Search in sources :

Example 1 with RemoteException

use of org.locationtech.geogig.api.porcelain.RemoteException 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();
        }
    });
}
Also used : RemoteRemoveOp(org.locationtech.geogig.api.porcelain.RemoteRemoveOp) 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)

Example 2 with RemoteException

use of org.locationtech.geogig.api.porcelain.RemoteException 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"));
    }
}
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)

Example 3 with RemoteException

use of org.locationtech.geogig.api.porcelain.RemoteException 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

IOException (java.io.IOException)3 Remote (org.locationtech.geogig.api.Remote)3 RemoteException (org.locationtech.geogig.api.porcelain.RemoteException)3 CommandResponse (org.locationtech.geogig.web.api.CommandResponse)3 CommandSpecException (org.locationtech.geogig.web.api.CommandSpecException)3 ResponseWriter (org.locationtech.geogig.web.api.ResponseWriter)3 RemoteRemoveOp (org.locationtech.geogig.api.porcelain.RemoteRemoveOp)1