Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.ModifiableTraversableSource


    }

    public void testCrawlUp() throws Exception {
        String text = "Look Pa, some more!";

        ModifiableTraversableSource src = (ModifiableTraversableSource)resolver.resolveURI("jcr://path/to/very/deep/content");
        write(src, text);

        // Do a fresh lookup
        src = (ModifiableTraversableSource)resolver.resolveURI("jcr://path/to/very/deep/content");

        ModifiableTraversableSource parent = (ModifiableTraversableSource)src.getParent();
        assertTrue(parent.exists());
        assertEquals("jcr://path/to/very/deep", parent.getURI());

        parent = (ModifiableTraversableSource)parent.getParent();
        assertTrue(parent.exists());
        assertEquals("jcr://path/to/very", parent.getURI());

        parent = (ModifiableTraversableSource)parent.getParent();
        assertTrue(parent.exists());
        assertEquals("jcr://path/to", parent.getURI());

        parent = (ModifiableTraversableSource)parent.getParent();
        assertTrue(parent.exists());
        assertEquals("jcr://path", parent.getURI());

        parent = (ModifiableTraversableSource)parent.getParent();
        assertTrue(parent.exists());
        assertEquals("jcr://", parent.getURI());

        // Root node has no parent
        parent = (ModifiableTraversableSource)parent.getParent();
        assertNull(parent);
    }
View Full Code Here


            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

   
    // ---------------------------------------------------- ModifiableTraversableSource
   
    public Source getChild(String name) throws SourceException {
        if (!m_delegate.isCollection()) return null;
        ModifiableTraversableSource child = (ModifiableTraversableSource) m_delegate.getChild(name);
        if (child == null) return null;
       
        return new RepositorySource(
            m_prefix,
            child,
View Full Code Here

    public Collection getChildren() throws SourceException {
        if (!m_delegate.isCollection()) return null;
      Collection result = new ArrayList();
    Iterator iter = m_delegate.getChildren().iterator();
      while(iter.hasNext()) {
            ModifiableTraversableSource child = (ModifiableTraversableSource) iter.next();
           
        result.add(
                new RepositorySource(
                    m_prefix,
                    child,
View Full Code Here

        return source;
    }

    public static void save(Request request, String dirName) throws Exception {
        TraversableSource collection = getCollection(dirName);
        ModifiableTraversableSource result;
       
        Enumeration params = request.getParameterNames();
        while (params.hasMoreElements()) {
            String name = (String) params.nextElement();
            if (name.indexOf("..") > -1) throw new Exception("We are under attack!!");
View Full Code Here

        contents = resource.getChildren();
      } catch (SourceException se) {
        throw new RuntimeException("Unable to list contents for collection " + resource);
      }
      for (Iterator iter = contents.iterator(); iter.hasNext();) {
                ModifiableTraversableSource element = (ModifiableTraversableSource) iter.next();
                success = remove(element);
            }
                     
        }
        try {
View Full Code Here

        contents = from.getChildren();
      } catch (SourceException se) {
        throw new RuntimeException("Unable to list contents for collection " + from);
      }
      for (Iterator iter = contents.iterator(); iter.hasNext();) {
        ModifiableTraversableSource src = (ModifiableTraversableSource) iter.next();
        SourceUtil.copy(src, env.resolveURI(to.getURI() + "/" + src.getName()));       

      }
        } else {
            to = (ModifiableTraversableSource)env.resolveURI(to.getURI());
            InputStream in = null;
View Full Code Here

TOP

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

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.