From: Wolfgang M. M. <wol...@us...> - 2004-08-06 15:24:57
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16444/src/org/exist/storage Modified Files: NativeBroker.java Log Message: Applied removeCollection patch. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** NativeBroker.java 4 Aug 2004 19:30:10 -0000 1.96 --- NativeBroker.java 6 Aug 2004 15:24:48 -0000 1.97 *************** *** 77,81 **** import org.exist.util.ByteArrayPool; import org.exist.util.ByteConversion; - import org.exist.util.CollectionScanner; import org.exist.util.Configuration; import org.exist.util.Lock; --- 77,80 ---- *************** *** 545,549 **** } ! public Document openDocument(String docPath, int lockMode) throws PermissionDeniedException { if (!docPath.startsWith("/")) docPath = '/' + docPath; --- 544,548 ---- } ! public DocumentImpl openDocument(String docPath, int lockMode) throws PermissionDeniedException { if (!docPath.startsWith("/")) docPath = '/' + docPath; *************** *** 1752,1769 **** throw new PermissionDeniedException("not allowed to remove collection"); final CollectionCache collectionsCache = pool.getCollectionsCache(); synchronized(collectionsCache) { String name = collection.getName(); ! // remove from parent collection ! Collection parent = openCollection(collection.getParentPath(), Lock.WRITE_LOCK); ! if (parent != null) { ! try { ! parent.removeCollection(name.substring(name.lastIndexOf("/") + 1)); ! saveCollection(parent); ! } catch (LockException e) { ! LOG.warn("LockException while removing collection " + name); ! } finally { ! parent.getLock().release(); ! } } --- 1751,1773 ---- throw new PermissionDeniedException("not allowed to remove collection"); + final boolean isRoot = collection.getParentPath() == null; + final CollectionCache collectionsCache = pool.getCollectionsCache(); synchronized(collectionsCache) { String name = collection.getName(); ! ! if (!isRoot) { ! // remove from parent collection ! Collection parent = openCollection(collection.getParentPath(), Lock.WRITE_LOCK); ! if (parent != null) { ! try { ! parent.removeCollection(name.substring(name.lastIndexOf("/") + 1)); ! saveCollection(parent); ! } catch (LockException e) { ! LOG.warn("LockException while removing collection " + name); ! } finally { ! parent.getLock().release(); ! } ! } } *************** *** 1787,1791 **** // if this is not the root collection remove it completely ! if (name.equals(ROOT_COLLECTION)) saveCollection(collection); else { --- 1791,1795 ---- // if this is not the root collection remove it completely ! if (isRoot) saveCollection(collection); else { *************** *** 1797,1803 **** } collectionsDb.remove(key); - } - if (!name.equals(ROOT_COLLECTION)) collectionsCache.remove(collection); } catch (LockException e) { LOG.warn("Failed to acquire lock on collections.dbx"); --- 1801,1808 ---- } collectionsDb.remove(key); collectionsCache.remove(collection); + freeCollection(collection.getId()); + } + } catch (LockException e) { LOG.warn("Failed to acquire lock on collections.dbx"); *************** *** 1808,1813 **** } - freeCollection(collection.getId()); - textEngine.dropIndex(collection); elementIndex.dropIndex(collection); --- 1813,1816 ---- |