*/
@Override
public void execute() throws BulkProcessFailed {
- RestClient client = aaiClient.createClient(AAIUriFactory.createResourceUri(AAIObjectType.SINGLE_TRANSACTION));
try {
- SingleTransactionResponse response = client.post(this.request, SingleTransactionResponse.class);
- if (response != null) {
- final Optional<String> errorMessage = this.locateErrorMessages(response);
- if (errorMessage.isPresent()) {
- throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get());
+ if (!this.request.getOperations().isEmpty()) {
+ RestClient client = aaiClient.createClient(AAIUriFactory.createResourceUri(AAIObjectType.SINGLE_TRANSACTION));
+ SingleTransactionResponse response = client.post(this.request, SingleTransactionResponse.class);
+ if (response != null) {
+ final Optional<String> errorMessage = this.locateErrorMessages(response);
+ if (errorMessage.isPresent()) {
+ throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get());
+ }
+ } else {
+ throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result.");
}
- } else {
- throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result.");
}
} finally {
this.request.getOperations().clear();
*/
@Override
public void execute() throws BulkProcessFailed {
- RestClient client = aaiClient.createClient(AAIUriFactory.createResourceUri(AAIObjectType.BULK_PROCESS));
try {
- Response response = client.put(this.transactions);
- if (response.hasEntity()) {
- final Optional<String> errorMessage = this.locateErrorMessages(response.readEntity(String.class));
- if (errorMessage.isPresent()) {
- throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get());
+ if (!this.transactions.getTransactions().isEmpty()) {
+ RestClient client = aaiClient.createClient(AAIUriFactory.createResourceUri(AAIObjectType.BULK_PROCESS));
+ Response response = client.put(this.transactions);
+ if (response.hasEntity()) {
+ final Optional<String> errorMessage = this.locateErrorMessages(response.readEntity(String.class));
+ if (errorMessage.isPresent()) {
+ throw new BulkProcessFailed("One or more transactions failed in A&AI. Check logs for payloads.\nMessages:\n" + errorMessage.get());
+ }
+ } else {
+ throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result.");
}
- } else {
- throw new BulkProcessFailed("Transactions acccepted by A&AI, but there was no response. Unsure of result.");
}
} finally {
this.transactions.getTransactions().clear();
if(!this.exists(uri)){
if (obj.isPresent()) {
this.create(uri, obj.get());
- incrementActionAmount();
} else {
this.createEmpty(uri);
- incrementActionAmount();
}
}
protected abstract boolean exists(Uri uri);
protected abstract String getGraphDBName();
-
+
/**
* @param obj - can be any object which will marshal into a valid A&AI payload
* @param uri