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) {
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;
}
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();
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));
}
}
tResps.add(uriResp);
}
}
+
+ protected abstract String getModule();
protected abstract boolean functionAllowed(HttpMethod method);