Update error messages to say bulkprocess instead 85/25485/1
authorMaharajh, Robby (rx2202) <rx2202@us.att.com>
Mon, 4 Dec 2017 20:55:46 +0000 (15:55 -0500)
committerMaharajh, Robby (rx2202) <rx2202@us.att.com>
Mon, 4 Dec 2017 20:55:56 +0000 (15:55 -0500)
of bulkadd

Issue-ID: AAI-537
Change-Id: Ib9efa0b0a1da72506b5c247c610ba6826e3e3aeb
Signed-off-by: Maharajh, Robby (rx2202) <rx2202@us.att.com>
aai-resources/src/main/java/org/onap/aai/rest/BulkAddConsumer.java
aai-resources/src/main/java/org/onap/aai/rest/BulkConsumer.java
aai-resources/src/main/java/org/onap/aai/rest/BulkProcessConsumer.java

index 82e179d..831b9cc 100644 (file)
@@ -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() {
index a973250..5591ae3 100644 (file)
@@ -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);
        
index cd2cf82..bffeac3 100644 (file)
@@ -34,6 +34,11 @@ public class BulkProcessConsumer extends BulkConsumer {
                return method.equals(HttpMethod.PUT) || method.equals(HttpMethod.DELETE) || method.equals(HttpMethod.MERGE_PATCH);
        }
 
+       @Override
+       protected String getModule(){
+               return "bulk process";
+       }
+
        @Override
        protected boolean enableResourceVersion() {
                // TODO Auto-generated method stub