summaryrefslogtreecommitdiffstats
path: root/ONAP-PDP-REST
diff options
context:
space:
mode:
authorKrishnajinka <kris.jinka@samsung.com>2018-08-14 14:09:59 +0900
committerKrishnajinka <kris.jinka@samsung.com>2018-08-14 14:25:18 +0900
commit343df73f2b2dd2a39d090244c091371edbd2127f (patch)
treed137c2e083d22abf54272209632df622c20b450f /ONAP-PDP-REST
parent5368a1d66dce2a1029e947a43e8ccdcfad98fbc8 (diff)
Optimize PAP policy constructor with builder
Fix sonar issue about constructor using more than 7 params. Use builder parameters object for setting the attributes of std pap policy.Recommit1 Issue-ID: POLICY-1016 Change-Id: Id9631a42813960baa78df4ab0c0f6706244c3180 Signed-off-by: Krishnajinka <kris.jinka@samsung.com>
Diffstat (limited to 'ONAP-PDP-REST')
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ActionPolicyService.java3
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java25
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/ConfigPolicyService.java2
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/DecisionPolicyService.java3
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java20
5 files changed, 41 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 ab5b60cea..b60878f8b 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
@@ -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.
@@ -97,7 +98,7 @@ public class ActionPolicyService {
// Create Policy
StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder().policyName(policyName)
.description(policyParameters.getPolicyDescription())
- .dyanamicFieldConfigAttributes(componentAttributes)
+ .dynamicFieldConfigAttributes(componentAttributes)
.dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels())
.dynamicRuleAlgorithmCombo(policyParameters.getDynamicRuleAlgorithmFunctions())
.dynamicRuleAlgorithmField1(policyParameters.getDynamicRuleAlgorithmField1())
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java
index df3f0356f..71d49addc 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/BRMSRawPolicyService.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.
@@ -30,6 +31,7 @@ import org.onap.policy.pdp.rest.api.utils.PolicyApiUtils;
import org.onap.policy.utils.PolicyUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.std.pap.StdPAPPolicy;
+import org.onap.policy.xacml.std.pap.StdPAPPolicyParams;
/**
* BRMS RAW Policy Implementation.
@@ -93,11 +95,24 @@ public class BRMSRawPolicyService {
ruleAttributes = policyParameters.getAttributes().get(AttributeType.RULE);
}
// Create Policy
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw", policyName, policyParameters.getPolicyDescription(),
- "BRMS_RAW_RULE", updateFlag, policyScope, ruleAttributes, 0, "DROOLS",
- brmsRawBody, policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date,
- policyParameters.getControllerName(), policyParameters.getDependencyNames());
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("BRMS_Raw")
+ .policyName(policyName)
+ .description(policyParameters.getPolicyDescription())
+ .configName("BRMS_RAW_RULE")
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .dynamicFieldConfigAttributes(ruleAttributes)
+ .highestVersion(0)
+ .onapName("DROOLS")
+ .configBodyData(brmsRawBody)
+ .riskLevel(policyParameters.getRiskLevel())
+ .riskType(policyParameters.getRiskType())
+ .guard(String.valueOf(policyParameters.getGuard()))
+ .ttlDate(date)
+ .brmsController(policyParameters.getControllerName())
+ .brmsDependency(policyParameters.getDependencyNames())
+ .build());
// Send JSON to PAP
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
"policyType=Config"}, policyParameters.getRequestID(), "ConfigBrmsRaw");
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 e25e94cd0..779e3e35c 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
@@ -133,7 +133,7 @@ public class ConfigPolicyService {
.description(policyParameters.getPolicyDescription())
.onapName(onapName)
.configName(configName)
- .dyanamicFieldConfigAttributes(configAttributes)
+ .dynamicFieldConfigAttributes(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 00a3cc890..85e9c6ae5 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
@@ -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.
@@ -103,7 +104,7 @@ public class DecisionPolicyService {
.description(policyParameters.getPolicyDescription())
.onapName(onapName)
.providerComboBox(ruleProvider.toString())
- .dyanamicFieldConfigAttributes(matchingAttributes)
+ .dynamicFieldConfigAttributes(matchingAttributes)
.dynamicSettingsMap(settingsAttributes)
.treatments(policyParameters.getTreatments())
.dynamicRuleAlgorithmLabels(policyParameters.getDynamicRuleAlgorithmLabels())
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java
index 45deeb49f..c3a2ce64b 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/FirewallPolicyService.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.
@@ -29,6 +30,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pdp.rest.api.utils.PolicyApiUtils;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.std.pap.StdPAPPolicy;
+import org.onap.policy.xacml.std.pap.StdPAPPolicyParams;
/**
* Firewall Policy Implementation.
@@ -104,10 +106,20 @@ public class FirewallPolicyService {
String configDescription = "";
String json = firewallJson.toString();
// Create Policy.
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("Firewall Config", policyName, configDescription, configName,
- updateFlag, policyScope, json, 0,
- policyParameters.getRiskLevel(), policyParameters.getRiskType(),
- String.valueOf(policyParameters.getGuard()), date);
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy(StdPAPPolicyParams.builder()
+ .configPolicyType("Firewall Config")
+ .policyName(policyName)
+ .description(configDescription)
+ .configName(configName)
+ .editPolicy(updateFlag)
+ .domain(policyScope)
+ .jsonBody(json)
+ .highestVersion(0)
+ .riskLevel(policyParameters.getRiskLevel())
+ .riskType(policyParameters.getRiskType())
+ .guard(String.valueOf(policyParameters.getGuard()))
+ .ttlDate(date)
+ .build());
// Send Json to PAP.
response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
"policyType=Config"}, policyParameters.getRequestID(), "ConfigFirewall");