if(source != null) source.release(); if(destination != null) destination.release();
    public void moveResource(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.moveResource(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 );        }    }