diff options
author | Krishnajinka <kris.jinka@samsung.com> | 2018-08-13 15:44:55 +0900 |
---|---|---|
committer | Krishnajinka <kris.jinka@samsung.com> | 2018-08-13 21:30:22 +0900 |
commit | 84223fab05c1493df05db20016a83687bdaee975 (patch) | |
tree | d2963885a5bc5a0589b3c84f51be16114963b243 /ONAP-XACML/src/main/java | |
parent | 6ed1731fa2ce340d745dc2d39ffc6a066f50fbc2 (diff) |
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 <kris.jinka@samsung.com>
Diffstat (limited to 'ONAP-XACML/src/main/java')
-rw-r--r-- | ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicy.java | 75 | ||||
-rw-r--r-- | ONAP-XACML/src/main/java/org/onap/policy/xacml/std/pap/StdPAPPolicyParams.java | 142 |
2 files changed, 158 insertions, 59 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 264b2b784..435e3c347 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 @@ -3,6 +3,7 @@ * ONAP-XACML * ================================================================================ * Copyright (C) 2017-2018 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. @@ -101,16 +102,23 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.configPolicyType = configPolicyType; } - //Constructor for Create Config Policies from API and Admin Console - //Constructor for Updating Config Policies from the API - //convenience constructor + /** + * Constructor for + * Create Config Policies from API and Admin Console + * Updating Config Policies from the API + * Create/Update Action Policies from API + * Create/Update Decision Policies + * @param stdPAPPolicyParams Input params object + */ public StdPAPPolicy(StdPAPPolicyParams stdPAPPolicyParams) { this.configPolicyType=stdPAPPolicyParams.getConfigPolicyType(); this.policyName = stdPAPPolicyParams.getPolicyName(); this.policyDescription = stdPAPPolicyParams.getDescription(); this.onapName = stdPAPPolicyParams.getOnapName(); + this.providerComboBox = stdPAPPolicyParams.getProviderComboBox(); this.configName = stdPAPPolicyParams.getConfigName(); - this.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getAttributes(); + this.dyanamicFieldConfigAttributes = stdPAPPolicyParams.getDyanamicFieldConfigAttributes(); + this.dynamicSettingsMap = stdPAPPolicyParams.getDynamicSettingsMap(); this.configType = stdPAPPolicyParams.getConfigType(); this.configBodyData = stdPAPPolicyParams.getConfigBodyData(); this.editPolicy = stdPAPPolicyParams.getEditPolicy(); @@ -120,55 +128,16 @@ public class StdPAPPolicy implements OnapPAPPolicy, Serializable { this.riskType = stdPAPPolicyParams.getRiskType(); this.guard = stdPAPPolicyParams.getGuard(); this.ttlDate = stdPAPPolicyParams.getTtlDate(); - } - - //Constructor for Create/Update Action Policies from API - public StdPAPPolicy(String policyName, String description, Map<String, String> attributes, - List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmCombo, - List<String> dynamicRuleAlgorithmField1, List<String> dynamicRuleAlgorithmField2, - String actionPerformer, String actionAttribute, Boolean editPolicy, - String domain, int highestVersion) { - - this.policyName = policyName; - this.policyDescription = description; - this.dyanamicFieldConfigAttributes = attributes; - this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; - this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo; - this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; - this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; - this.actionPerformer = actionPerformer; - this.actionAttribute = actionAttribute; - this.editPolicy = editPolicy; - this.domain = domain; - this.highestVersion = highestVersion; - - } - - //Constructor for Create/Update Decision Policies - public StdPAPPolicy(String policyName, String description, String onapName, String providerComboBox, - Map<String, String> attributes, Map<String, String> settings, Map<String, String> treatments, - List<String> dynamicRuleAlgorithmLabels, List<String> dynamicRuleAlgorithmCombo, - List<String> dynamicRuleAlgorithmField1, - List<String> dynamicRuleAlgorithmField2, Map<String, String> dropDownMap, - List<Object> dynamicVariableList, - List<String> dataTypeList, Boolean editPolicy, String domain, int highestVersion) { - this.policyName = policyName; - this.policyDescription = description; - this.onapName = onapName; - this.setProviderComboBox(providerComboBox); - this.dyanamicFieldConfigAttributes = attributes; - this.dynamicSettingsMap = settings; - this.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; - this.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo; - this.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; - this.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; - this.dynamicVariableList = dynamicVariableList; - this.dataTypeList = dataTypeList; - this.dropDownMap = dropDownMap; - this.editPolicy = editPolicy; - this.domain = domain; - this.highestVersion = highestVersion; - this.treatments = treatments; + this.dynamicRuleAlgorithmLabels = stdPAPPolicyParams.getDynamicRuleAlgorithmLabels(); + this.dynamicRuleAlgorithmCombo = stdPAPPolicyParams.getDynamicRuleAlgorithmCombo(); + this.dynamicRuleAlgorithmField1 = stdPAPPolicyParams.getDynamicRuleAlgorithmField1(); + this.dynamicRuleAlgorithmField2 = stdPAPPolicyParams.getDynamicRuleAlgorithmField2(); + this.dynamicVariableList = stdPAPPolicyParams.getDynamicVariableList(); + this.dataTypeList = stdPAPPolicyParams.getDataTypeList(); + this.dropDownMap = stdPAPPolicyParams.getDropDownMap(); + this.actionPerformer = stdPAPPolicyParams.getActionPerformer(); + this.actionAttribute = stdPAPPolicyParams.getActionAttribute(); + this.treatments = stdPAPPolicyParams.getTreatments(); } //convenience constructor 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 a9daa9e97..0e183e08a 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 @@ -20,15 +20,19 @@ package org.onap.policy.xacml.std.pap; +import java.util.List; import java.util.Map; +/** + * Std PAP Policy paramters class. + */ public class StdPAPPolicyParams { private String configPolicyType; private String policyName; private String description; private String onapName; private String configName; - private Map<String, String> attributes; + private Map<String, String> dyanamicFieldConfigAttributes; private String configType; private String configBodyData; private Boolean editPolicy; @@ -38,7 +42,22 @@ public class StdPAPPolicyParams { private String guard; private String ttlDate; private int highestVersion; - + private List<String> dynamicRuleAlgorithmLabels; + private List<String> dynamicRuleAlgorithmCombo; + private List<String> dynamicRuleAlgorithmField1; + private List<String> dynamicRuleAlgorithmField2; + private String actionPerformer; + private String actionAttribute; + private String providerComboBox; + private Map<String, String> dynamicSettingsMap; + private List<Object> dynamicVariableList; + private List<String> dataTypeList; + private Map<String, String> dropDownMap; + private Map<String,String> treatments; + + /** + * Default constructor + */ private StdPAPPolicyParams() { super(); } @@ -71,8 +90,8 @@ public class StdPAPPolicyParams { return configName; } - public Map<String, String> getAttributes() { - return attributes; + public Map<String, String> getDyanamicFieldConfigAttributes() { + return dyanamicFieldConfigAttributes; } public String getConfigType() { @@ -107,6 +126,57 @@ public class StdPAPPolicyParams { return ttlDate; } + public List<String> getDynamicRuleAlgorithmLabels() { + return dynamicRuleAlgorithmLabels; + } + + public List<String> getDynamicRuleAlgorithmCombo() { + return dynamicRuleAlgorithmCombo; + } + + public List<String> getDynamicRuleAlgorithmField1() { + return dynamicRuleAlgorithmField1; + } + + public List<String> getDynamicRuleAlgorithmField2() { + return dynamicRuleAlgorithmField2; + } + + public String getActionPerformer() { + return actionPerformer; + } + + public String getActionAttribute() { + return actionAttribute; + } + + public String getProviderComboBox() { + return providerComboBox; + } + + public Map<String,String> getDynamicSettingsMap() { + return dynamicSettingsMap; + } + + public List<Object> getDynamicVariableList() { + return dynamicVariableList; + } + + public List<String> getDataTypeList() { + return dataTypeList; + } + + public Map<String,String> getDropDownMap() { + return dropDownMap; + } + + public Map<String,String> getTreatments() { + return treatments; + } + + /** + * Builder class for the Policy parameters + */ public static class StdPAPPolicyParamsBuilder { StdPAPPolicyParams m = new StdPAPPolicyParams(); @@ -140,8 +210,8 @@ public class StdPAPPolicyParams { return this; } - public StdPAPPolicyParamsBuilder attributes(Map<String, String> attributes) { - m.attributes = attributes; + public StdPAPPolicyParamsBuilder dyanamicFieldConfigAttributes(Map<String, String> attributes) { + m.dyanamicFieldConfigAttributes = attributes; return this; } @@ -189,5 +259,65 @@ public class StdPAPPolicyParams { m.highestVersion = highVer; return this; } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmLabels(List<String> dynamicRuleAlgorithmLabels) { + m.dynamicRuleAlgorithmLabels = dynamicRuleAlgorithmLabels; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmCombo(List<String> dynamicRuleAlgorithmCombo) { + m.dynamicRuleAlgorithmCombo = dynamicRuleAlgorithmCombo; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmField1(List<String> dynamicRuleAlgorithmField1) { + m.dynamicRuleAlgorithmField1 = dynamicRuleAlgorithmField1; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicRuleAlgorithmField2(List<String> dynamicRuleAlgorithmField2) { + m.dynamicRuleAlgorithmField2 = dynamicRuleAlgorithmField2; + return this; + } + + public StdPAPPolicyParamsBuilder actionPerformer(String actionPerformer) { + m.actionPerformer = actionPerformer; + return this; + } + + public StdPAPPolicyParamsBuilder actionAttribute(String actionAttribute) { + m.actionAttribute = actionAttribute; + return this; + } + + public StdPAPPolicyParamsBuilder providerComboBox(String providerComboBox) { + m.providerComboBox = providerComboBox; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicVariableList(List<Object> dynamicVariableList) { + m.dynamicVariableList = dynamicVariableList; + return this; + } + + public StdPAPPolicyParamsBuilder dynamicSettingsMap(Map<String, String> dynamicSettingsMap) { + m.dynamicSettingsMap = dynamicSettingsMap; + return this; + } + + public StdPAPPolicyParamsBuilder dataTypeList(List<String> dataTypeList) { + m.dataTypeList = dataTypeList; + return this; + } + + public StdPAPPolicyParamsBuilder dropDownMap(Map<String, String> dropDownMap){ + m.dropDownMap = dropDownMap; + return this; + } + + public StdPAPPolicyParamsBuilder treatments(Map<String,String> treatments) { + m.treatments = treatments; + return this; + } } } |