diff options
author | Tej, Tarun <tt3868@att.com> | 2017-12-12 15:04:43 -0500 |
---|---|---|
committer | Tej, Tarun <tt3868@att.com> | 2017-12-13 17:07:58 -0500 |
commit | 948367c08eb34ebaac24601cfc2b249b11925255 (patch) | |
tree | 662ec1834c897b3d77447905a3f9db397a2bd2bd /PolicyEngineAPI | |
parent | aa9e865ccf191e814b50b8b4b51d516fc359d948 (diff) |
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 <tt3868@att.com>
Diffstat (limited to 'PolicyEngineAPI')
5 files changed, 39 insertions, 1 deletions
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 <code>Map</code> of <code>String, String</code> which consists of the Response Attributes of the Policy retrieved. */ public Map<String,String> getResponseAttributes(); + + /** + * Gets the {@link PolicyConfigType} of the policy that has been retrieved. + * + * @return the <code>PolicyConfigType</code> of the policy that has been retrieved. + */ + public PolicyConfigType getPolicyType(); /** * Returns the <code>String</code> version of the <code>PolicyConfig</code> 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<String,String> 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<String,String> matchingConditions; private Map<String,String> 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; + } } |