Policy TestSuite Enabled
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / openecomp / policy / controller / CreateDcaeMicroServiceController.java
index aeb5266..ce6531f 100644 (file)
@@ -92,6 +92,7 @@ import com.google.gson.Gson;
 
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
@@ -1020,52 +1021,45 @@ public class CreateDcaeMicroServiceController extends RestrictedBaseController {
                                                                // Under AllOFType we have Match
                                                                List<MatchType> matchList = allOf.getMatch();
                                                                if (matchList != null) {
-                                                                       int index = 0;
                                                                        Iterator<MatchType> iterMatch = matchList.iterator();
                                                                        while (matchList.size()>1 && iterMatch.hasNext()) {
                                                                                MatchType match = iterMatch.next();
                                                                                //
-                                                                               // Under the match we have attributevalue and
+                                                                               // Under the match we have attribute value and
                                                                                // attributeDesignator. So,finally down to the actual attribute.
                                                                                //
                                                                                AttributeValueType attributeValue = match.getAttributeValue();
                                                                                String value = (String) attributeValue.getContent().get(0);
-
+                                                                               AttributeDesignatorType designator = match.getAttributeDesignator();
+                                                                               String attributeId = designator.getAttributeId();
                                                                                // First match in the target is EcompName, so set that value.
-                                                                               if (index == 0) {
+                                                                               if (attributeId.equals("ECOMPName")) {
                                                                                        policyAdapter.setEcompName(value);
                                                                                }
-                                                                               if (index == 1){
+                                                                               if (attributeId.equals("ConfigName")){
                                                                                        policyAdapter.setConfigName(value);
                                                                                }
-                                                                               if (index == 2){
-                                                                                       if(value != null){
-                                                                                               readFile(policyAdapter, entity);
-                                                                                       }
-                                                                               }
-                                                                               if (index == 3){
+                                                                               if (attributeId.equals("uuid")){
                                                                                        policyAdapter.setUuid(value);
                                                                                }
-                                                                               if (index == 4){
+                                                                               if (attributeId.equals("location")){
                                                                                        policyAdapter.setLocation(value);
                                                                                }
-                                                                               if (index ==  5){
+                                                                               if (attributeId.equals("RiskType")){
                                                                                        policyAdapter.setRiskType(value);
                                                                                }
-
-                                                                               if (index ==  6){
+                                                                               if (attributeId.equals("RiskLevel")){
                                                                                        policyAdapter.setRiskLevel(value);
                                                                                }
-
-                                                                               if (index ==  7){
+                                                                               if (attributeId.equals("guard")){
                                                                                        policyAdapter.setGuard(value);
                                                                                }
-                                                                               if (index == 8 && !value.contains("NA")){
+                                                                               if (attributeId.equals("TTLDate") && !value.contains("NA")){
                                                                                        String newDate = convertDate(value, true);
                                                                                        policyAdapter.setTtlDate(newDate);
                                                                                }
-                                                                               index++;
                                                                        }
+                                                                       readFile(policyAdapter, entity);
                                                                }
                                                        }
                                                }