use of org.locationtech.geogig.web.api.WebAPICommand in project GeoGig by boundlessgeo.
the class CommandResource method runCommand.
private Representation runCommand(Variant variant, Request request) {
final Optional<GeoGIG> geogig = getGeogig(request);
Preconditions.checkState(geogig.isPresent());
Representation rep = null;
WebAPICommand command = null;
Form options = getRequest().getResourceRef().getQueryAsForm();
String commandName = (String) getRequest().getAttributes().get("command");
MediaType format = resolveFormat(options, variant);
try {
ParameterSet params = new FormParams(options);
command = CommandBuilder.build(commandName, params);
assert command != null;
} catch (CommandSpecException ex) {
rep = formatException(ex, format);
}
try {
if (command != null) {
RestletContext ctx = new RestletContext(geogig.get());
command.run(ctx);
rep = ctx.getRepresentation(format, getJSONPCallback());
}
} catch (IllegalArgumentException ex) {
rep = formatException(ex, format);
} catch (Exception ex) {
rep = formatUnexpectedException(ex, format);
}
return rep;
}
Aggregations