You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2003/10/29 15:16:53 UTC

cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java

vgritsenko    2003/10/29 06:16:53

  Modified:    src/blocks/webdav/java/org/apache/cocoon/components/source/impl
                        WebDAVSource.java
  Log:
  Vector -> ArrayList;
  Add TODOs for missing logging;
  Reformat code
  
  Revision  Changes    Path
  1.10      +38 -44    cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java
  
  Index: WebDAVSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl/WebDAVSource.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- WebDAVSource.java	25 Sep 2003 17:28:38 -0000	1.9
  +++ WebDAVSource.java	29 Oct 2003 14:16:53 -0000	1.10
  @@ -61,6 +61,7 @@
   import java.util.Properties;
   import java.util.Vector;
   import java.util.Enumeration;
  +import java.util.ArrayList;
   
   import javax.xml.transform.OutputKeys;
   import javax.xml.transform.TransformerFactory;
  @@ -164,39 +165,35 @@
   
       /**
        * Static factory method to obtain a Source.
  -     * 
  -     * 
        */
  -    
  -    public static WebDAVSource newWebDAVSource(
  -      String location,
  -      String principal,
  -      String password,
  -      String protocol) throws SourceException {
  -          // FIXME: wild hack needed for writing to a new resource.
  -          // if a resource doesn't exist, an exception
  -          // will be thrown, unless such resource isn't created with the
  -          // WebdavResouce.NOACTION flag. However, such flag cannot be
  -          // used by default, since it won't allow to discover the 
  -          // properties of an exixting resource. So either we do this
  -          // hack here or we fill properties on the fly when requested.
  -          // This "solution" is scary, but the SWCL is pretty dumb.
  -          try {
  -            return new WebDAVSource(location, principal, password, protocol, false);  
  -          }  catch (HttpException he) {
  -             try { 
  -                 return new WebDAVSource(location, principal, password, protocol, true);            
  -             } catch (HttpException finalHe) {
  -             	finalHe.printStackTrace(System.err);
  -                throw new SourceException("Error creating the source: ", finalHe);   
  -             } catch (IOException e) {
  -				e.printStackTrace(System.err);
  -                throw new SourceException("Error creating the source: ", e);                	
  -             }    
  -          } catch (IOException e) {
  -                throw new SourceException("Error creating the source: ", e);   
  -          }      
  -      }      
  +    public static WebDAVSource newWebDAVSource(String location,
  +                                               String principal,
  +                                               String password,
  +                                               String protocol) throws SourceException {
  +        // FIXME: wild hack needed for writing to a new resource.
  +        // if a resource doesn't exist, an exception
  +        // will be thrown, unless such resource isn't created with the
  +        // WebdavResouce.NOACTION flag. However, such flag cannot be
  +        // used by default, since it won't allow to discover the
  +        // properties of an exixting resource. So either we do this
  +        // hack here or we fill properties on the fly when requested.
  +        // This "solution" is scary, but the SWCL is pretty dumb.
  +        try {
  +            return new WebDAVSource(location, principal, password, protocol, false);
  +        }  catch (HttpException he) {
  +            try {
  +                return new WebDAVSource(location, principal, password, protocol, true);
  +            } catch (HttpException finalHe) {
  +                finalHe.printStackTrace(System.err);
  +                throw new SourceException("Error creating the source: ", finalHe);
  +            } catch (IOException e) {
  +                e.printStackTrace(System.err);
  +                throw new SourceException("Error creating the source: ", e);
  +            }
  +        } catch (IOException e) {
  +            throw new SourceException("Error creating the source: ", e);
  +        }
  +    }
   
       /**
        * Constructor used by the Traversable methods to build children.
  @@ -245,14 +242,13 @@
        * Return the unique identifer for this source
        */
       public String getURI() {
  -    	// Change http: to webdav:
  +        // Change http: to webdav:
           //return "webdav:" + this.systemId.substring(5);
           //add Source credentials
           if (principal != null)
  -			return "webdav://" + this.principal + ":" + this.password + "@" +  this.systemId.substring(7);
  +            return "webdav://" + this.principal + ":" + this.password + "@" +  this.systemId.substring(7);
           else
  -		return "webdav://"  +  this.systemId.substring(7);
  -        
  +            return "webdav://"  +  this.systemId.substring(7);
       }
       
       /**
  @@ -603,7 +599,7 @@
        * @see org.apache.excalibur.source.TraversableSource#getChildren()
        */
       public Collection getChildren() throws SourceException {
  -        Vector children = new Vector();
  +        ArrayList children = new ArrayList();
           try {
               WebdavResource[] resources = this.resource.listWebdavResources();
               for (int i = 0; i < resources.length; i++) {
  @@ -611,11 +607,11 @@
                   children.add(src);
               }
           } catch (HttpException e) {
  -            e.printStackTrace();
  -            throw new SourceException(e.getMessage());
  +            // TODO: getLogger.debug()
  +            throw new SourceException(e.getMessage(), e);
           } catch (IOException e) {
  -            e.printStackTrace();
  -            throw new SourceException(e.getMessage());
  +            // TODO: getLogger.debug()
  +            throw new SourceException(e.getMessage(), e);
           }
           return children;
       }
  @@ -781,7 +777,6 @@
       throws SourceException {
   
           try {
  -
               Document doc = sourceproperty.getValue().getOwnerDocument();
               DocumentFragment frag = doc.createDocumentFragment();
               NodeList list = sourceproperty.getValue().getChildNodes();
  @@ -802,5 +797,4 @@
               throw new SourceException("Could not set property ", e);
           }
       }
  -
   }