broker.removeCollection(destCollection.getName());
broker.removeCollection(destCollection);
    private void moveCollection(User user, HttpServletRequest request, HttpServletResponse response,             Collection collection, String destination) throws ServletException, IOException {        if(collection.getName().equals(destination)) {            response.sendError(HttpServletResponse.SC_FORBIDDEN,                    "Source and destination are the same");            return;        }        DBBroker broker = null;        try {            broker = pool.get(user);            boolean replaced = false;            Collection destCollection = broker.getCollection(destination);            if(destCollection != null) {                boolean overwrite = overwrite(request);                if(!overwrite) {                    response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED,                        "Destination collection exists");                    return;                }                broker.removeCollection(destCollection.getName());                replaced = true;            }            int p = destination.lastIndexOf('/');            if(p < 0) {                response.sendError(HttpServletResponse.SC_BAD_REQUEST,                        "Bad destination: " + destination);                return;            }            String parentPath = destination.substring(0, p);            String newCollectionName = destination.substring(p + 1);            LOG.debug("parent = " + parentPath + "; new name = " + newCollectionName);            Collection parent = broker.getCollection(parentPath);            if(parent == null) {                response.sendError(HttpServletResponse.SC_CONFLICT,                        "No parent collection: " + parentPath);                return;            }            broker.moveCollection(collection, parent, newCollectionName);            if(replaced)                response.setStatus(HttpServletResponse.SC_NO_CONTENT);            else                response.setStatus(HttpServletResponse.SC_CREATED);        } catch (EXistException e) {            throw new ServletException(e.getMessage(), e);        } catch (PermissionDeniedException e) {            response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());        } catch (LockException e) {            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());        } finally {            pool.release(broker);        }    }