if (this.path == null) {
throw new CommandSpecException("No path was specified for removal.");
}
final Context geogig = this.getCommandLocator(context);
RemoveOp command = geogig.command(RemoveOp.class);
NodeRef.checkValidPath(path);
Optional<NodeRef> node = geogig.command(FindTreeChild.class)
.setParent(geogig.workingTree().getTree()).setIndex(true).setChildPath(path)
.call();
if (node.isPresent()) {
NodeRef nodeRef = node.get();
if (nodeRef.getType() == TYPE.TREE) {
if (!recursive) {
throw new CommandSpecException(
"Recursive option must be used to remove a tree.");
}
}
}
command.addPathToRemove(path).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("Deleted", path);