From ce1cf85647ab1ae3c292fd1b1286ea0dbb56223f Mon Sep 17 00:00:00 2001 From: "Tej, Tarun" Date: Fri, 11 Aug 2017 12:20:16 -0400 Subject: Fixes for Backward compatibility issues Changes to the API interface and Java SDK to support backward compatibility. Issue-Id: POLICY-165 Change-Id: I2efe8196614cfbd8b733abceb505bd6b91aa97f7 Signed-off-by: Tarun Tej Velaga --- .../onap/policy/api/ConfigRequestParameters.java | 32 ++++++++-- .../onap/policy/api/DecisionRequestParameters.java | 48 +++++++++++---- .../java/org/onap/policy/api/PolicyConfigType.java | 4 +- .../java/org/onap/policy/api/PolicyEngine.java | 68 +++++++++++----------- .../java/org/onap/policy/api/PolicyParameters.java | 33 +++++++++-- .../java/org/onap/policy/std/StdPolicyEngine.java | 10 ++-- 6 files changed, 133 insertions(+), 62 deletions(-) (limited to 'PolicyEngineAPI/src/main/java') diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java index cdee9672b..dcdc17802 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/ConfigRequestParameters.java @@ -31,7 +31,7 @@ import java.util.UUID; */ public class ConfigRequestParameters { private String policyName; - private String onapComponentName; + private String onapName; private String configName; private Map configAttributes; private UUID requestID; @@ -49,12 +49,23 @@ public class ConfigRequestParameters { /** * Sets the ONAP Component Name of the Config policy which needs to be retrieved. * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. */ - public void setOnapName(String onapComponentName){ - this.onapComponentName = onapComponentName; + public void setOnapName(String onapName){ + this.onapName = onapName; } + /** + * Sets the ONAP Component Name of the Config policy which needs to be retrieved. + * + * @param ecompName the String format of the onapName whose configuration is required. + * @deprecated use {@link #setOnapName(String)} instead. + */ + @Deprecated + public void setEcompName(String ecompName){ + this.onapName = ecompName; + } + /** * Sets the Config Name of the Config policy which needs to be retrieved. * @@ -97,9 +108,20 @@ public class ConfigRequestParameters { * @return String format of the ONAP Component Name. */ public String getOnapName(){ - return onapComponentName; + return onapName; } + /** + * Gets the ONAP Component Name of the Request Parameters. + * + * @return String format of the ONAP Component Name. + * @deprecated use {@link #getOnapName()} instead. + */ + @Deprecated + public String getEcompName(){ + return onapName; + } + /** * Gets the Config name of the Request Parameters. * diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java index 27e419fb1..5cf9d641d 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/DecisionRequestParameters.java @@ -30,7 +30,7 @@ import java.util.UUID; * @version 0.1 */ public class DecisionRequestParameters { - private String onapComponentName; + private String onapName; private Map decisionAttributes; private UUID requestID; @@ -43,32 +43,56 @@ public class DecisionRequestParameters { /** * Constructor with Parameters * - * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param onapName the String format of the onapName whose Decision is required. * @param decisionAttributes the Map of String,String format of the decisionAttributes that contain the ID and values. * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. */ - public DecisionRequestParameters(String onapComponentName, Map decisionAttributes, UUID requestID){ - this.onapComponentName = onapComponentName; + public DecisionRequestParameters(String onapName, Map decisionAttributes, UUID requestID){ + this.onapName = onapName; this.decisionAttributes = decisionAttributes; this.requestID = requestID; } /** - * Gets the ONAPComponentName of the Decision Request Parameters. + * Gets the onapName of the Decision Request Parameters. * - * @return ONAPComponentName the String format of the onapComponentName of the Decision Request Parameters. + * @return onapName the String format of the onapName of the Decision Request Parameters. */ - public String getONAPComponentName() { - return onapComponentName; + public String getOnapName() { + return onapName; } + + /** + * Gets the onapName of the Decision Request Parameters. + * + * @return onapName the String format of the onapName of the Decision Request Parameters. + * @deprecated use {@link #getOnapName()} instead. + */ + @Deprecated + public String getECOMPComponentName() { + return onapName; + } + /** - * Sets the ONAPComponentName of the Decision Request parameters. + * Sets the onapName of the Decision Request parameters. * - * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param onapName the String format of the onapName whose Decision is required. */ - public void setONAPComponentName(String onapComponentName) { - this.onapComponentName = onapComponentName; + public void setOnapName(String onapName) { + this.onapName = onapName; } + + /** + * Sets the ecompComponentName of the Decision Request parameters. + * + * @param ecompName the String format of the onapName whose Decision is required. + * @deprecated use {@link #setOnapName(String)} instead. + */ + @Deprecated + public void setECOMPComponentName(String ecompName) { + this.onapName = ecompName; + } + /** * Gets the Decision Attributes from Decision Request Parameters. * diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java index 77c978da4..59fd42733 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfigType.java @@ -57,7 +57,9 @@ public enum PolicyConfigType{ * Indicates DCAE Micro Service based Policy. */ MicroService("MS"), - + /** + * Indicates Custom Extended Policy type. + */ Extended("EXTENDED") ; diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java index bfb4f1e4f..7bd45983b 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyEngine.java @@ -121,22 +121,22 @@ public class PolicyEngine{ } /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapComponentName + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapName * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. * @throws PolicyConfigException PolicyConfig Exception * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. */ @Deprecated - public Collection getConfig(String onapComponentName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapComponentName, null, null, null)); + public Collection getConfig(String onapName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, null, null, null)); } /** - * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapComponentName + * Gets the configuration from the PolicyDecisionPoint(PDP) for the String which represents the onapName * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. * A different request ID should be passed for each request. @@ -144,32 +144,32 @@ public class PolicyEngine{ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. */ @Deprecated - public Collection getConfig(String onapComponentName, UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapComponentName, null, null, requestID)); + public Collection getConfig(String onapName, UUID requestID) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID)); } /** - * Requests the configuration of the String which represents the onapComponentName and String + * Requests the configuration of the String which represents the onapName and String * which represents the configName and returns the configuration if different Configurations exist for the - * particular onapComponentName. + * particular onapName. * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. * @param configName the String format of the configurationName whose configuration is required. * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. * @throws PolicyConfigException PolicyConfig Exception * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. */ @Deprecated - public Collection getConfig(String onapComponentName, String configName) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapComponentName, configName, null, null)); + public Collection getConfig(String onapName, String configName) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, configName, null, null)); } /** - * Requests the configuration of the String which represents the onapComponentName and String + * Requests the configuration of the String which represents the onapName and String * which represents the configName and returns the configuration if different Configurations exist for the - * particular onapComponentName. + * particular onapName. * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. * @param configName the String format of the configurationName whose configuration is required. * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. * A different request ID should be passed for each request. @@ -178,16 +178,16 @@ public class PolicyEngine{ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. */ @Deprecated - public Collection getConfig(String onapComponentName, String configName, UUID requestID) throws PolicyConfigException { - return getConfig(setConfigRequestParameters(null, onapComponentName, configName, null, requestID)); + public Collection getConfig(String onapName, String configName, UUID requestID) throws PolicyConfigException { + return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID)); } /** - * Requests the configuration of the String which represents the onapComponentName, String + * Requests the configuration of the String which represents the onapName, String * which represents the configName and Map of String,String which has the configAttribute and returns the specific * configuration related to the configAttributes mentioned. * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. * @param configName the String format of the configurationName whose configuration is required. * @param configAttributes the Map of String,String format of the configuration attributes which are required. * @return Collection of {@link org.onap.policy.api.PolicyConfig} which has the configuration. @@ -195,16 +195,16 @@ public class PolicyEngine{ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. */ @Deprecated - public Collection getConfig(String onapComponentName, String configName, Map configAttributes) throws PolicyConfigException{ - return getConfig(setConfigRequestParameters(null, onapComponentName, configName, configAttributes, null)); + public Collection getConfig(String onapName, String configName, Map configAttributes) throws PolicyConfigException{ + return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null)); } /** - * Requests the configuration of the String which represents the onapComponentName, String + * Requests the configuration of the String which represents the onapName, String * which represents the configName and Map of String,String which has the configAttribute and returns the specific * configuration related to the configAttributes mentioned. * - * @param onapComponentName the String format of the onapComponentName whose configuration is required. + * @param onapName the String format of the onapName whose configuration is required. * @param configName the String format of the configurationName whose configuration is required. * @param configAttributes the Map of String,String format of the configuration attributes which are required. * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. @@ -214,8 +214,8 @@ public class PolicyEngine{ * @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead. */ @Deprecated - public Collection getConfig(String onapComponentName, String configName, Map configAttributes, UUID requestID) throws PolicyConfigException{ - return getConfig(setConfigRequestParameters(null, onapComponentName, configName, configAttributes, requestID)); + public Collection getConfig(String onapName, String configName, Map configAttributes, UUID requestID) throws PolicyConfigException{ + return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID)); } /** @@ -285,21 +285,21 @@ public class PolicyEngine{ /** * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. * - * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param onapName the String format of the onapName whose Decision is required. * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. * @return {@link org.onap.policy.api.DecisionResponse} which has the Decision. * @throws PolicyDecisionException PolicyDecision Exception * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. */ @Deprecated - public DecisionResponse getDecision(String onapComponentName, Map decisionAttributes) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(onapComponentName, decisionAttributes, null); + public DecisionResponse getDecision(String onapName, Map decisionAttributes) throws PolicyDecisionException { + return stdPolicyEngine.getDecision(onapName, decisionAttributes, null); } /** * Sends the decision Attributes specified to the PEP and returns back the PolicyDecision. * - * @param onapComponentName the String format of the onapComponentName whose Decision is required. + * @param onapName the String format of the onapName whose Decision is required. * @param decisionAttributes the Map of String,String format of the decisionAttributes that must contain the ID and values. * @param requestID unique request ID which will be passed throughout the ONAP components to correlate logging messages. * A different request ID should be passed for each request. @@ -308,8 +308,8 @@ public class PolicyEngine{ * @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead. */ @Deprecated - public DecisionResponse getDecision(String onapComponentName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { - return stdPolicyEngine.getDecision(onapComponentName, decisionAttributes, requestID); + public DecisionResponse getDecision(String onapName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { + return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID); } /** @@ -590,10 +590,10 @@ public class PolicyEngine{ } // Internal Setter Method to help build configRequestParameters. - private ConfigRequestParameters setConfigRequestParameters(String policyName, String onapComponentName, String configName, Map configAttributes, UUID requestID){ + private ConfigRequestParameters setConfigRequestParameters(String policyName, String onapName, String configName, Map configAttributes, UUID requestID){ ConfigRequestParameters configRequestParameters = new ConfigRequestParameters(); configRequestParameters.setPolicyName(policyName); - configRequestParameters.setOnapName(onapComponentName); + configRequestParameters.setOnapName(onapName); configRequestParameters.setConfigName(configName); configRequestParameters.setConfigAttributes(configAttributes); configRequestParameters.setRequestID(requestID); diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java index 0d76d8f13..1078916eb 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyParameters.java @@ -53,7 +53,7 @@ public class PolicyParameters { private RuleProvider ruleProvider; private String controllerName; private ArrayList dependencyNames; - private Date TTLDate; + private Date ttlDate; private boolean guard = false; private String riskLevel = "5"; private String riskType = "default"; @@ -146,6 +146,17 @@ public class PolicyParameters { public String getOnapName() { return onapName; } + + /** + * Gets the ONAP Name value of the Policy Paramters. + * + * @return String format of the ONAP Name + * @deprecated Use {@link #getOnapName()} instead. + */ + @Deprecated + public String getEcompName() { + return onapName; + } /** * Sets the ONAP Name field of the Policy Parameters. @@ -155,6 +166,18 @@ public class PolicyParameters { public void setOnapName(String onapName) { this.onapName = onapName; } + + /** + * Sets the ONAP Name field of the Policy Parameters. + * + * @param ecompName the String format of the ONAP Name + * @deprecated use {@link #setOnapName(String)} instead. + */ + @Deprecated + public void setEcompName(String ecompName) { + this.onapName = ecompName; + } + /** * Gets the Config Name value of the Policy Parameters. @@ -486,10 +509,10 @@ public class PolicyParameters { /** * Sets the TTLDate field of the Policy Parameters. * - * @param TTLDate the Date format of the TTLDate value + * @param ttlDate the Date format of the TTLDate value */ - public void setTtlDate(Date TTLDate){ - this.TTLDate = TTLDate; + public void setTtlDate(Date ttlDate){ + this.ttlDate = ttlDate; } /** @@ -498,7 +521,7 @@ public class PolicyParameters { * @return the Date value of the TTLDate for Config Policies */ public Date getTtlDate(){ - return TTLDate; + return ttlDate; } /** 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 608bb8de0..8a6c6c668 100644 --- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java +++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java @@ -205,8 +205,8 @@ public class StdPolicyEngine { /* * getDecision using the decision Attributes. */ - public DecisionResponse getDecision(String onapComponentName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { - return getDecisionImpl(onapComponentName, decisionAttributes, requestID); + public DecisionResponse getDecision(String onapName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { + return getDecisionImpl(onapName, decisionAttributes, requestID); } /* @@ -218,7 +218,7 @@ public class StdPolicyEngine { LOGGER.error(message); throw new PolicyDecisionException(message); } - return getDecisionImpl(decisionRequestParameters.getONAPComponentName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID()); + return getDecisionImpl(decisionRequestParameters.getOnapName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID()); } /* @@ -523,7 +523,7 @@ public class StdPolicyEngine { } } - public DecisionResponse getDecisionImpl(String onapComponentName, + public DecisionResponse getDecisionImpl(String onapName, Map decisionAttributes, UUID requestID) throws PolicyDecisionException { String resource= "getDecision"; @@ -533,7 +533,7 @@ public class StdPolicyEngine { try { DecisionRequestParameters decisionRequestParameters = new DecisionRequestParameters(); decisionRequestParameters.setDecisionAttributes(decisionAttributes); - decisionRequestParameters.setONAPComponentName(onapComponentName); + decisionRequestParameters.setOnapName(onapName); decisionRequestParameters.setRequestID(requestID); body = PolicyUtils.objectToJsonString(decisionRequestParameters); } catch (JsonProcessingException e) { -- cgit 1.2.3-korg