+ if(!"API".equals(policyData.getApiflag()) && policyData.getAttributes() != null && !policyData.getAttributes().isEmpty()){
+ for(Object attribute : policyData.getAttributes()){
+ if(attribute instanceof LinkedHashMap<?, ?>){
+ String value = null;
+ String key = null;
+ if(((LinkedHashMap<?, ?>) attribute).get("key") != null){
+ key = ((LinkedHashMap<?, ?>) attribute).get("key").toString();
+ if(!PolicyUtils.policySpecialCharValidator(key).contains("success")){
+ responseString.append("<b>Attributes or Component Attributes</b>:<i>" + value + " : value has spaces or invalid characters</i><br>");
+ valid = false;
+ }
+ }else{
+ if(CONFIG_POLICY.equals(policyData.getPolicyType())){
+ if("Base".equals(policyData.getConfigPolicyType())){
+ responseString.append("<b>Attributes</b>:<i> has one missing Attribute key</i><br>");
+ }
+ if("BRMS_Param".equals(policyData.getConfigPolicyType()) || "BRMS_Raw".equals(policyData.getConfigPolicyType())){
+ responseString.append("<b>Rule Attributes</b>:<i> has one missing Attribute key</i><br>");
+ }
+ }else{
+ responseString.append("<b>Component Attributes</b>:<i> has one missing Component Attribute key</i><br>");
+ }
+ valid = false;
+ }
+ if(((LinkedHashMap<?, ?>) attribute).get("value") != null){
+ value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
+ if(!PolicyUtils.policySpecialCharValidator(value).contains("success")){
+ if(CONFIG_POLICY.equals(policyData.getPolicyType())){
+ if("Base".equals(policyData.getConfigPolicyType())){
+ responseString.append("<b>Attributes</b>:<i>" + value + " : value has spaces or invalid characters</i><br>");
+ }
+ if("BRMS_Param".equals(policyData.getConfigPolicyType()) || "BRMS_Raw".equals(policyData.getConfigPolicyType())){
+ responseString.append("<b>Rule Attributes</b>:<i>" + value + " : value has spaces or invalid characters</i><br>");
+ }
+ }else{
+ responseString.append("<b>Component Attributes</b>:<i>" + value + " : value has spaces or invalid characters</i><br>");
+ }
+ valid = false;
+ }
+ }else{
+ if(CONFIG_POLICY.equals(policyData.getPolicyType())){
+ if("Base".equals(policyData.getConfigPolicyType())){
+ responseString.append("<b>Attributes</b>:<i> has one missing Attribute value</i><br>");
+ }
+ if("BRMS_Param".equals(policyData.getConfigPolicyType()) || "BRMS_Raw".equals(policyData.getConfigPolicyType())){
+ responseString.append("<b>Rule Attributes</b>:<i> has one missing Attribute value</i><br>");
+ }
+ }else{
+ responseString.append("<b>Component Attributes</b>:<i> has one missing Component Attribute value</i><br>");
+ }
+ valid = false;
+ }
+ }
+ }
+ }
+
+ //Decision Policy Attributes Validation
+ if(!"API".equals(policyData.getApiflag()) && policyData.getSettings() != null && !policyData.getSettings().isEmpty()){
+ for(Object attribute : policyData.getAttributes()){
+ if(attribute instanceof LinkedHashMap<?, ?>){
+ String value = null;
+ if(((LinkedHashMap<?, ?>) attribute).get("key") == null){
+ responseString.append("<b>Settings Attributes</b>:<i> has one missing Attribute key</i><br>");
+ valid = false;
+ }
+ if(((LinkedHashMap<?, ?>) attribute).get("value") != null){
+ value = ((LinkedHashMap<?, ?>) attribute).get("value").toString();
+ if(!PolicyUtils.policySpecialCharValidator(value).contains("success")){
+ responseString.append("<b>Settings Attributes</b>:<i>" + value + " : value has spaces or invalid characters</i><br>");
+ valid = false;
+ }
+ }else{
+ responseString.append("<b>Settings Attributes</b>:<i> has one missing Attribute Value</i><br>");
+ valid = false;
+ }
+ }
+ }
+ }
+
+ if(!"API".equals(policyData.getApiflag()) && policyData.getRuleAlgorithmschoices() != null && !policyData.getRuleAlgorithmschoices().isEmpty()){
+ for(Object attribute : policyData.getRuleAlgorithmschoices()){
+ if(attribute instanceof LinkedHashMap<?, ?>){
+ String label = ((LinkedHashMap<?, ?>) attribute).get("id").toString();
+ if(((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField1") == null){
+ responseString.append("<b>Rule Algorithms</b>:<i>" + label + " : Field 1 value is not selected</i><br>");
+ valid = false;
+ }
+ if(((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmCombo") == null){
+ responseString.append("<b>Rule Algorithms</b>:<i>" + label + " : Field 2 value is not selected</i><br>");
+ valid = false;
+ }
+ if(((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2") != null){
+ String value = ((LinkedHashMap<?, ?>) attribute).get("dynamicRuleAlgorithmField2").toString();
+ if(!PolicyUtils.policySpecialCharValidator(value).contains("success")){
+ responseString.append("<b>Rule Algorithms</b>:<i>" + label + " : Field 3 value has special characters</i><br>");
+ valid = false;
+ }
+ }else{
+ responseString.append("<b>Rule Algorithms</b>:<i>" + label + " : Field 3 value is empty</i><br>");
+ valid = false;
+ }
+ }
+ }
+ }
+