Search in sources :

Example 1 with ConflictsException

use of org.locationtech.geogig.api.porcelain.ConflictsException in project GeoGig by boundlessgeo.

the class GeogigTransactionState method commit.

@Override
public void commit() throws IOException {
    Preconditions.checkState(this.geogigTx != null);
    /*
         * This follows suite with the hack set on GeoSever's
         * org.geoserver.wfs.Transaction.getDatastoreTransaction()
         */
    final Optional<String> txUserName = getTransactionProperty(VERSIONING_COMMIT_AUTHOR);
    final Optional<String> fullName = getTransactionProperty("fullname");
    final Optional<String> email = getTransactionProperty("email");
    final String author = fullName.isPresent() ? fullName.get() : txUserName.orNull();
    String commitMessage = getTransactionProperty(VERSIONING_COMMIT_MESSAGE).orNull();
    this.geogigTx.command(AddOp.class).call();
    try {
        CommitOp commitOp = this.geogigTx.command(CommitOp.class);
        if (txUserName != null) {
            commitOp.setAuthor(author, email.orNull());
        }
        if (commitMessage == null) {
            commitMessage = composeDefaultCommitMessage();
        }
        commitOp.setMessage(commitMessage);
        commitOp.call();
    } catch (NothingToCommitException nochanges) {
    // ok
    }
    try {
        this.geogigTx.setAuthor(author, email.orNull()).commit();
    } catch (ConflictsException e) {
        // TODO: how should this be handled?
        this.geogigTx.abort();
    }
    this.geogigTx = null;
}
Also used : AddOp(org.locationtech.geogig.api.porcelain.AddOp) NothingToCommitException(org.locationtech.geogig.api.porcelain.NothingToCommitException) CommitOp(org.locationtech.geogig.api.porcelain.CommitOp) ConflictsException(org.locationtech.geogig.api.porcelain.ConflictsException)

Aggregations

AddOp (org.locationtech.geogig.api.porcelain.AddOp)1 CommitOp (org.locationtech.geogig.api.porcelain.CommitOp)1 ConflictsException (org.locationtech.geogig.api.porcelain.ConflictsException)1 NothingToCommitException (org.locationtech.geogig.api.porcelain.NothingToCommitException)1