DocumentImpl doc = (DocumentImpl)broker.getDocument(resourcePath);
int pos = resourcePath.lastIndexOf('/'); String collName = resourcePath.substring(0, pos); String docName = resourcePath.substring(pos + 1); source = broker.openCollection(collName, Lock.WRITE_LOCK); if(source == null) throw new XMLDBException(ErrorCodes.INVALID_COLLECTION, "Collection " + collName + " not found"); DocumentImpl doc = source.getDocument(broker, docName);
	public void copyResource(String resourcePath, String destinationPath,			String newName) throws XMLDBException {		if(!resourcePath.startsWith("/db"))            resourcePath = parent.getPath() + '/' + resourcePath;        if(!destinationPath.startsWith("/db"))            destinationPath = parent.getPath() + '/' + destinationPath;        DBBroker broker = null;        try {            broker = brokerPool.get(user);            DocumentImpl doc = (DocumentImpl)broker.getDocument(resourcePath);            if(doc == null)                throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, "Resource " + resourcePath + " not found");            org.exist.collections.Collection destination = broker.getCollection(destinationPath);            if(destination == null)                throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, "Collection " + destinationPath + " not found");            broker.copyResource(doc, destination, newName);        } catch ( EXistException e ) {        	e.printStackTrace();            throw new XMLDBException( ErrorCodes.VENDOR_ERROR,                "failed to move resource " + resourcePath, e );        } catch ( PermissionDeniedException e ) {            throw new XMLDBException( ErrorCodes.PERMISSION_DENIED,                e.getMessage(), e );        } catch (LockException e) {            throw new XMLDBException( ErrorCodes.PERMISSION_DENIED,                    e.getMessage(), e );        } finally {            brokerPool.release( broker );        }	}