Search in sources :

Example 31 with ResponseWriter

use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.

the class RemoteWebOp method remoteList.

private void remoteList(CommandContext context, final Context geogig) {
    final List<Remote> remotes = geogig.command(RemoteListOp.class).call();
    context.setResponseContent(new CommandResponse() {

        @Override
        public void write(ResponseWriter out) throws Exception {
            out.start();
            out.writeRemoteListResponse(remotes, verbose);
            out.finish();
        }
    });
}
Also used : ResponseWriter(org.locationtech.geogig.web.api.ResponseWriter) Remote(org.locationtech.geogig.api.Remote) RemoteListOp(org.locationtech.geogig.api.porcelain.RemoteListOp) CommandResponse(org.locationtech.geogig.web.api.CommandResponse) IOException(java.io.IOException) RemoteException(org.locationtech.geogig.api.porcelain.RemoteException) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException)

Example 32 with ResponseWriter

use of org.locationtech.geogig.web.api.ResponseWriter in project GeoGig by boundlessgeo.

the class RemoteWebOp method remoteAdd.

private void remoteAdd(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 remote;
    try {
        remote = 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", remote.getName());
                out.finish();
            }
        });
    } catch (RemoteException e) {
        context.setResponseContent(CommandResponse.error(e.statusCode.toString()));
    } catch (Exception e) {
        context.setResponseContent(CommandResponse.error("Aborting Remote Add"));
    }
}
Also used : ResponseWriter(org.locationtech.geogig.web.api.ResponseWriter) Remote(org.locationtech.geogig.api.Remote) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException) CommandResponse(org.locationtech.geogig.web.api.CommandResponse) RemoteException(org.locationtech.geogig.api.porcelain.RemoteException) IOException(java.io.IOException) RemoteException(org.locationtech.geogig.api.porcelain.RemoteException) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException)

Aggregations

CommandResponse (org.locationtech.geogig.web.api.CommandResponse)32 ResponseWriter (org.locationtech.geogig.web.api.ResponseWriter)32 Context (org.locationtech.geogig.api.Context)24 CommandContext (org.locationtech.geogig.web.api.CommandContext)24 CommandSpecException (org.locationtech.geogig.web.api.CommandSpecException)23 ObjectId (org.locationtech.geogig.api.ObjectId)11 RevCommit (org.locationtech.geogig.api.RevCommit)9 Ref (org.locationtech.geogig.api.Ref)8 NodeRef (org.locationtech.geogig.api.NodeRef)6 Optional (com.google.common.base.Optional)5 IOException (java.io.IOException)5 Remote (org.locationtech.geogig.api.Remote)5 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)5 RemoteException (org.locationtech.geogig.api.porcelain.RemoteException)5 SymRef (org.locationtech.geogig.api.SymRef)4 MergeScenarioReport (org.locationtech.geogig.api.plumbing.merge.MergeScenarioReport)4 GeogigTransaction (org.locationtech.geogig.api.GeogigTransaction)3 RevFeature (org.locationtech.geogig.api.RevFeature)3 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)3 RevTree (org.locationtech.geogig.api.RevTree)3