From 84223fab05c1493df05db20016a83687bdaee975 Mon Sep 17 00:00:00 2001 From: Krishnajinka Date: Mon, 13 Aug 2018 15:44:55 +0900 Subject: Modify std pap policy to use builder in constr Fix sonar issue about constructor using more than 7 params. Use builder parameters object for setting the attributes of std pap policy.Rework2 Issue-ID: POLICY-1016 Change-Id: If26f7daa8d5b5d387238aad74daeddd49a8b95bb Signed-off-by: Krishnajinka --- .../pdp/rest/api/services/ActionPolicyService.java | 19 +++++++++++++----- .../pdp/rest/api/services/ConfigPolicyService.java | 3 ++- .../rest/api/services/DecisionPolicyService.java | 23 ++++++++++++++++------ 3 files changed, 33 insertions(+), 12 deletions(-) (limited to 'ONAP-PDP-REST') 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"); -- cgit 1.2.3-korg