aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-02-26 16:57:42 +0000
committerGerrit Code Review <gerrit@onap.org>2019-02-26 16:57:42 +0000
commit309c41420e8a14d9ac7eab4c28fd7ea6154b1fe1 (patch)
treec05eaabbd40f554950c0554c119fbff26945a336
parenta0f41b0c01515ee42ffec59b03aebfc68ede8e99 (diff)
parentf42fc1972f4b641aaf3248ce167c33a87277d8cf (diff)
Merge "do not attempt to commit empty transactions"
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAISingleTransactionClient.java18
-rw-r--r--common/src/main/java/org/onap/so/client/aai/AAITransactionalClient.java18
-rw-r--r--common/src/main/java/org/onap/so/client/graphinventory/GraphInventoryTransactionClient.java4
3 files changed, 21 insertions, 19 deletions
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<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();
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<AAIT
*/
@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();
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<Self, Uri extends GraphInv
if(!this.exists(uri)){
if (obj.isPresent()) {
this.create(uri, obj.get());
- incrementActionAmount();
} else {
this.createEmpty(uri);
- incrementActionAmount();
}
}
@@ -194,7 +192,7 @@ public abstract class GraphInventoryTransactionClient<Self, Uri extends GraphInv
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