cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From step...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/webdav/java/org/apache/cocoon/components/source/impl WebDAVSource.java
Date Tue, 13 Apr 2004 14:20:36 GMT
stephan     2004/04/13 07:20:35

  Modified:    src/blocks/webdav/java/org/apache/cocoon/components/source/impl
                        WebDAVSource.java
  Log:
  Make getParent available for directories.
  tab2spaces
  
  Revision  Changes    Path
  1.27      +38 -57    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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- WebDAVSource.java	29 Mar 2004 10:52:46 -0000	1.26
  +++ WebDAVSource.java	13 Apr 2004 14:20:35 -0000	1.27
  @@ -189,30 +189,27 @@
        * @throws SourceNotFoundException
        */
       private void initResource(int action, int depth) throws SourceException, SourceNotFoundException
{
  -		try {
  +        try {
               boolean update = false;
               if (action != WebdavResource.NOACTION) {
                   if (action > this.action) {
                       this.action = action;
                       update = true;
  -                }
  -                else {
  +                } else {
                       action = this.action;
                   }
               }
               if (depth > this.depth) {
                   this.depth = depth;
                   update = true;
  -            }
  -            else {
  +            } else {
                   depth = this.depth;
               }
  -			if (this.resource == null) {
  -			    this.resource = new WebdavResource(this.url, action, depth);
  -			}
  -			else if (update) {
  -			    this.resource.setProperties(action, depth);
  -			}
  +            if (this.resource == null) {
  +                this.resource = new WebdavResource(this.url, action, depth);
  +            } else if (update) {
  +                this.resource.setProperties(action, depth);
  +            }
               if (this.action > WebdavResource.NOACTION) {
                   if (this.resource.isCollection()) {
                       String path = this.url.getPath();
  @@ -221,18 +218,16 @@
                       }
                   }
               }
  - 		}
  -		catch (HttpException e) {
  +       } catch (HttpException e) {
               if (e.getReasonCode() == HttpStatus.SC_NOT_FOUND) {
                   throw new SourceNotFoundException("Not found: " + getSecureURI(), e);
               }
               final String msg = "Could not initialize webdav resource. Server responded
" 
                   + e.getReasonCode() + " (" + e.getReason() + ") - " + e.getMessage();
               throw new SourceException(msg, e);
  -		}
  -		catch (IOException e) {
  +       } catch (IOException e) {
               throw new SourceException("Could not initialize webdav resource", e);
  -		}
  +       }
       }
   
       /**
  @@ -282,8 +277,7 @@
               final String userinfo = this.url.getEscapedUserinfo();
               if (userinfo != null) {
                   uri = this.protocol + "://" + userinfo + "@" + uri;
  -            }
  -            else {
  +            } else {
                   uri = this.protocol + "://" + uri;
               }
               this.uri = uri;
  @@ -366,8 +360,7 @@
       public String getMimeType() {
           try {
               initResource(WebdavResource.BASIC, DepthSupport.DEPTH_0);
  -        }
  -        catch (IOException e) {
  +        } catch (IOException e) {
               return null;
           }
           return this.resource.getGetContentType();
  @@ -398,8 +391,7 @@
       public long getLastModified() {
           try {
               initResource(WebdavResource.BASIC, DepthSupport.DEPTH_0);
  -        }
  -        catch(IOException e) {
  +        } catch(IOException e) {
               return 0;
           }
           return this.resource.getGetLastModified();
  @@ -413,11 +405,9 @@
       public boolean exists() {
           try {
               initResource(WebdavResource.BASIC, DepthSupport.DEPTH_0);
  -        }
  -        catch (SourceNotFoundException e) {
  +        } catch (SourceNotFoundException e) {
               return false;
  -        }
  -        catch(IOException e) {
  +        } catch(IOException e) {
               return true;
           }
           return this.resource.getExistence();
  @@ -540,13 +530,11 @@
               HttpURL childURL;
               if (this.url instanceof HttpsURL) {
                   childURL = new HttpsURL((HttpsURL) this.url, childName);
  -            }
  -            else {
  +            } else {
                   childURL = new HttpURL(this.url, childName);
               }
               return WebDAVSource.newWebDAVSource(childURL, this.protocol, getLogger());
  -        }
  -        catch (URIException e) {
  +        } catch (URIException e) {
               throw new SourceException("Failed to create child", e);
           }        
       }
  @@ -565,8 +553,7 @@
                   HttpURL childURL;
                   if (this.url instanceof HttpsURL) {
                       childURL = new HttpsURL((HttpsURL) this.url,resources[i].getName());
  -                }
  -                else {
  +                } else {
                       childURL = new HttpURL(this.url,resources[i].getName());
                   }
                   WebDAVSource src = WebDAVSource.newWebDAVSource(resources[i],
  @@ -576,8 +563,7 @@
                   src.enableLogging(getLogger());
                   children.add(src);
               }
  -        }
  -        catch (HttpException e) {
  +        } catch (HttpException e) {
               if (getLogger().isDebugEnabled()) {
                   final String message =
                       "Unable to get WebDAV children. Server responded " +
  @@ -586,11 +572,9 @@
                   getLogger().debug(message);
               }
               throw new SourceException("Failed to get WebDAV collection children.", e);
  -        } 
  -        catch (SourceException e) {
  +        } catch (SourceException e) {
               throw e;
  -        }
  -        catch (IOException e) {
  +        } catch (IOException e) {
               throw new SourceException("Failed to get WebDAV collection children.", e);
           }
           return children;
  @@ -616,17 +600,17 @@
        * @see org.apache.excalibur.source.TraversableSource#getParent()
        */
       public Source getParent() throws SourceException {
  +        String path = isCollection()?"..":".";
  +      
           try {
               HttpURL parentURL;
               if (url instanceof HttpsURL) {
  -                parentURL = new HttpsURL((HttpsURL) this.url, ".");
  -            }
  -            else {
  -                parentURL = new HttpURL(this.url, ".");
  +                parentURL = new HttpsURL((HttpsURL) this.url, path);
  +            } else {
  +                parentURL = new HttpURL(this.url, path);
               }
               return WebDAVSource.newWebDAVSource(parentURL, this.protocol, getLogger());
  -        }
  -        catch (URIException e) {
  +        } catch (URIException e) {
               throw new SourceException("Failed to create parent", e);
           }
       }
  @@ -700,13 +684,13 @@
        * @see org.apache.excalibur.source.ModifiableSource#delete()
        */
       public void delete() throws SourceException {
  -    	initResource(WebdavResource.NOACTION, DepthSupport.DEPTH_0);
  +      initResource(WebdavResource.NOACTION, DepthSupport.DEPTH_0);
           try {
               this.resource.deleteMethod();
           } catch (HttpException e) {
  -        	throw new SourceException("Unable to delete source: " + getSecureURI(), e);
  +            throw new SourceException("Unable to delete source: " + getSecureURI(), e);
           } catch (IOException e) {
  -			throw new SourceException("Unable to delete source: " + getSecureURI(), e);
  +            throw new SourceException("Unable to delete source: " + getSecureURI(), e);
           }
       }
   
  @@ -760,7 +744,7 @@
       public void makeCollection() throws SourceException {
           initResource(WebdavResource.NOACTION, DepthSupport.DEPTH_0);
           if (this.resource.exists()) return;
  -    	try {
  +        try {
               if (!this.resource.mkcolMethod()) {
                   int status = this.resource.getStatusCode();
                   // Ignore status 405 - Not allowed: collection already exists
  @@ -772,15 +756,12 @@
                       throw new SourceException(msg);
                   }
               }
  -        }
  -    	catch (HttpException e) {
  +        } catch (HttpException e) {
               throw new SourceException("Unable to create collection(s) " + getSecureURI(),
e);
  -        }
  -    	catch (SourceException e) {
  +        } catch (SourceException e) {
               throw e;
  -        }
  -        catch (IOException e) {
  -            throw new SourceException("Unable to create collection(s)"  + getSecureURI(),
e);			
  +        } catch (IOException e) {
  +            throw new SourceException("Unable to create collection(s)"  + getSecureURI(),
e);      
           }
       }
       
  @@ -890,7 +871,7 @@
           initResource(WebdavResource.NOACTION, DepthSupport.DEPTH_0);
           
           try {
  -			Node node = null;
  +            Node node = null;
               NodeList list = sourceproperty.getValue().getChildNodes();
               for (int i=0; i<list.getLength(); i++) {
                   if ((list.item(i) instanceof Text && !"".equals(list.item(i).getNodeValue()))
  
  
  

Mime
View raw message