LOG.debug("Found old doc " + oldDoc.getDocId() + "; identity = " + oldDoc.hashCode());
	private void checkPermissions(DBBroker broker, String name, DocumentImpl oldDoc) throws LockException, PermissionDeniedException {		if (oldDoc != null) {			LOG.debug("Found old doc " + oldDoc.getDocId() + "; identity = " + oldDoc.hashCode());			// check if the document is locked by another user			User lockUser = oldDoc.getUserLock();			if(lockUser != null && !lockUser.equals(broker.getUser()))				throw new PermissionDeniedException("The document is locked by user " +						lockUser.getName());						// check if the document is currently being changed by someone else			oldDoc.getUpdateLock().acquire(Lock.WRITE_LOCK);						// do we have permissions for update?			if (!oldDoc.getPermissions().validate(broker.getUser(),					Permission.UPDATE))				throw new PermissionDeniedException(						"Document exists and update is not allowed");			if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) ||			        getPermissions().validate(broker.getUser(), Permission.WRITE)))				throw new PermissionDeniedException(						"Document exists and update is not allowed for the collection");			// do we have write permissions?		} else if (!getPermissions().validate(broker.getUser(),				Permission.WRITE))			throw new PermissionDeniedException(					"Not allowed to write to collection " + getName());	}