Return-Path: Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 1763 invoked by uid 500); 2 Aug 2000 17:18:22 -0000 Delivered-To: apmail-jakarta-tomcat-cvs@apache.org Received: (qmail 1758 invoked by uid 1135); 2 Aug 2000 17:18:22 -0000 Date: 2 Aug 2000 17:18:21 -0000 Message-ID: <20000802171821.1757.qmail@locus.apache.org> From: remm@locus.apache.org To: jakarta-tomcat-cvs@apache.org Subject: cvs commit: jakarta-tomcat/proposals/catalina/src/share/org/apache/tomcat/servlets WebdavServlet.java 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