if (!name.equals(ROOT_COLLECTION)) { Collection parent = collection.getParent(this); parent.update(collection); saveCollection(parent); }
	public void addDocument(Collection collection, DocumentImpl doc)		throws PermissionDeniedException {		Lock lock = collectionsDb.getLock();		try {			lock.acquire();			Value name;			try {				name = new Value(collection.getName().getBytes("UTF-8"));			} catch (UnsupportedEncodingException uee) {				LOG.debug(uee);				name = new Value(collection.getName().getBytes());			}			storeDocument(doc);			VariableByteOutputStream ostream = new VariableByteOutputStream(6);			doc.write(ostream);			long address = collectionsDb.append(name, ostream.data());			if (address < 0) {				LOG.debug("could not store collection data for " + collection.getName());				return;			}			collection.setAddress(address);			if (!name.equals(ROOT_COLLECTION)) {				Collection parent = collection.getParent(this);				parent.update(collection);				saveCollection(parent);			}			ostream.close();		} catch (IOException ioe) {			LOG.debug(ioe);		} catch (ReadOnlyException e) {			LOG.warn(DATABASE_IS_READ_ONLY);		} catch (LockException e) {			LOG.warn("failed to acquire lock on collections.dbx");		} finally {			lock.release();		}	}