aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java5
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java19
-rw-r--r--aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java5
3 files changed, 21 insertions, 8 deletions
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
index 82e179d..831b9cc 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
@@ -34,6 +34,11 @@ public class BulkAddConsumer extends BulkConsumer {
return method.equals(HttpMethod.PUT);
}
+
+ @Override
+ protected String getModule(){
+ return "bulk add";
+ }
@Override
protected boolean enableResourceVersion() {
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
index a973250..5591ae3 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
@@ -239,14 +239,15 @@ public abstract class BulkConsumer extends RESTAPI {
JsonParser parser = new JsonParser();
JsonObject input = parser.parse(content).getAsJsonObject();
-
+ String module = getModule();
+
if (!(input.has("transactions"))) {
- throw new AAIException("AAI_6118", "input payload does not follow bulk add interface - missing \"transactions\"");
+ throw new AAIException("AAI_6118", String.format("input payload does not follow %s interface - missing \"transactions\"", module));
}
JsonElement transactionsObj = input.get("transactions");
if (!(transactionsObj.isJsonArray())){
- throw new AAIException("AAI_6111", "input payload does not follow bulk add interface");
+ throw new AAIException("AAI_6111", String.format("input payload does not follow %s interface", module));
}
JsonArray transactions = transactionsObj.getAsJsonArray();
if (transactions.size() == 0) {
@@ -303,13 +304,13 @@ public abstract class BulkConsumer extends RESTAPI {
private void populateBulkOperations(List<BulkOperation> bulkOperations, JsonObject item, Loader loader, TransactionalGraphEngine dbEngine, String inputMediaType, HttpMethod method) throws AAIException, JsonSyntaxException, UnsupportedEncodingException{
-
+ String module = getModule();
for (int i=0; i<item.size(); i++) {
BulkOperation bulkOperation = new BulkOperation();
try {
if (!(item.isJsonObject())) {
- throw new AAIException("AAI_6111", "input payload does not follow bulk add interface");
+ throw new AAIException("AAI_6111", String.format("input payload does not follow %s interface", module));
}
JsonElement actionElement = null;
@@ -323,7 +324,7 @@ public abstract class BulkConsumer extends RESTAPI {
}
if ((actionElement == null) || !actionElement.isJsonArray()) {
- throw new AAIException("AAI_6111", "input payload does not follow bulk add interface");
+ throw new AAIException("AAI_6111", String.format("input payload does not follow %s interface", module));
}
JsonArray httpArray = actionElement.getAsJsonArray();
@@ -365,11 +366,11 @@ public abstract class BulkConsumer extends RESTAPI {
JsonElement bodyObj = new JsonObject();
if (!bulkOperation.getHttpMethod().equals(HttpMethod.DELETE)) {
if (!(it.has("body"))){
- throw new AAIException("AAI_6118", "input payload does not follow bulk interface - missing \"body\"");
+ throw new AAIException("AAI_6118", String.format("input payload does not follow %s interface - missing \"body\"", module));
}
bodyObj = it.get("body");
if (!(bodyObj.isJsonObject())) {
- throw new AAIException("AAI_6111", "input payload does not follow bulk interface");
+ throw new AAIException("AAI_6111", String.format("input payload does not follow %s interface", module));
}
}
@@ -529,6 +530,8 @@ public abstract class BulkConsumer extends RESTAPI {
tResps.add(uriResp);
}
}
+
+ protected abstract String getModule();
protected abstract boolean functionAllowed(HttpMethod method);
diff --git a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
index cd2cf82..bffeac3 100644
--- a/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
+++ b/aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java
@@ -35,6 +35,11 @@ public class BulkProcessConsumer extends BulkConsumer {
}
@Override
+ protected String getModule(){
+ return "bulk process";
+ }
+
+ @Override
protected boolean enableResourceVersion() {
// TODO Auto-generated method stub
return true;