tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@locus.apache.org
Subject cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets WebdavServlet.java
Date Wed, 02 Aug 2000 17:18:21 GMT
remm        00/08/02 10:18:21

  Modified:    proposals/catalina/src/share/org/apache/tomcat/servlets
                        WebdavServlet.java
  Log:
  - Delete method support (without error reporting)
  
  Revision  Changes    Path
  1.3       +73 -5     jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/WebdavServlet.java
  
  Index: WebdavServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/WebdavServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebdavServlet.java	2000/08/01 07:19:39	1.2
  +++ WebdavServlet.java	2000/08/02 17:18:19	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/WebdavServlet.java,v
1.2 2000/08/01 07:19:39 remm Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/08/01 07:19:39 $
  + * $Header: /home/cvs/jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets/WebdavServlet.java,v
1.3 2000/08/02 17:18:19 remm Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/08/02 17:18:19 $
    *
    * ====================================================================
    *
  @@ -118,7 +118,7 @@
    * are handled by the DefaultServlet.
    *
    * @author Remy Maucherat
  - * @version $Revision: 1.2 $ $Date: 2000/08/01 07:19:39 $
  + * @version $Revision: 1.3 $ $Date: 2000/08/02 17:18:19 $
    */
   
   public class WebdavServlet
  @@ -553,7 +553,50 @@
               return;
           }
           
  +	String servletPath = req.getServletPath();
  +	if (servletPath == null)
  +	    servletPath = "/";
  +        
  +        // Retrieve the Catalina context
  +        ApplicationContext context = (ApplicationContext) getServletContext();
  +
  +	// Convert the resource path to a URL
  +	URL resourceURL = null;
  +	try {
  +	    resourceURL = context.getResource(servletPath);
  +	} catch (MalformedURLException e) {
  +	    ;
  +	}
  +	if (resourceURL == null) {
  +	    resp.sendError(WebdavStatus.SC_NOT_FOUND);
  +	    return;
  +	}
  +
  +        Resources resources = context.getResources();
  +        
  +        boolean collection = resources.isCollection(servletPath);
  +        
  +        if (!collection) {
  +            if (!resources.deleteResource(servletPath)) {
  +                resp.sendError(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
  +                return;
  +            }
  +        } else {
  +            
  +            Hashtable errorList = new Hashtable();
  +            
  +            deleteCollection(resources, servletPath, errorList);
  +            resources.deleteResource(servletPath);
  +            
  +            if (!errorList.isEmpty()) {
  +                
  +                // TODO : Display a status report if there was an error
  +                
  +            }
  +            
  +        }
           
  +        resp.setStatus(WebdavStatus.SC_NO_CONTENT);
           
       }
   
  @@ -607,7 +650,7 @@
           }
           
           
  -
  +        
       }
   
   
  @@ -897,6 +940,31 @@
           }
           
           generatedXML.writeElement("d", "response", XMLWriter.CLOSING);
  +        
  +    }
  +
  +
  +    /**
  +     * Deletes a collection.
  +     * 
  +     * @param resources Resources implementation associated with the context
  +     * @param path Path to the collection to be deleted
  +     * @param errorList Contains the list of the errors which occured
  +     */
  +    private void deleteCollection(Resources resources, String path, 
  +                                  Hashtable errorList) {
  +        
  +        String[] members = resources.getCollectionMembers(path);
  +        
  +        for (int i=0; i<members.length; i++) {
  +            
  +            // TODO : Check locking
  +            if (resources.isCollection(members[i])) {
  +                deleteCollection(resources, members[i], errorList);
  +            }
  +            boolean result = resources.deleteResource(members[i]);
  +            
  +        }
           
       }
   
  
  
  

Mime
View raw message