From 948367c08eb34ebaac24601cfc2b249b11925255 Mon Sep 17 00:00:00 2001 From: "Tej, Tarun" Date: Tue, 12 Dec 2017 15:04:43 -0500 Subject: Adding PolicyType to getConfig Response Adding a new parameter PolicyType so that getConfig Response can be known based on type of policy. Fixes for project warnings and unused imports. Issue-ID: POLICY-434 Change-Id: I0874abb7e986a8bb42ae18561064a8d7534eade6 Signed-off-by: Tej, Tarun --- .../src/main/java/org/onap/policy/api/PolicyConfig.java | 7 +++++++ .../org/onap/policy/models/APIPolicyConfigResponse.java | 8 ++++++++ .../src/main/java/org/onap/policy/std/StdPolicyConfig.java | 14 +++++++++++++- .../src/main/java/org/onap/policy/std/StdPolicyEngine.java | 1 + .../src/main/java/org/onap/policy/std/StdStatus.java | 10 ++++++++++ 5 files changed, 39 insertions(+), 1 deletion(-) (limited to 'PolicyEngineAPI') diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java index 652fd4da3..aa5ee1304 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java @@ -111,6 +111,13 @@ public interface PolicyConfig { * @return Map of String, String which consists of the Response Attributes of the Policy retrieved. */ public Map getResponseAttributes(); + + /** + * Gets the {@link PolicyConfigType} of the policy that has been retrieved. + * + * @return the PolicyConfigType of the policy that has been retrieved. + */ + public PolicyConfigType getPolicyType(); /** * Returns the String version of the PolicyConfig object. diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java index 7efee00b8..be363c24f 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java @@ -22,12 +22,14 @@ package org.onap.policy.models; import java.util.Map; import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyConfigType; import org.onap.policy.api.PolicyType; public class APIPolicyConfigResponse implements APIConfigResponse { private String policyConfigMessage; private PolicyConfigStatus policyConfigStatus; private PolicyType type; + private PolicyConfigType policyType; private String config; private String policyName; private String policyVersion; @@ -88,4 +90,10 @@ public class APIPolicyConfigResponse implements APIConfigResponse { public Map getResponseAttributes(){ return responseAttributes; } + public PolicyConfigType getPolicyType() { + return policyType; + } + public void setPolicyType(PolicyConfigType policyType) { + this.policyType = policyType; + } } diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java index 8a9b0a0b4..62db64491 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java @@ -28,6 +28,7 @@ import javax.json.JsonObject; import org.onap.policy.api.PolicyConfig; import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyConfigType; import org.onap.policy.api.PolicyType; import org.w3c.dom.Document; @@ -48,6 +49,7 @@ public class StdPolicyConfig implements PolicyConfig{ private String configStatus; private String policyName; private String policyVersion; + private PolicyConfigType type; private Map matchingConditions; private Map responseAttributes; @@ -89,7 +91,7 @@ public class StdPolicyConfig implements PolicyConfig{ @Override public String getPolicyName() { if(policyName!=null && policyName.contains(".xml")){ - return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf("."))); + return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.'))); } return policyName; } @@ -158,7 +160,17 @@ public class StdPolicyConfig implements PolicyConfig{ this.responseAttributes = responseAttributes; } + + public void setPolicyType(PolicyConfigType policyType) { + this.type = policyType; + } + @Override + public PolicyConfigType getPolicyType(){ + return this.type; + } + + @Override public String toString() { return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName + "" diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java index bef964174..6c74dde89 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java @@ -625,6 +625,7 @@ public class StdPolicyEngine { policyConfig.setPolicyName(policyConfigResponse.getPolicyName()); policyConfig.setPolicyType(policyConfigResponse.getType()); policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion()); + policyConfig.setPolicyType(policyConfigResponse.getPolicyType()); policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes()); setMatches(policyConfig.getMatchingConditions()); if (policyConfigResponse.getType() != null) { diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java index 798cbde37..fc854b077 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java @@ -29,6 +29,7 @@ import javax.json.JsonObject; import org.onap.policy.api.DecisionResponse; import org.onap.policy.api.PolicyConfig; import org.onap.policy.api.PolicyConfigStatus; +import org.onap.policy.api.PolicyConfigType; import org.onap.policy.api.PolicyDecision; import org.onap.policy.api.PolicyResponse; import org.onap.policy.api.PolicyResponseStatus; @@ -39,6 +40,7 @@ public class StdStatus extends StdPolicyResponse implements PolicyConfig, Policy private PolicyType policyType; private Properties properties; private JsonObject jsonObject; + private PolicyConfigType type; private Document document; private String other; private PolicyConfigStatus policyConfigStatus; @@ -232,4 +234,12 @@ public class StdStatus extends StdPolicyResponse implements PolicyConfig, Policy public String getDetails(){ return details; } + + public PolicyConfigType getPolicyType() { + return type; + } + + public void setPolicyType(PolicyConfigType policyType) { + this.type = policyType; + } } -- cgit 1.2.3-korg