use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class AddWebOp method run.
/**
* Runs the command and builds the appropriate response
*
* @param context - the context to use for this command
*
* @throws CommandSpecException
*/
@Override
public void run(CommandContext context) {
if (this.getTransactionId() == null) {
throw new CommandSpecException("No transaction was specified, add requires a transaction to preserve the stability of the repository.");
}
final Context geogig = this.getCommandLocator(context);
AddOp command = geogig.command(AddOp.class);
if (path != null) {
command.addPattern(path);
}
command.call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("Add", "Success");
out.finish();
}
});
}
use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class VersionWebOp method run.
/**
* Runs the command and builds the appropriate response.
*
* @param context - the context to use for this command
*/
@Override
public void run(CommandContext context) {
final Context geogig = this.getCommandLocator(context);
final VersionInfo info = geogig.command(VersionOp.class).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("ProjectVersion", info.getProjectVersion());
out.writeElement("BuildTime", info.getBuildTime());
out.writeElement("BuildUserName", info.getBuildUserName());
out.writeElement("BuildUserEmail", info.getBuildUserEmail());
out.writeElement("GitBranch", info.getBranch());
out.writeElement("GitCommitID", info.getCommitId());
out.writeElement("GitCommitTime", info.getCommitTime());
out.writeElement("GitCommitAuthorName", info.getCommitUserName());
out.writeElement("GitCommitAuthorEmail", info.getCommitUserEmail());
out.writeElement("GitCommitMessage", info.getCommitMessageFull());
out.finish();
}
});
}
use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class RebuildGraphWebOp method run.
/**
* Runs the command and builds the appropriate response.
*
* @param context - the context to use for this command
*/
@Override
public void run(CommandContext context) {
final Context geogig = this.getCommandLocator(context);
final ImmutableList<ObjectId> updatedObjects = geogig.command(RebuildGraphOp.class).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeRebuildGraphResponse(updatedObjects, quiet);
out.finish();
}
});
}
use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class RemoteWebOp method remoteRemove.
private void remoteRemove(CommandContext context, final Context geogig) {
if (remoteName == null || remoteName.trim().isEmpty()) {
throw new CommandSpecException("No remote was specified.");
}
final Remote remote;
try {
remote = geogig.command(RemoteRemoveOp.class).setName(remoteName).call();
} catch (RemoteException e) {
context.setResponseContent(CommandResponse.error(e.statusCode.toString()));
return;
} catch (Exception e) {
context.setResponseContent(CommandResponse.error("Aborting Remote Remove"));
return;
}
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("name", remote.getName());
out.finish();
}
});
}
use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.
the class RemoteWebOp method remoteUpdate.
private void remoteUpdate(CommandContext context, final Context geogig) {
if (remoteName == null || remoteName.trim().isEmpty()) {
throw new CommandSpecException("No remote was specified.");
} else if (remoteURL == null || remoteURL.trim().isEmpty()) {
throw new CommandSpecException("No URL was specified.");
}
final Remote newRemote;
try {
if (newName != null && !newName.trim().isEmpty() && !newName.equals(remoteName)) {
newRemote = geogig.command(RemoteAddOp.class).setName(newName).setURL(remoteURL).setUserName(username).setPassword(password).call();
geogig.command(RemoteRemoveOp.class).setName(remoteName).call();
} else {
geogig.command(RemoteRemoveOp.class).setName(remoteName).call();
newRemote = geogig.command(RemoteAddOp.class).setName(remoteName).setURL(remoteURL).setUserName(username).setPassword(password).call();
}
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("name", newRemote.getName());
out.finish();
}
});
} catch (RemoteException e) {
context.setResponseContent(CommandResponse.error(e.statusCode.toString()));
} catch (Exception e) {
context.setResponseContent(CommandResponse.error("Aborting Remote Update"));
}
}
Aggregations