summaryrefslogtreecommitdiffstats
path: root/applications/optimization/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-08 08:47:38 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-10 08:39:41 -0400
commite034d785a227815f66138d1f83f49624c402aa97 (patch)
tree38feabe112c00b97bc3deab32c4fb845f63a7b04 /applications/optimization/src/main/java
parent5dd6d165a0b3ee88563e5bcabd4c2a7fc42a676b (diff)
Test decision from main entry
Tests a decision upon startup. This also updates the use of ToscaPolicyTypeIdentifier for all the applications. Very basic packaging for applications and their properties. Added cleaning of unused imports to remove sonar issues. Added production persistence.xml file to guard application. Not sure if we need a copy in the application/common resource directory. Issue-ID: POLICY-1440 Change-Id: If96eef5a9e0a7c6cc5461c0bdb6f0cd708cc41bb Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'applications/optimization/src/main/java')
-rw-r--r--applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java55
1 files changed, 34 insertions, 21 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 4a4a6046..accf7a0c 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
@@ -25,12 +25,12 @@ package org.onap.policy.xacml.pdp.application.optimization;
import com.att.research.xacml.api.Request;
import com.att.research.xacml.api.Response;
import com.att.research.xacml.util.XACMLPolicyWriter;
-import com.google.common.collect.Lists;
import java.io.IOException;
import java.nio.file.Path;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -39,6 +39,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
import org.onap.policy.models.decisions.concepts.DecisionResponse;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifier;
import org.onap.policy.pdp.xacml.application.common.ToscaPolicyConversionException;
import org.onap.policy.pdp.xacml.application.common.XacmlPolicyUtils;
import org.onap.policy.pdp.xacml.application.common.std.StdMatchableTranslator;
@@ -52,26 +53,35 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
private static final String STRING_VERSION100 = "1.0.0";
private StdMatchableTranslator translator = new StdMatchableTranslator();
- private Map<String, String> supportedPolicyTypes = new HashMap<>();
+ private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes = new ArrayList<>();
/**
* Constructor.
*/
public OptimizationPdpApplication() {
- this.supportedPolicyTypes.put("onap.policies.optimization.AffinityPolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.DistancePolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.HpaPolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.OptimizationPolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.PciPolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.QueryPolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.SubscriberPolicy", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.Vim_fit", STRING_VERSION100);
- this.supportedPolicyTypes.put("onap.policies.optimization.VnfPolicy", STRING_VERSION100);
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.AffinityPolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.DistancePolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.HpaPolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.OptimizationPolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.PciPolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.QueryPolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.SubscriberPolicy", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.Vim_fit", STRING_VERSION100));
+ this.supportedPolicyTypes.add(new ToscaPolicyTypeIdentifier(
+ "onap.policies.optimization.VnfPolicy", STRING_VERSION100));
}
@Override
public String applicationName() {
- return "Optimization Application";
+ return "optimization";
}
@Override
@@ -80,23 +90,26 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid
}
@Override
- public synchronized List<String> supportedPolicyTypes() {
- return Lists.newArrayList(supportedPolicyTypes.keySet());
+ public synchronized List<ToscaPolicyTypeIdentifier> supportedPolicyTypes() {
+ return Collections.unmodifiableList(supportedPolicyTypes);
}
@Override
- public boolean canSupportPolicyType(String policyType, String policyTypeVersion) {
+ public boolean canSupportPolicyType(ToscaPolicyTypeIdentifier policyTypeId) {
//
// For the time being, restrict this if the version isn't known.
// Could be too difficult to support changing of versions dynamically.
//
- if (! this.supportedPolicyTypes.containsKey(policyType)) {
- return false;
- }
//
- // Must match version exactly
+ // For the time being, restrict this if the version isn't known.
+ // Could be too difficult to support changing of versions dynamically.
//
- return this.supportedPolicyTypes.get(policyType).equals(policyTypeVersion);
+ for (ToscaPolicyTypeIdentifier supported : this.supportedPolicyTypes) {
+ if (policyTypeId.equals(supported)) {
+ return true;
+ }
+ }
+ return false;
}
@Override