diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2020-10-02 09:13:13 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2020-10-02 09:13:18 -0400 |
commit | 7ae3ab19d0556a0308f0d293d4dd2e58dd3d3929 (patch) | |
tree | 16e26e30d7a6e734ec34108d24727eb8afc0c9dc /applications/optimization/src | |
parent | 57e705469481f446aeada858c8eb411c5cccebc8 (diff) |
Remove duplicated code
Initially, just moving the applicationName and actions as protected
fields got rid of the sonar issue. I included also the supportedPolicyTypes
also. But that triggered another sonar duplicate code, so I had to rename
a few private fields to rid that. Seems like a very sensitive sonar detection
that results in kludgy code.
Issue-ID: POLICY-2681
Change-Id: Ie79a95786cdb80381cbce4b182e9e66a2776e0dd
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/optimization/src')
-rw-r--r-- | applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java index 8d337e47..1cc94ed6 100644 --- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java +++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java @@ -28,10 +28,8 @@ import com.att.research.xacml.api.Decision; import com.att.research.xacml.api.Response; import com.att.research.xacml.api.Result; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.Pair; @@ -66,12 +64,16 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid public static final String ONAP_OPTIMIZATION_DERIVED_POLICY_TYPE = "onap.policies.optimization."; private OptimizationPdpApplicationTranslator translator = new OptimizationPdpApplicationTranslator(); - private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>(); /** * Constructor. */ public OptimizationPdpApplication() { + super(); + + applicationName = "optimization"; + actions = Arrays.asList("optimize"); + this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_AFFINITY, STRING_VERSION100)); this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_DISTANCE, STRING_VERSION100)); this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(POLICYTYPE_HPA, STRING_VERSION100)); @@ -84,16 +86,6 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid } @Override - public String applicationName() { - return "optimization"; - } - - @Override - public List<String> actionDecisionsSupported() { - return Arrays.asList("optimize"); - } - - @Override public void initialize(Path pathForData, RestServerParameters policyApiParameters) throws XacmlApplicationException { // @@ -109,11 +101,6 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid } @Override - public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() { - return Collections.unmodifiableList(supportedPolicyTypes); - } - - @Override public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) { // // For the time being, restrict this if the version isn't known. |