} catch (PermissionDeniedException e) { throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, e);
	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);			if (resource.getResourceType().equals("XMLResource"))				document = ((LocalXMLResource) resource).getDocument(broker, true);			else				document = ((LocalBinaryResource) resource).getDocument(broker, true);			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.saveCollection(collection.getCollection());		} catch (EXistException e) {			throw new XMLDBException(				ErrorCodes.VENDOR_ERROR,				e.getMessage(),				e);		} catch (PermissionDeniedException e) {			throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, e);		} finally {		    collection.getCollection().releaseDocument(document);			pool.release(broker);		}	}