if (!manager.hasGroup(perm.getOwnerGroup())) manager.addGroup(perm.getOwnerGroup());
	public void setPermissions(Resource resource, Permission perm)		throws XMLDBException {		org.exist.security.SecurityManager manager = pool.getSecurityManager();		DocumentImpl document = null;		DBBroker broker = null;        TransactionManager transact = pool.getTransactionManager();        Txn transaction = transact.beginTransaction();		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);            broker.storeXMLResource(transaction, document);            transact.commit(transaction);		} catch (EXistException e) {            transact.abort(transaction);			throw new XMLDBException(				ErrorCodes.VENDOR_ERROR,				e.getMessage(),				e);		} finally {		    ((AbstractEXistResource)resource).closeDocument(document, Lock.WRITE_LOCK);			pool.release(broker);		}	}