* @throws CommandSpecException
*/
@Override
public void run(CommandContext context) {
if (this.getTransactionId() == null) {
throw new CommandSpecException(
"No transaction was specified, remove requires a transaction to preserve the stability of the repository.");
}
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.");
}
}
}