From: Wolfgang M. M. <wol...@us...> - 2004-08-03 16:46:27
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25039/src/org/exist/http/webdav/methods Modified Files: Copy.java Log Message: All the addDocument methods in org.exist.collections.Collection have been split into two method calls: validate + store. Background: while locking the collection is necessary during validation, this is not really required while the document is being stored. The caller can thus release the lock after validate has completed. Index: Copy.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Copy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Copy.java 3 Aug 2004 15:25:58 -0000 1.2 --- Copy.java 3 Aug 2004 16:45:45 -0000 1.3 *************** *** 39,42 **** --- 39,43 ---- import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.Lock; import org.exist.util.LockException; *************** *** 109,115 **** DBBroker broker = null; Collection destCollection = null; try { broker = pool.get(user); ! destCollection = broker.getCollection(destination); if(destCollection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, --- 110,117 ---- DBBroker broker = null; Collection destCollection = null; + Collection sourceCollection = null; try { broker = pool.get(user); ! destCollection = broker.openCollection(destination, Lock.WRITE_LOCK); if(destCollection == null) { response.sendError(HttpServletResponse.SC_CONFLICT, *************** *** 117,120 **** --- 119,128 ---- return; } + String sourcePath = resource.getName(); + int pos = sourcePath.lastIndexOf('/'); + String collName = sourcePath.substring(0, pos); + String docName = sourcePath.substring(pos + 1); + sourceCollection = broker.openCollection(collName, Lock.READ_LOCK); + DocumentImpl oldDoc = destCollection.getDocument(broker, newResourceName); if(oldDoc != null) { *************** *** 139,142 **** --- 147,152 ---- response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); } finally { + if(sourceCollection != null) + sourceCollection.release(); if(destCollection != null) destCollection.release(); |