Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.Source


     * @param uri Uri of the source.
     * @param deep Deep of the hirachy, which should traversed.
     */
    private void collectSources(Hashtable sources, String uri,
                                int deep) throws ProcessingException {
        Source source = null;

        try {
            source = this.resolver.resolveURI(uri+this.queryString);
        } catch (Exception e) {
            if (sources.isEmpty()) {
View Full Code Here


                                         throws SAXException,
                                                SourceException,
                                                ProcessingException,
                                                IOException {

        Source source = (Source) this.cachedsources.get(uri);

        if (source==null) {
            return;
        }

        try {
            AttributesImpl attributes = new AttributesImpl();

            attributes.addAttribute("", URI_ATTR_NAME, URI_ATTR_NAME,
                                    "CDATA", source.getURI());

            String name = source.getURI();

            if (name.endsWith("://")) {
                attributes.addAttribute("", NAME_ATTR_NAME,
                                        NAME_ATTR_NAME, "CDATA", "");
            } else if (name.endsWith("/")) {
                name = name.substring(1, name.length()-1);
                attributes.addAttribute("", NAME_ATTR_NAME,
                                        NAME_ATTR_NAME, "CDATA",
                                        name.substring(name.lastIndexOf("/")+
                                                       1, name.length()));
            } else {
                attributes.addAttribute("", NAME_ATTR_NAME,
                                        NAME_ATTR_NAME, "CDATA",
                                        name.substring(name.lastIndexOf("/")+
                                                       1, name.length()));
            }

            if ((source.getMimeType()!=null) &&
                (source.getMimeType().length()>0)) {
                attributes.addAttribute("", MIMETYPE_ATTR_NAME,
                                        MIMETYPE_ATTR_NAME, "CDATA",
                                        source.getMimeType());
            }

            if (source.getContentLength()>=0) {
                attributes.addAttribute("", CONTENTLENGTH_ATTR_NAME,
                                        CONTENTLENGTH_ATTR_NAME, "CDATA",
                                        String.valueOf(source.getContentLength()));
            }

            if (source.getLastModified()>0) {
                attributes.addAttribute("", LASTMODIFIED_ATTR_NAME,
                                        LASTMODIFIED_ATTR_NAME, "CDATA",
                                        String.valueOf(source.getLastModified()));
            }

            if (this.version && (source instanceof VersionableSource)) {
                VersionableSource versionablesource = (VersionableSource) source;
View Full Code Here

            datatype.setSelectionList(selectionList);
        }
    }

    private Element readSelectionList(String src) throws Exception {
        Source source = resolve(src);
        InputSource inputSource = new InputSource(source.getInputStream());
        inputSource.setSystemId(source.getURI());
        Document document = DomHelper.parse(inputSource);
        Element selectionListElement = document.getDocumentElement();
        if (!Constants.WD_NS.equals(selectionListElement.getNamespaceURI()) || !"selection-list".equals(selectionListElement.getLocalName()))
            throw new Exception("Excepted a wd:selection-list element at " + DomHelper.getLocation(selectionListElement));
        return selectionListElement;
View Full Code Here

     */
    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source,
        Parameters parameters) throws Exception {
        String urlstring = parameters.getParameter("url", source);
        String typestring = parameters.getParameter("type", "resource");
        Source src = null;

        try {
            src = resolver.resolveURI(urlstring);

            File resource = new File(new URL(src.getURI()).getFile());

            if (typestring.equals("resource") && src.exists()) {
                getLogger().debug(".act(): Resource (file or directory) exists: " + src.getURI());

                return EMPTY_MAP;
            } else if (typestring.equals("file") && resource.isFile()) {
                getLogger().debug(".act(): File exists: " + resource);

View Full Code Here

    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
        throws ConfigurationException {

        String resourceURI = name;
       
        Source source = null;
        boolean exists = false;
        try {
            source = resolver.resolveURI(resourceURI);
            exists = source.exists();
        } catch (SourceNotFoundException e) {
            exists = false;
        } catch (Exception e) {
            getLogger().warn("Exception resolving resource [" + resourceURI + "]", e);
            exists = false;
View Full Code Here

        List baseUriList = new ArrayList();

        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
            Source source = null;
            for (int i = 0; i < pathConfigs.length; i++) {
                String uri = pathConfigs[i].getAttribute(ATTRIBUTE_SRC);
                try {
                    source = resolver.resolveURI(uri);
                    if (source.exists()) {
                        File file = SourceUtil.getFile(source);
                        if (file.isDirectory()) {
                            baseUriList.add(uri);
                        } else {
                            getLogger().warn("Omitting path [" + uri + "] (not a directory).");
View Full Code Here

        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);

            String[] baseUris = getBaseURIs(objectModel);
            Source source = null;
            int i = 0;
            while (resolvedUri == null && i < baseUris.length) {
                String uri = baseUris[i] + "/" + path;

                checkedUris += uri + "\n";

                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Trying to resolve URI [" + uri + "]");
                }

                try {
                    source = resolver.resolveURI(uri);
                    if (source.exists()) {
                        resolvedUri = uri;
                    } else {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Skipping URI [" + uri + "] (does not exist).");
                        }
View Full Code Here

    public static Publication getPublication(SourceResolver resolver, Request request)
        throws PublicationException {
        log.debug("Creating publication from resolver and request");
        Publication publication;
        String webappUri = ServletHelper.getWebappURI(request);
        Source source = null;
        try {
            source = resolver.resolveURI("context:///");
            File servletContext = SourceUtil.getFile(source);
            publication = PublicationFactory.getPublication(webappUri, servletContext);
        } catch (Exception e) {
View Full Code Here

     *
     * @throws Exception DOCUMENT ME!
     */
    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
        Parameters parameters) throws Exception {
        Source input_source = resolver.resolveURI("");
        String sitemapParentPath = input_source.getURI();
        sitemapParentPath = sitemapParentPath.substring(5); // Remove "file:" protocol

        getLogger().debug(".act(): PARENT PATH OF SITEMAP: " + sitemapParentPath);

        // Get request object
View Full Code Here

                String value = (String) cache.get(key);

                if (value == null) {
                    String parameterSrc = parameters.getParameter(parameterNames[i]) + "/" + src;

                    Source inputSource = null;
                    try {
                        inputSource = resolver.resolveURI(parameterSrc);

                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("File resolved to " + inputSource.getURI());
                        }

                        SourceUtil.toSAX(inputSource, xmlConsumer);
                    } finally {
                        if (inputSource != null) {
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.Source

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.