if (!name.equals(ROOT_COLLECTION)) { Collection parent = collection.getParent(this); parent.update(collection); saveCollection(parent); }
	public void saveCollection(Collection collection) throws PermissionDeniedException {		if (readOnly)			throw new PermissionDeniedException(DATABASE_IS_READ_ONLY);		Lock lock = null;		try {			lock = collectionsDb.getLock();			lock.acquire(Lock.WRITE_LOCK);			if (collection.getId() < 0)				collection.setId(getNextCollectionId());			Value name;			try {				name = new Value(collection.getName().getBytes("UTF-8"));			} catch (UnsupportedEncodingException uee) {				LOG.debug(uee);				name = new Value(collection.getName().getBytes());			}			try {				final VariableByteOutputStream ostream = new VariableByteOutputStream(8);				collection.write(this, ostream);				final long addr = collectionsDb.put(name, ostream.data());				if (addr < 0) {					LOG.debug(						"could not store collection data for " + collection.getName());					return;				}				collection.setAddress(addr);				if (!name.equals(ROOT_COLLECTION)) {					Collection parent = collection.getParent(this);					parent.update(collection);					saveCollection(parent);				}				collectionsDb.getCollectionCache().add(collection);				ostream.close();			} catch (IOException ioe) {				LOG.debug(ioe);			}		} catch (ReadOnlyException e) {			LOG.warn(DATABASE_IS_READ_ONLY);		} catch (LockException e) {			LOG.warn("could not acquire lock for collections store", e);		} finally {			lock.release();		}	}