Search in sources :

Example 6 with ResponseWriter

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();
        }
    });
}
Also used : Context(org.locationtech.geogig.api.Context) CommandContext(org.locationtech.geogig.web.api.CommandContext) AddOp(org.locationtech.geogig.api.porcelain.AddOp) ResponseWriter(org.locationtech.geogig.web.api.ResponseWriter) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException) CommandResponse(org.locationtech.geogig.web.api.CommandResponse) CommandSpecException(org.locationtech.geogig.web.api.CommandSpecException)

Example 7 with ResponseWriter

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();
        }
    });
}
Also used : Context(org.locationtech.geogig.api.Context) CommandContext(org.locationtech.geogig.web.api.CommandContext) VersionInfo(org.locationtech.geogig.api.porcelain.VersionInfo) ResponseWriter(org.locationtech.geogig.web.api.ResponseWriter) VersionOp(org.locationtech.geogig.api.porcelain.VersionOp) CommandResponse(org.locationtech.geogig.web.api.CommandResponse)

Example 8 with ResponseWriter

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();
        }
    });
}
Also used : Context(org.locationtech.geogig.api.Context) CommandContext(org.locationtech.geogig.web.api.CommandContext) RebuildGraphOp(org.locationtech.geogig.api.plumbing.RebuildGraphOp) ObjectId(org.locationtech.geogig.api.ObjectId) ResponseWriter(org.locationtech.geogig.web.api.ResponseWriter) CommandResponse(org.locationtech.geogig.web.api.CommandResponse)

Example 9 with ResponseWriter

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();
        }
    });
}
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 10 with ResponseWriter

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"));
    }
}
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