- // validate if the requiredFields are in the request
- for(String requiredField : modelRequiredFieldsList) {
- if (jsonRequestMap.containsKey(requiredField)) {
- String value = jsonRequestMap.get(requiredField);
- if(Strings.isNullOrEmpty(jsonRequestMap.get(requiredField)) ||
- "\"\"".equals(value) ||
- "".equals(jsonRequestMap.get(requiredField))){
+ // get list of required fields from the ref_Attributes of the Model
+ if (!Strings.isNullOrEmpty(refAttributes)) {
+ Map<String, String> refAttributesMap = null;
+ if (",".equals(refAttributes.substring(refAttributes.length()-1))) {
+ String attributesString = refAttributes.substring(0, refAttributes.length()-1);
+ refAttributesMap = Splitter.on(",").withKeyValueSeparator("=").split(attributesString);
+ } else {
+ refAttributesMap = Splitter.on(",").withKeyValueSeparator("=").split(modelAttributes);
+ }
+ String json = new ObjectMapper().writeValueAsString(refAttributesMap);
+ findRequiredFields(stringToJsonObject(json));
+ }
+
+ if (modelRequiredFieldsList!=null || !modelRequiredFieldsList.isEmpty()) {
+ // create jsonRequestMap with all json keys and values from request
+ JsonNode rootNode = (JsonNode) policyData.getPolicyJSON();
+ jsonRequestMap.clear();
+ pullModelJsonKeyPairs(rootNode);
+
+ // validate if the requiredFields are in the request
+ for(String requiredField : modelRequiredFieldsList) {
+ if (jsonRequestMap.containsKey(requiredField)) {
+ String value = jsonRequestMap.get(requiredField);
+ if(Strings.isNullOrEmpty(jsonRequestMap.get(requiredField)) ||
+ "\"\"".equals(value) ||
+ "".equals(jsonRequestMap.get(requiredField))){
+ responseString.append("<b>Micro Service Model</b>:<i> " + requiredField + " is required" + HTML_ITALICS_LNBREAK);
+ valid = false;
+ }
+ } else {