You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2001/03/16 06:47:52 UTC

cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources DirContextURLConnection.java

remm        01/03/15 21:47:52

  Modified:    catalina/src/share/org/apache/naming/resources
                        DirContextURLConnection.java
  Log:
  - Add a new list call which returns an enumeration of names of the children of
    a collection. Since that call isn't part of the URLConnection methods, the
    URL connection returned by getResource(path).openConnection() needs
    to be typecast.
  
  Revision  Changes    Path
  1.3       +46 -4     jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java
  
  Index: DirContextURLConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DirContextURLConnection.java	2001/01/26 01:04:25	1.2
  +++ DirContextURLConnection.java	2001/03/16 05:47:51	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v 1.2 2001/01/26 01:04:25 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/01/26 01:04:25 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/naming/resources/DirContextURLConnection.java,v 1.3 2001/03/16 05:47:51 remm Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/03/16 05:47:51 $
    *
    * ====================================================================
    *
  @@ -69,7 +69,11 @@
   import java.io.InputStream;
   import java.io.FileNotFoundException;
   import java.util.Date;
  +import java.util.Enumeration;
  +import java.util.Vector;
   import javax.naming.NamingException;
  +import javax.naming.NamingEnumeration;
  +import javax.naming.NameClassPair;
   import javax.naming.directory.DirContext;
   import javax.naming.directory.Attribute;
   import javax.naming.directory.Attributes;
  @@ -85,7 +89,7 @@
    * content is directly returned.
    * 
    * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public class DirContextURLConnection 
       extends URLConnection {
  @@ -303,6 +307,44 @@
           }
           
           return (resource.streamContent());
  +        
  +    }
  +    
  +    
  +    // --------------------------------------------------------- Public Methods
  +    
  +    
  +    /**
  +     * List children of this collection. The names given are relative to this
  +     * URI's path. The full uri of the children is then : path + "/" + name.
  +     */
  +    public Enumeration list()
  +        throws IOException {
  +        
  +        if (!connected) {
  +            connect();
  +        }
  +        
  +        if ((resource == null) && (collection == null)) {
  +            throw new FileNotFoundException();
  +        }
  +        
  +        Vector result = new Vector();
  +        
  +        if (collection != null) {
  +            try {
  +                NamingEnumeration enum = context.list(getURL().getFile());
  +                while (enum.hasMoreElements()) {
  +                    NameClassPair ncp = (NameClassPair) enum.nextElement();
  +                    result.addElement(ncp.getName());
  +                }
  +            } catch (NamingException e) {
  +                // Unexpected exception
  +                throw new FileNotFoundException();
  +            }
  +        }
  +        
  +        return result.elements();
           
       }