Merge "Addressing Technical Debt for ONAP-XACML"
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / controller / CreateBRMSRawController.java
index 9851d31..3ab4f4f 100644 (file)
@@ -57,7 +57,7 @@ public class CreateBRMSRawController{
        
        @SuppressWarnings("unchecked")
        public void prePopulateBRMSRawPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
-               attributeList = new ArrayList<Object>();
+               attributeList = new ArrayList<>();
                if (policyAdapter.getPolicyData() instanceof PolicyType) {
                        PolicyType policy = (PolicyType) policyAdapter.getPolicyData();
                        policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
@@ -89,7 +89,7 @@ public class CreateBRMSRawController{
                                                attribute.put("value", value);
                                                attributeList.add(attribute);
                                        }else if(attributeAssignment.getAttributeId().startsWith("dependencies:")){
-                        ArrayList<String> dependencies = new ArrayList<String>(Arrays.asList(attributeAssignment.getAttributeId().replace("dependencies:", "").split(",")));
+                        ArrayList<String> dependencies = new ArrayList<>(Arrays.asList(attributeAssignment.getAttributeId().replace("dependencies:", "").split(",")));
                         if(dependencies.contains("")){
                             dependencies.remove("");
                         }
@@ -131,17 +131,18 @@ public class CreateBRMSRawController{
                                                                                AttributeDesignatorType designator = match.getAttributeDesignator();
                                                                                String attributeId = designator.getAttributeId();
                                                                                
-                                                                               if (attributeId.equals("RiskType")){
+                                                                               if ("RiskType".equals(attributeId)){
                                                                                        policyAdapter.setRiskType(value);
                                                                                }
-                                                                               if (attributeId.equals("RiskLevel")){
+                                                                               if ("RiskLevel".equals(attributeId)){
                                                                                        policyAdapter.setRiskLevel(value);
                                                                                }
-                                                                               if (attributeId.equals("guard")){
+                                                                               if ("guard".equals(attributeId)){
                                                                                        policyAdapter.setGuard(value);
                                                                                }
-                                                                               if (attributeId.equals("TTLDate") && !value.contains("NA")){
-                                                                                       String newDate = convertDate(value, true);
+                                                                               if ("TTLDate".equals(attributeId) && !value.contains("NA")){
+                                                                                       PolicyController controller = new PolicyController();
+                                                                                       String newDate = controller.convertDate(value);
                                                                                        policyAdapter.setTtlDate(newDate);
                                                                                }
                                                                        }
@@ -154,19 +155,4 @@ public class CreateBRMSRawController{
                } 
        }
 
-       private String convertDate(String dateTTL, boolean portalType) {
-               String formateDate = null;
-               String[] date;
-               String[] parts;
-               
-               if (portalType){
-                       parts = dateTTL.split("-");
-                       formateDate = parts[2] + "-" + parts[1] + "-" + parts[0] + "T05:00:00.000Z";
-               } else {
-                       date  = dateTTL.split("T");
-                       parts = date[0].split("-");
-                       formateDate = parts[2] + "-" + parts[1] + "-" + parts[0];
-               }
-               return formateDate;
-       }
 }