Package org.apache.excalibur.source

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


        }
       
        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

    }

    private static Source resolve(String uri)
    throws MalformedURLException, IOException {
        SourceResolver resolver = null;
        TraversableSource source;
        try {
            resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
            source = (TraversableSource) resolver.resolveURI(uri);
        } catch (ComponentException ce) {
            throw new IOException("ComponentException");
View Full Code Here

        }
        return source;
    }

    private static TraversableSource getCollection(String colName) {
      TraversableSource source;
        try {
            source = (TraversableSource)resolve(colName);
        } catch (MalformedURLException e) {
            throw new RuntimeException("'unable to resolve source: malformed URL");
        } catch (IOException e) {
            throw new RuntimeException("'unable to resolve source: IOException");
        }
        if (!source.isCollection()) throw new RuntimeException(colName + " is not a collection!");
        return source;
    }
View Full Code Here

        if (!source.isCollection()) throw new RuntimeException(colName + " is not a collection!");
        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!!");
//System.out.println("[param] " + name);
            if (name.startsWith("save:")) {
                Part part = (Part) request.get(name);
                String code = name.substring(5);
                if (!(collection instanceof ModifiableSource)) {
                  throw new RuntimeException("Cannot modify the given source");
                }
                result = (ModifiableTraversableSource)resolve(collection.getURI() + "/" + code);

                save(part, result);
            } else if (name.startsWith("delete:")) {
                String value = request.getParameter(name);
                if (value.length() > 0) {
View Full Code Here

    /**
     * Returns the highest version id of the files included in the given
     * directory.
     */
    public static int getVersionID(String colName) {
        TraversableSource collection = getCollection(colName);
        int id = 0;
        Collection contents;
        try {
            contents = collection.getChildren();
        } catch (SourceException se) {
          throw new RuntimeException("Unable to list contents for collection " + colName);
        }
        for (Iterator iter = contents.iterator(); iter.hasNext();) {
            TraversableSource content = (TraversableSource) iter.next();
            if (!content.isCollection()) {
        try {
          int localid = getVersion(content.getName());
          if (localid > id) id = localid;
        } catch (Exception e) {}

            }
        }
View Full Code Here

        return ++id;
    }

    public static Object[] getVersions(String colName) {
      TraversableSource collection = getCollection(colName);
        ArrayList versions = new ArrayList();

    Collection contents;
    try {
      contents = collection.getChildren();
    } catch (SourceException se) {
      throw new RuntimeException("Unable to list contents for collection " + colName);
    }

        for (Iterator iter = contents.iterator(); iter.hasNext();) {
            TraversableSource content = (TraversableSource) iter.next();
      if (!content.isCollection())  {
         try {
           int version = getVersion(content.getName());
           if (version > 0) {
             versions.add(new Integer(version));
           }
         } catch (Exception e) {}
       }
View Full Code Here

        }
        return -1;
    }

    public static int getID(String colName) {
        TraversableSource collection = getCollection(colName);

        int id = 0;
    Collection contents;
    try {
      contents = collection.getChildren();
    } catch (SourceException se) {
      throw new RuntimeException("Unable to list contents for collection " + colName);
    }

    for (Iterator iter = contents.iterator(); iter.hasNext();) {
            TraversableSource content = (TraversableSource) iter.next();
      if (content.isCollection())  {
        try {
          String name = content.getName();
          int localid = Integer.parseInt(name);
          if (localid > id) id = localid;
        } catch (Exception e) {}
      }
        }
View Full Code Here

        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 RuntimeException("getChildren", e);
            }
        } else {
            return null;
View Full Code Here

        }
       
        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

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

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.