Examples of TraversableSource


Examples of org.apache.cocoon.components.source.TraversableSource

        }

        sources.put(uri, source);

        if (source instanceof TraversableSource) {
            TraversableSource traversablesource = (TraversableSource) source;

            try {
                if (traversablesource.isSourceCollection() && (deep>0)) {
                    for (int i = 0; i<traversablesource.getChildSourceCount();
                        i++)
                        collectSources(sources,
                                       traversablesource.getChildSource(i),
                                       deep-1);
                }
            } catch (SourceException se) {
                getLogger().warn("Could not traverse source", se);
            }
View Full Code Here

Examples of org.apache.cocoon.components.source.TraversableSource

                    }
                }
            }

            boolean isCollection = false;
            TraversableSource traversablesource = null;

            if (source instanceof TraversableSource) {
                traversablesource = (TraversableSource) source;

                isCollection = traversablesource.isSourceCollection();

                attributes.addAttribute("", COLLECTION_ATTR_NAME,
                                        COLLECTION_ATTR_NAME, "CDATA",
                                        String.valueOf(isCollection));

                String parent = traversablesource.getParentSource();

                if ((parent!=null) && (parent.length()>0)) {
                    attributes.addAttribute("", PARENT_ATTR_NAME,
                                            PARENT_ATTR_NAME, "CDATA",
                                            parent);
                }
            }

            this.contentHandler.startElement(SOURCE_NS, SOURCE_NODE_NAME,
                                             SOURCE_NODE_QNAME, attributes);

            if (this.properties && (source instanceof InspectableSource)) {
                pushLiveSourceProperties((InspectableSource) source);
            }

            if (this.properties) {
                pushComputedSourceProperties(source);
            }

            if (this.permissions) {
                try {
                    if (source instanceof RestrictableSource) {
                        pushSourcePermissions((RestrictableSource) source);
                    }
                } catch (SourceException se) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("Could not retrieve source permissions",
                                          se);
                    }
                }
            }

            if (this.locks && (source instanceof LockableSource)) {
                pushSourceLocks((LockableSource) source);
            }

            if ((isCollection) && (deep>0)) {
                this.contentHandler.startElement(SOURCE_NS,
                                                 CHILDREN_NODE_NAME,
                                                 CHILDREN_NODE_QNAME,
                                                 new AttributesImpl());
                for (int i = 0; i<traversablesource.getChildSourceCount();
                    i++) {
                    try {
                        pushSourceDescription(traversablesource.getChildSource(i),
                                              deep-1);
                    } catch (SourceException se) {
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Could not retrieve source",
                                              se);
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("copy: " + source.getURI() + " -> " + destination.getURI());
        }
       
        if (source instanceof TraversableSource) {
            final TraversableSource origin = (TraversableSource) source;
            ModifiableTraversableSource target = null;
            if (origin.isCollection()) {
                if (!(destination instanceof ModifiableTraversableSource)) {
                    final String message = "copy() is forbidden: " +
                        "Cannot create a collection at the indicated destination.";
                    getLogger().warn(message);
                    return STATUS_FORBIDDEN;
                }
                // TODO: copy properties
                target = ((ModifiableTraversableSource) destination);
                m_interceptor.preStoreSource(target);
                target.makeCollection();
                m_interceptor.postStoreSource(target);
                if (recurse) {
                    Iterator children = origin.getChildren().iterator();
                    while (children.hasNext()) {
                        TraversableSource child = (TraversableSource) children.next();
                        /*int status =*/ copy(child,target.getChild(child.getName()),recurse);
                        // TODO: record this status
                        // according to the spec we must continue moving files even though
                        // a part of the move has not succeeded
                    }
                }
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

     * @throws  SAXException if an error occurs while outputting the document
     * @throws  ProcessingException if something went wrong while traversing
     *                              the source hierarchy
     */
    public void generate() throws SAXException, ProcessingException {
        TraversableSource inputSource = null;
        try {
            inputSource = (TraversableSource) this.resolver.resolveURI(this.source);

            if (!inputSource.isCollection()) {
                throw new ResourceNotFoundException(this.source + " is not a collection.");
            }

            this.contentHandler.startDocument();

View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

     *
     * @param source the traversable source whose ancestors shall be retrieved
     * @return a Stack containing the ancestors.
     */
    protected Stack getAncestors(TraversableSource source) throws IOException {
        TraversableSource parent = source;
        Stack ancestors = new Stack();

        while ((parent != null) && !isRoot(parent)) {
            parent = (TraversableSource) parent.getParent();
            if (parent != null) {
                ancestors.push(parent);
            } else {
                // no ancestor matched the root pattern
                ancestors.clear();
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

                        }
                    });
                } else if (sort.equals("collection")) {
                    Arrays.sort(contents.toArray(), new Comparator() {
                        public int compare(Object o1, Object o2) {
                            TraversableSource ts1 = (TraversableSource) o1;
                            TraversableSource ts2 = (TraversableSource) o2;

                            if (reverse) {
                                if (ts2.isCollection() && !ts1.isCollection())
                                    return -1;
                                if (!ts2.isCollection() && ts1.isCollection())
                                    return 1;
                                return ts2.getName().compareTo(ts1.getName());
                            }
                            if (ts2.isCollection() && !ts1.isCollection())
                                return 1;
                            if (!ts2.isCollection() && ts1.isCollection())
                                return -1;
                            return ts1.getName().compareTo(ts2.getName());
                        }
                    });
                }

                for (int i = 0; i < contents.size(); i++) {
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

    /**
     *
     */
    public Collection getChildren() throws RepositoryException {
        SourceResolver resolver = null;
        TraversableSource source = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (TraversableSource) resolver.resolveURI(this.contentSource.getRealSourceUri());
            Collection children = source.getChildren();
            java.util.Iterator iterator = children.iterator();
            java.util.Vector newChildren = new java.util.Vector();
            while (iterator.hasNext()) {
                TraversableSource child = (TraversableSource) iterator.next();
                newChildren.add(new SourceNode(getSession(),
                        getSourceURI() + "/" + child.getName(), this.manager, getLogger()));
            }
            return newChildren;
        } catch (Exception e) {
            throw new RepositoryException(e);
        }
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

    /**
     *
     */
    public boolean isCollection() throws RepositoryException {
        SourceResolver resolver = null;
        TraversableSource source = null;
        try {
            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
            source = (TraversableSource) resolver.resolveURI(this.contentSource.getRealSourceUri());
            return source.isCollection();
        } catch (Exception e) {
            throw new RepositoryException(e);
        }
    }
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

        return this.rootSource;
    }

    public Collection getChildren(Object parent) {
        if (parent instanceof TraversableSource) {
            TraversableSource dir = (TraversableSource)parent;
            try {
                // Return children if it's a collection, null otherwise
                return dir.isCollection() ? filterChildren(dir.getChildren()) : null;
            } catch (SourceException e) {
                throw new CascadingRuntimeException("getChildren", e);
            }
        } else {
            return null;
View Full Code Here

Examples of org.apache.excalibur.source.TraversableSource

        }
       
        ArrayList result = new ArrayList();
        Iterator iter = coll.iterator();
        while(iter.hasNext()) {
            TraversableSource src = (TraversableSource)iter.next();

            // Does it match the patterns?
            boolean matches = true;
            if (src.isCollection()) {
                matches = matches(src, this.dirIncludePatterns, this.dirExcludePatterns);
            } else {
                matches = matches(src, this.fileIncludePatterns, this.fileExcludePatterns);
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.