From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:44
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/collections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/collections Modified Files: Collection.java Log Message: Improved locking to handle concurrent XUpdates. Index: Collection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/collections/Collection.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Collection.java 25 May 2004 12:52:00 -0000 1.25 --- Collection.java 2 Jun 2004 11:34:35 -0000 1.26 *************** *** 175,178 **** --- 175,182 ---- } + public void unlinkDocument(DocumentImpl doc) { + documents.remove(doc.getFileName()); + } + /** * Return an iterator over all subcollections. *************** *** 542,546 **** } } ! /** * Remove the specified document from the collection. --- 546,550 ---- } } ! /** * Remove the specified document from the collection. *************** *** 663,666 **** --- 667,674 ---- throw new PermissionDeniedException( "Document exists and update is not allowed"); + if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) || + getPermissions().validate(broker.getUser(), Permission.WRITE))) + throw new PermissionDeniedException( + "Document exists and update is not allowed for the collection"); // do we have write permissions? } else if (!getPermissions().validate(broker.getUser(), *************** *** 758,763 **** document.setFileName(oldDoc.getFileName()); } addDocument(broker, document); - document.setWriteLock(true); indexer.setValidating(false); if (trigger != null) --- 766,771 ---- document.setFileName(oldDoc.getFileName()); } + document.getUpdateLock().acquire(Lock.WRITE_LOCK); addDocument(broker, document); indexer.setValidating(false); if (trigger != null) *************** *** 795,799 **** } } finally { ! document.setWriteLock(false); } broker.deleteObservers(); --- 803,807 ---- } } finally { ! document.getUpdateLock().release(Lock.WRITE_LOCK); } broker.deleteObservers(); *************** *** 835,838 **** --- 843,850 ---- throw new PermissionDeniedException( "Document exists and update is not allowed"); + if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) || + getPermissions().validate(broker.getUser(), Permission.WRITE))) + throw new PermissionDeniedException( + "Document exists and update is not allowed for the collection"); // do we have write permissions? } else if (!getPermissions().validate(broker.getUser(), *************** *** 930,934 **** document.setFileName(oldDoc.getFileName()); } ! document.setWriteLock(true); addDocument(broker, document); --- 942,946 ---- document.setFileName(oldDoc.getFileName()); } ! document.getUpdateLock().acquire(Lock.WRITE_LOCK); addDocument(broker, document); *************** *** 980,984 **** } } finally { ! document.setWriteLock(false); } broker.deleteObservers(); --- 992,996 ---- } } finally { ! document.getUpdateLock().release(Lock.WRITE_LOCK); } broker.deleteObservers(); *************** *** 1018,1021 **** --- 1030,1037 ---- throw new PermissionDeniedException( "document exists and update " + "is not allowed"); + if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) || + getPermissions().validate(broker.getUser(), Permission.WRITE))) + throw new PermissionDeniedException( + "Document exists and update is not allowed for the collection"); // no: do we have write permissions? } else if (!getPermissions().validate(broker.getUser(), *************** *** 1098,1102 **** document.setFileName(oldDoc.getFileName()); } ! document.setWriteLock(true); addDocument(broker, document); --- 1114,1118 ---- document.setFileName(oldDoc.getFileName()); } ! document.getUpdateLock().acquire(Lock.WRITE_LOCK); addDocument(broker, document); *************** *** 1129,1133 **** } } finally { ! document.setWriteLock(false); } broker.deleteObservers(); --- 1145,1149 ---- } } finally { ! document.getUpdateLock().release(Lock.WRITE_LOCK); } broker.deleteObservers(); *************** *** 1189,1194 **** return blob; } finally { - if(blob != null) - blob.setWriteLock(false); lock.release(); } --- 1205,1208 ---- *************** *** 1278,1282 **** path = path.substring(path.lastIndexOf('/') + 1); childDoc.setFileName(getName() + '/' + path); - LOG.debug("Moved " + childDoc.getFileName()); newMap.put(childDoc.getFileName(), childDoc); } --- 1292,1295 ---- |