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;
}
Aggregations