DocumentImpl doc = (DocumentImpl) broker.getDocument(path);
doc = (DocumentImpl) broker.openDocument(path, Lock.WRITE_LOCK);
	public boolean lockResource(User user, String path, String userName) throws Exception {		DBBroker broker = null;		try {			broker = brokerPool.get(user);			DocumentImpl doc = (DocumentImpl) broker.getDocument(path);				if (doc == null)					throw new EXistException("Resource "							+ path + " not found");			if (!doc.getPermissions().validate(user, Permission.UPDATE))				throw new PermissionDeniedException("User is not allowed to lock resource " + path);			org.exist.security.SecurityManager manager = brokerPool.getSecurityManager();			if (!(userName.equals(user.getName()) || manager.hasAdminPrivileges(user)))				throw new PermissionDeniedException("User " + user.getName() + " is not allowed " +						"to lock the resource for user " + userName);			User lockOwner = doc.getUserLock();			if(lockOwner != null && (!lockOwner.equals(user)) && (!manager.hasAdminPrivileges(user)))				throw new PermissionDeniedException("Resource is already locked by user " +						lockOwner.getName());			doc.setUserLock(user);			broker.saveCollection(doc.getCollection());			return true;		} finally {			brokerPool.release(broker);		}	}