public synchronized BLOBDocument addBinaryResource(
public synchronized BinaryDocument addBinaryResource(
	public synchronized BLOBDocument addBinaryResource(		DBBroker broker,		String name,		byte[] data)		throws EXistException, PermissionDeniedException {		if (broker.isReadOnly())			throw new PermissionDeniedException("Database is read-only");		DocumentImpl oldDoc = null;		synchronized (this) {			oldDoc = getDocument(getName() + '/' + name);		}		if (oldDoc != null) {			// do we have permissions for update?			if (!oldDoc.getPermissions().validate(broker.getUser(), Permission.UPDATE))				throw new PermissionDeniedException(					"document exists and update " + "is not allowed");			// no: do we have write permissions?		} else if (!getPermissions().validate(broker.getUser(), Permission.WRITE))			throw new PermissionDeniedException(				"not allowed to write to collection " + getName());		BLOBDocument blob = new BLOBDocument(broker, getName() + '/' + name, this);		if (oldDoc != null) {			blob.setCreated(oldDoc.getCreated());			blob.setLastModified(System.currentTimeMillis());			blob.setPermissions(oldDoc.getPermissions());			LOG.debug("removing old document " + oldDoc.getFileName());			broker.removeDocument(oldDoc.getFileName());		} else {			blob.setCreated(System.currentTimeMillis());			blob.getPermissions().setOwner(broker.getUser());			blob.getPermissions().setGroup(broker.getUser().getPrimaryGroup());		}		broker.storeBinaryResource(blob, data);		synchronized (this) {			addDocument(broker, blob);			broker.addDocument(this, blob);		}		return blob;	}