diff options
author | Krishnajinka <kris.jinka@samsung.com> | 2018-08-14 14:09:59 +0900 |
---|---|---|
committer | Krishnajinka <kris.jinka@samsung.com> | 2018-08-14 14:25:18 +0900 |
commit | 343df73f2b2dd2a39d090244c091371edbd2127f (patch) | |
tree | d137c2e083d22abf54272209632df622c20b450f /ONAP-XACML/src/main | |
parent | 5368a1d66dce2a1029e947a43e8ccdcfad98fbc8 (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-XACML/src/main')
-rw-r--r-- | ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java | 229 | ||||
-rw-r--r-- | ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java | 80 |
2 files changed, 92 insertions, 217 deletions
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java index 435e3c347..74ded6d43 100644 --- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java +++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java @@ -36,7 +36,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { private String policyDescription = null; private String onapName = null; private String configName = null; - private Map<String, String> dyanamicFieldConfigAttributes = new HashMap<>(); + private Map<String, String> dynamicFieldConfigAttributes = new HashMap<>(); private Map<String, String> treatments = new HashMap<>(); private Map<String, String> dropDownMap = new HashMap<>(); private Map<String, String> dynamicSettingsMap = new HashMap<>(); @@ -117,7 +117,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.onapName = stdPAPPolicyParams.getOnapName(); this.providerComboBox = stdPAPPolicyParams.getProviderComboBox(); this.configName = stdPAPPolicyParams.getConfigName(); - this.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getDyanamicFieldConfigAttributes(); + this.dynamicFieldConfigAttributes = stdPAPPolicyParams.getDynamicFieldConfigAttributes(); this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap(); this.configType = stdPAPPolicyParams.getConfigType(); this.configBodyData = stdPAPPolicyParams.getConfigBodyData(); @@ -138,113 +138,19 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.actionPerformer = stdPAPPolicyParams.getActionPerformer(); this.actionAttribute = stdPAPPolicyParams.getActionAttribute(); this.treatments = stdPAPPolicyParams.getTreatments(); - } - - //convenience constructor - public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName, - String configName, Map<String, String> attributes, String body, String policyID, - String ruleID, String configType, Boolean editPolicy, String version, String domain, - String riskLevel, String riskType, String guard, String ttlDate) { - this(configPolicyType, policyName, description, onapName, configName, attributes, body, policyID, - ruleID, configType, editPolicy, version, domain, 1, riskLevel, riskType, guard, ttlDate); - } - - //Constructor for Updating Config Policies from Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName, - String configName, Map<String, String> attributes, String body, String policyID, - String ruleID, String configType, Boolean editPolicy, String version, String domain, - int highestVersion, String riskLevel, String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.onapName = onapName; - this.configName = configName; - this.dyanamicFieldConfigAttributes = attributes; - this.configBodyData = body; - this.policyID = policyID; - this.ruleID = ruleID; - this.configType = configType; - this.editPolicy = editPolicy; - this.version = version; - this.domain = domain; - this.highestVersion = highestVersion; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - - //Constructor for Creating Config Firewall Policies - public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, - Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String riskLevel, - String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - - } - - //Constructor for Creating Goc Policies - public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, - Boolean editPolicy, String domain, String jsonBody, Integer highestVersion, String eCompName, - String riskLevel, String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - //Constructor for Creating BRMS Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, - String configBodyData, String riskLevel, String riskType, String guard, String ttlDate, - String brmsController, List<String> brmsDependency) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.configBodyData = configBodyData; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - this.brmsController = brmsController; - this.brmsDependency = brmsDependency; + this.policyID = stdPAPPolicyParams.getPolicyID(); + this.ruleID = stdPAPPolicyParams.getRuleID(); + this.version = stdPAPPolicyParams.getVersion(); + this.jsonBody = stdPAPPolicyParams.getJsonBody(); + this.brmsController = stdPAPPolicyParams.getBrmsController(); + this.brmsDependency = stdPAPPolicyParams.getBrmsDependency(); + this.drlRuleAndUIParams = stdPAPPolicyParams.getDrlRuleAndUIParams(); } //Constructor for Creating BRMS Param Policies from the Admin Console public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, Boolean editPolicy, String domain, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, + Map<String, String> dynamicFieldConfigAttributes, Integer highestVersion, String eCompName, String configBodyData, Map<String, String> drlRuleAndUIParams, String riskLevel, String riskType, String guard, String ttlDate, String brmsController, List<String> brmsDependency) { @@ -255,7 +161,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.configName = configName; this.editPolicy = editPolicy; this.domain = domain; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; + this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes; this.highestVersion = highestVersion; this.onapName = eCompName; this.configBodyData = configBodyData; @@ -292,29 +198,6 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.ttlDate = ttlDate; } - //Constructor for Updating Config Firewall Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, String configName, - Boolean editPolicy, String domain, String policyID, - String ruleID, String version, String jsonBody, Integer highestVersion, String riskLevel, - String riskType, String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - //Constructor for Micro Service Creating/Updating Policies from the Admin Console public StdPAPPolicy(String configPolicyType, String policyName, String description, String onapName, String configName, String serviceType, String uuid, @@ -342,84 +225,6 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.ttlDate = ttlDate; } - //Constructor for Updating Goc Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - String policyID, String ruleID, String version, - String jsonBody, Integer highestVersion, String eCompName, String riskLevel, String riskType, - String guard, String ttlDate) { - - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.jsonBody = jsonBody; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - //Constructor for Updating Brms Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - String policyID, String ruleID, String version, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, - String configBodyData, String riskLevel, String riskType, String guard, String ttlDate - ) { - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.configBodyData = configBodyData; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - - //Constructor for Updating Brms Param Policies from the Admin Console - public StdPAPPolicy(String configPolicyType, String policyName, String description, - String configName, Boolean editPolicy, String domain, - String policyID, String ruleID, String version, - Map<String, String> dyanamicFieldConfigAttributes, Integer highestVersion, String eCompName, - Map<String, String> drlRuleAndUIParams, String riskLevel, String riskType, String guard, - String ttlDate - ) { - this.configPolicyType = configPolicyType; - this.policyName = policyName; - this.policyDescription = description; - this.configName = configName; - this.editPolicy = editPolicy; - this.domain = domain; - this.policyID = policyID; - this.ruleID = ruleID; - this.version = version; - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; - this.highestVersion = highestVersion; - this.onapName = eCompName; - this.drlRuleAndUIParams = drlRuleAndUIParams; - this.riskLevel = riskLevel; - this.riskType = riskType; - this.guard = guard; - this.ttlDate = ttlDate; - } - // Constructor for deleting policies from the API public StdPAPPolicy(String policyName, String deleteCondition) { this.policyName = policyName; @@ -455,7 +260,7 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { @Override public Map<String, String> getDynamicFieldConfigAttributes() { - return dyanamicFieldConfigAttributes; + return dynamicFieldConfigAttributes; } @Override @@ -666,8 +471,8 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { @Override public String toString() { return "StdPAPPolicy [policyName=" + policyName + ", policyDescription=" + policyDescription + ", onapName=" - + onapName + ", configName=" + configName + ", dyanamicFieldConfigAttributes=" + - dyanamicFieldConfigAttributes + ", configBodyData=" + configBodyData + + onapName + ", configName=" + configName + ", dynamicFieldConfigAttributes=" + + dynamicFieldConfigAttributes + ", configBodyData=" + configBodyData + ", policyID=" + policyID + ", ruleID=" + ruleID + ", configType=" + configType + ", editPolicy=" + ", version=" + ", domain=" + domain + ", configPolicyType=" + configPolicyType + ", jsonBody=" + jsonBody + ", highestVersion=" + @@ -710,9 +515,9 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.configName = configName; } - public void setDyanamicFieldConfigAttributes( - Map<String, String> dyanamicFieldConfigAttributes) { - this.dyanamicFieldConfigAttributes = dyanamicFieldConfigAttributes; + public void setDynamicFieldConfigAttributes( + Map<String, String> dynamicFieldConfigAttributes) { + this.dynamicFieldConfigAttributes = dynamicFieldConfigAttributes; } public void setConfigBodyData(String configBodyData) { diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java index 0e183e08a..7eb422b99 100644 --- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java +++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java @@ -32,7 +32,7 @@ public class StdPAPPolicyParams { private String description; private String onapName; private String configName; - private Map<String, String> dyanamicFieldConfigAttributes; + private Map<String, String> dynamicFieldConfigAttributes; private String configType; private String configBodyData; private Boolean editPolicy; @@ -54,6 +54,13 @@ public class StdPAPPolicyParams { private List<String> dataTypeList; private Map<String, String> dropDownMap; private Map<String,String> treatments; + private String policyID; + private String ruleID; + private String version; + private String jsonBody; + private String brmsController; + private List<String> brmsDependency; + private Map<String,String> drlRuleAndUIParams; /** * Default constructor @@ -90,8 +97,8 @@ public class StdPAPPolicyParams { return configName; } - public Map<String, String> getDyanamicFieldConfigAttributes() { - return dyanamicFieldConfigAttributes; + public Map<String, String> getDynamicFieldConfigAttributes() { + return dynamicFieldConfigAttributes; } public String getConfigType() { @@ -174,6 +181,34 @@ public class StdPAPPolicyParams { return treatments; } + public String getPolicyID() { + return policyID; + } + + public String getRuleID() { + return ruleID; + } + + public String getVersion() { + return version; + } + + public String getJsonBody() { + return jsonBody; + } + + public String getBrmsController() { + return brmsController; + } + + public List<String> getBrmsDependency() { + return brmsDependency; + } + + public Map<String,String> getDrlRuleAndUIParams() { + return drlRuleAndUIParams; + } + /** * Builder class for the Policy parameters */ @@ -210,8 +245,8 @@ public class StdPAPPolicyParams { return this; } - public StdPAPPolicyParamsBuilder dyanamicFieldConfigAttributes(Map<String, String> attributes) { - m.dyanamicFieldConfigAttributes = attributes; + public StdPAPPolicyParamsBuilder dynamicFieldConfigAttributes(Map<String, String> attributes) { + m.dynamicFieldConfigAttributes = attributes; return this; } @@ -319,5 +354,40 @@ public class StdPAPPolicyParams { m.treatments = treatments; return this; } + + public StdPAPPolicyParamsBuilder policyID(String policyID) { + m.policyID = policyID; + return this; + } + + public StdPAPPolicyParamsBuilder ruleID(String ruleID) { + m.ruleID = ruleID; + return this; + } + + public StdPAPPolicyParamsBuilder version(String version) { + m.version = version; + return this; + } + + public StdPAPPolicyParamsBuilder jsonBody(String jsonBody) { + m.jsonBody = jsonBody; + return this; + } + + public StdPAPPolicyParamsBuilder brmsController(String controllerName) { + m.brmsController = controllerName; + return this; + } + + public StdPAPPolicyParamsBuilder brmsDependency(List<String> dependencyNames) { + m.brmsDependency = dependencyNames; + return this; + } + + public StdPAPPolicyParamsBuilder drlRuleAndUIParams(Map<String,String> drlRuleAndUIParams) { + m.drlRuleAndUIParams = drlRuleAndUIParams; + return this; + } } } |