if(doc.isLockedForWrite()) throw new PermissionDeniedException("Document " + doc.getFileName() + " is locked for write");
	public void removeDocument(DBBroker broker, String docname)			throws PermissionDeniedException, TriggerException, LockException {		Lock lock = db.getLock();		try {			lock.acquire(Lock.READ_LOCK);			Trigger trigger = null;			if (!docname.equals(COLLECTION_CONFIG_FILE)) {				if (triggersEnabled) {					CollectionConfiguration config = getConfiguration(broker);					if (config != null)						trigger = config								.getTrigger(Trigger.REMOVE_DOCUMENT_EVENT);				}			} else				configuration = null;			String path = getName() + '/' + docname;			DocumentImpl doc = getDocument(path);			if (doc == null)				return;			if (!getPermissions().validate(broker.getUser(), Permission.WRITE))				throw new PermissionDeniedException(						"Write access to collection denied; user=" + broker.getUser().getName());			if (!doc.getPermissions().validate(broker.getUser(), Permission.WRITE))				throw new PermissionDeniedException("Permission to remove document denied");			if (trigger != null && triggersEnabled) {				trigger.prepare(Trigger.REMOVE_DOCUMENT_EVENT, broker, docname,						doc);			}			broker.removeDocument(path);			documents.remove(path);			broker.saveCollection(this);		} finally {			lock.release();		}	}