From: Benjamin, Max (mb388a) Date: Tue, 26 Feb 2019 14:51:06 +0000 (-0500) Subject: do not attempt to commit empty transactions X-Git-Tag: 1.4.1~245^2 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F90%2F79190%2F1;p=so.git do not attempt to commit empty transactions do not attempt to commit empty transactions Change-Id: I0db4f87449e7362dbbc2dc6ccfffca9f75c077eb Issue-ID: SO-1569 Signed-off-by: Benjamin, Max (mb388a) --- diff --git a/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java b/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java index ee15e10e01..fecbf59c36 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java @@ -60,16 +60,18 @@ public class AAISingleTransactionClient extends GraphInventoryTransactionClient< */ @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 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 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(); diff --git a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java index 474ae89ff9..9fb6cd7706 100644 --- a/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java +++ b/common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java @@ -82,16 +82,18 @@ public class AAITransactionalClient extends GraphInventoryTransactionClient 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 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(); diff --git a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java index 8d1a945c1b..4c228b2ea3 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java @@ -84,10 +84,8 @@ public abstract class GraphInventoryTransactionClient