summaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-08-13 17:20:21 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-13 17:20:21 +0000
commit5368a1d66dce2a1029e947a43e8ccdcfad98fbc8 (patch)
tree6b9824f65696a21cbbe9bfdf9b02e5064c36f665 /ONAP-PDP-REST
parenta54ec0fce0cb5032d373e811d830cdd027b0dd9c (diff)
parent84223fab05c1493df05db20016a83687bdaee975 (diff)
Merge "Modify std pap policy to use builder in constr"
Diffstat (limited to 'ONAP-PDP-REST')
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java19
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java3
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java23
3 files changed, 33 insertions, 12 deletions
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java
index 5016e0690..ab5b60cea 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java
@@ -28,6 +28,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;
/**
* Action Policy Implementation.
@@ -94,11 +95,19 @@ public class ActionPolicyService {
operation = "create";
}
// Create Policy
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy(policyName, policyParameters.getPolicyDescription(),
- componentAttributes, policyParameters.getDynamicRuleAlgorithmLabels(),
- policyParameters.getDynamicRuleAlgorithmFunctions(),
- policyParameters.getDynamicRuleAlgorithmField1(), policyParameters.getDynamicRuleAlgorithmField2(),
- actionPerformer, actionAttribute, updateFlag, policyScope, 0);
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder().policyName(policyName)
+ .description(policyParameters.getPolicyDescription())
+ .dyanamicFieldConfigAttributes(componentAttributes)
+ .dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels())
+ .dynamicRuleAlgorithmCombo(policyParameters.getDynamicRuleAlgorithmFunctions())
+ .dynamicRuleAlgorithmField1(policyParameters.getDynamicRuleAlgorithmField1())
+ .dynamicRuleAlgorithmField2(policyParameters.getDynamicRuleAlgorithmField2())
+ .actionPerformer(actionPerformer)
+ .actionAttribute(actionAttribute)
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .highestVersion(0)
+ .build());
// send Json to PAP
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
"policyType=Action"}, policyParameters.getRequestID(), "Action");
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java
index 46f968aac..e25e94cd0 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java
@@ -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.
@@ -132,7 +133,7 @@ public class ConfigPolicyService {
.description(policyParameters.getPolicyDescription())
.onapName(onapName)
.configName(configName)
- .attributes(configAttributes)
+ .dyanamicFieldConfigAttributes(configAttributes)
.configType(configType)
.configBodyData(configBody)
.editPolicy(updateFlag)
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java
index 7bdf1dc71..00a3cc890 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java
@@ -29,6 +29,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 +98,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())
+ .dyanamicFieldConfigAttributes(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");