From: Wolfgang M. M. <wol...@us...> - 2004-08-06 17:36:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11150/src/org/exist/http/webdav Modified Files: WebDAVMethod.java WebDAVMethodFactory.java WebDAV.java Log Message: Modified WebDAV implementation classes to have better control over collection and resource locks. Index: WebDAV.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/WebDAV.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** WebDAV.java 3 Aug 2004 20:54:33 -0000 1.7 --- WebDAV.java 6 Aug 2004 17:36:37 -0000 1.8 *************** *** 116,155 **** LOG.debug("path = " + path + "; method = " + request.getMethod()); - DocumentImpl resource = null; - Collection collection = null; WebDAVMethod method = null; ! DBBroker broker = null; ! boolean collectionLocked = false; ! try { ! broker = pool.get(user); ! ! method = WebDAVMethodFactory.create(request.getMethod(), pool); ! if(method == null) { ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "Method is not supported: " + request.getMethod()); ! return; ! } ! collection = broker.openCollection(path, Lock.READ_LOCK); ! if(collection == null) { ! resource = (DocumentImpl)broker.openDocument(path, Lock.READ_LOCK); ! if(resource != null) ! collection = resource.getCollection(); ! } else ! collectionLocked = true; ! } catch (EXistException e) { ! throw new ServletException("An error occurred while retrieving resource: " + e.getMessage(), e); ! } catch (PermissionDeniedException e) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, "Not allowed to access resource " + path); ! } finally { ! pool.release(broker); ! } ! try { ! method.process(user, request, response, collection, resource); ! } finally { ! if(collection != null && collectionLocked) ! collection.release(); ! if(resource != null) ! resource.getUpdateLock().release(); } } --- 116,128 ---- LOG.debug("path = " + path + "; method = " + request.getMethod()); WebDAVMethod method = null; ! ! method = WebDAVMethodFactory.create(request.getMethod(), pool); ! if(method == null) { ! response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, ! "Method is not supported: " + request.getMethod()); ! return; } + method.process(user, request, response, path); } *************** *** 167,171 **** return digestAuth.authenticate(request, response); } else { - LOG.debug("Falling back to basic authentication"); return basicAuth.authenticate(request, response); } --- 140,143 ---- Index: WebDAVMethod.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/WebDAVMethod.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WebDAVMethod.java 21 May 2004 08:35:42 -0000 1.2 --- WebDAVMethod.java 6 Aug 2004 17:36:37 -0000 1.3 *************** *** 29,35 **** import javax.servlet.http.HttpServletResponse; - import org.apache.log4j.Logger; - import org.exist.collections.Collection; - import org.exist.dom.DocumentImpl; import org.exist.security.User; --- 29,32 ---- *************** *** 41,46 **** public interface WebDAVMethod { - final static Logger LOG = Logger.getLogger(WebDAVMethod.class); - /** * Process a WebDAV request. The collection and resource parameters --- 38,41 ---- *************** *** 57,61 **** */ void process(User user, HttpServletRequest request, HttpServletResponse response, ! Collection collection, DocumentImpl resource) throws ServletException, IOException; } --- 52,56 ---- */ void process(User user, HttpServletRequest request, HttpServletResponse response, ! String path) throws ServletException, IOException; } Index: WebDAVMethodFactory.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/WebDAVMethodFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WebDAVMethodFactory.java 22 Jun 2004 10:10:18 -0000 1.3 --- WebDAVMethodFactory.java 6 Aug 2004 17:36:37 -0000 1.4 *************** *** 49,53 **** return new Get(pool); else if(method.equals("HEAD")) ! return new Head(); else if(method.equals("PUT")) return new Put(pool); --- 49,53 ---- return new Get(pool); else if(method.equals("HEAD")) ! return new Head(pool); else if(method.equals("PUT")) return new Put(pool); |