Merge "Resolved the Sonar issues"
[policy/engine.git] / ONAP-PDP-REST / src / main / java / org / onap / policy / pdp / rest / api / services / DecisionPolicyService.java
index 7bdf1dc..85e9c6a 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP-PDP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +30,7 @@ import org.onap.policy.common.logging.flexlogger.FlexLogger;
 import org.onap.policy.common.logging.flexlogger.Logger;
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 import org.onap.policy.xacml.std.pap.StdPAPPolicy;
+import org.onap.policy.xacml.std.pap.StdPAPPolicyParams;
 
 /**
  * Decision Policy Implementation
@@ -97,12 +99,22 @@ public class DecisionPolicyService {
             matchingAttributes = policyParameters.getAttributes().get(AttributeType.MATCHING);
         }
         // Create StdPAPPolicy object used to send policy data to PAP-REST.
-        StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyParameters.getPolicyDescription(), onapName,
-                ruleProvider.toString(), matchingAttributes, settingsAttributes,
-                policyParameters.getTreatments(), policyParameters.getDynamicRuleAlgorithmLabels(),
-                policyParameters.getDynamicRuleAlgorithmFunctions(),
-                policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmField2(),
-                null, null, null, updateFlag, policyScope, 0);
+        StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+                .policyName(policyName)
+                .description(policyParameters.getPolicyDescription())
+                .onapName(onapName)
+                .providerComboBox(ruleProvider.toString())
+                .dynamicFieldConfigAttributes(matchingAttributes)
+                .dynamicSettingsMap(settingsAttributes)
+                .treatments(policyParameters.getTreatments())
+                .dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels())
+                .dynamicRuleAlgorithmCombo(policyParameters.getDynamicRuleAlgorithmFunctions())
+                .dynamicRuleAlgorithmField1(policyParameters.getDynamicRuleAlgorithmField1())
+                .dynamicRuleAlgorithmField2(policyParameters.getDynamicRuleAlgorithmField2())
+                .editPolicy(updateFlag)
+                .domain(policyScope)
+                .highestVersion(0)
+                .build());
         // Send JSON to PAP.
         response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
                 "policyType=Decision"}, policyParameters.getRequestID(), "Decision");