collection.saveCollection();
broker.storeDocument(transaction, document); transact.commit(transaction);
	public void setPermissions(Resource resource, Permission perm)		throws XMLDBException {		org.exist.security.SecurityManager manager = pool.getSecurityManager();		DocumentImpl document = null;		DBBroker broker = null;		try {			broker = pool.get(user);			document = ((AbstractEXistResource) resource).openDocument(broker, Lock.WRITE_LOCK);			if (!(document.getPermissions().getOwner().equals(user.getName())				|| manager.hasAdminPrivileges(user)))				throw new XMLDBException(					ErrorCodes.PERMISSION_DENIED,					"you are not the owner of this resource; owner = "						+ document.getPermissions().getOwner());			document.setPermissions(perm);			collection.saveCollection();		} catch (EXistException e) {			throw new XMLDBException(				ErrorCodes.VENDOR_ERROR,				e.getMessage(),				e);		} finally {		    ((AbstractEXistResource)resource).closeDocument(document, Lock.WRITE_LOCK);			pool.release(broker);		}	}