use of org.locationtech.geogig.api.porcelain.TransferSummary in project GeoGig by boundlessgeo.
the class Fetch method runInternal.
/**
* Executes the fetch command using the provided options.
*/
@Override
public void runInternal(GeogigCLI cli) throws IOException {
checkParameter(depth > 0 ? !fulldepth : true, "Cannot specify a depth and full depth. Use --depth <depth> or --fulldepth.");
if (depth > 0 || fulldepth) {
checkParameter(cli.getGeogig().getRepository().getDepth().isPresent(), "Depth operations can only be used on a shallow clone.");
}
TransferSummary result;
try {
FetchOp fetch = cli.getGeogig().command(FetchOp.class);
fetch.setProgressListener(cli.getProgressListener());
fetch.setAll(all).setPrune(prune).setFullDepth(fulldepth);
fetch.setDepth(depth);
if (args != null) {
for (String repo : args) {
fetch.addRemote(repo);
}
}
result = fetch.call();
} catch (SynchronizationException e) {
switch(e.statusCode) {
case HISTORY_TOO_SHALLOW:
default:
throw new CommandFailedException("Unable to fetch, the remote history is shallow.", e);
}
} catch (IllegalArgumentException iae) {
throw new CommandFailedException(iae.getMessage(), iae);
} catch (IllegalStateException ise) {
throw new CommandFailedException(ise.getMessage(), ise);
}
ConsoleReader console = cli.getConsole();
if (result.getChangedRefs().isEmpty()) {
console.println("Already up to date.");
} else {
FetchResultPrinter.print(result, console);
}
}
use of org.locationtech.geogig.api.porcelain.TransferSummary in project GeoGig by boundlessgeo.
the class PushWebOp 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);
PushOp command = geogig.command(PushOp.class);
if (refSpec != null) {
command.addRefSpec(refSpec);
}
try {
final TransferSummary dataPushed = command.setAll(pushAll).setRemote(remoteName).call();
context.setResponseContent(new CommandResponse() {
@Override
public void write(ResponseWriter out) throws Exception {
out.start();
out.writeElement("Push", "Success");
out.writeElement("dataPushed", String.valueOf(!dataPushed.isEmpty()));
out.finish();
}
});
} catch (SynchronizationException e) {
switch(e.statusCode) {
case REMOTE_HAS_CHANGES:
context.setResponseContent(CommandResponse.error("Push failed: The remote repository has changes that would be lost in the event of a push."));
break;
case HISTORY_TOO_SHALLOW:
context.setResponseContent(CommandResponse.error("Push failed: There is not enough local history to complete the push."));
default:
break;
}
}
}
Aggregations