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 <tt3868@att.com>
*/
package org.onap.policy.pdp.rest.api.models;
-import io.swagger.annotations.ApiModel;
-
import java.io.Serializable;
import java.util.Map;
+import io.swagger.annotations.ApiModel;
+
@ApiModel
public class ConfigPolicyAPIRequest implements Serializable{
private static final long serialVersionUID = -4103391389984557025L;
public String getOnapName() {
return onapName;
}
+ /**
+ * @return the onapName
+ */
+ @Deprecated
+ public String getEcompName() {
+ return onapName;
+ }
/**
* @return the configName
*/
public void setOnapName(String onapName) {
this.onapName = onapName;
}
+ /**
+ * @param ecompName the onapName to set
+ */
+ @Deprecated
+ public void setEcompName(String ecompName) {
+ this.onapName = ecompName;
+ }
/**
* @param configName the configName to set
*/
return false;
}
if(configRequestParameters.getOnapName()==null && configRequestParameters.getPolicyName()==null){
- message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot proceed without onapComponentName or PolicyName";
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot proceed without onapName or PolicyName";
return false;
}
return true;
message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Decision Request Paramaters";
return false;
}
- onapComponentName = decisionRequestParameters.getONAPComponentName();
+ onapComponentName = decisionRequestParameters.getOnapName();
decisionAttributes = decisionRequestParameters.getDecisionAttributes();
if (onapComponentName == null || onapComponentName.isEmpty()) {
message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No onapComponentName given : " + onapComponentName;
DecisionRequestParameters pep = new DecisionRequestParameters();
Map<String,String> eventAttributes = new HashMap<>();
eventAttributes.put("TEST", "test");
- pep.setONAPComponentName("te123");
+ pep.setOnapName("te123");
pep.setDecisionAttributes(eventAttributes);
PDPServices fixture = new PDPServices();
.add("Request", Json.createObjectBuilder()
.add("AccessSubject", Json.createObjectBuilder()
.add("Attribute", Json.createObjectBuilder()
- .add("Value", pep.getONAPComponentName())
+ .add("Value", pep.getOnapName())
.add("AttributeId", "ONAPName")))
.add("Resource", Json.createObjectBuilder()
.add("Attribute", resourceArray))
DecisionRequestParameters pep = new DecisionRequestParameters();
Map<String,String> eventAttributes = new HashMap<>();
eventAttributes.put("TEST", "test");
- pep.setONAPComponentName("te123");
+ pep.setOnapName("te123");
pep.setDecisionAttributes(eventAttributes);
//Failure Tests.
mockMvc.perform(post("/getDecision")).andExpect(status().isBadRequest());
mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
.headers(headers).header(UUIDHEADER, "123")).andExpect(status().isOk());
pep.setDecisionAttributes(null);
- pep.setONAPComponentName(null);
+ pep.setOnapName(null);
mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
.headers(headers).header(UUIDHEADER, UUID.randomUUID())).andExpect(status().isBadRequest());
- pep.setONAPComponentName("testing");
+ pep.setOnapName("testing");
mockMvc.perform(post("/getDecision").content(PolicyUtils.objectToJsonString(pep)).contentType(MediaType.APPLICATION_JSON)
.headers(headers)).andExpect(status().isBadRequest());
pep.setDecisionAttributes(eventAttributes);
*/
public class ConfigRequestParameters {
private String policyName;
- private String onapComponentName;
+ private String onapName;
private String configName;
private Map<String,String> configAttributes;
private UUID requestID;
/**
* Sets the ONAP Component Name of the Config policy which needs to be retrieved.
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> 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 <code>String</code> 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.
*
* @return <code>String</code> format of the ONAP Component Name.
*/
public String getOnapName(){
- return onapComponentName;
+ return onapName;
}
+ /**
+ * Gets the ONAP Component Name of the Request Parameters.
+ *
+ * @return <code>String</code> 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.
*
* @version 0.1
*/
public class DecisionRequestParameters {
- private String onapComponentName;
+ private String onapName;
private Map<String,String> decisionAttributes;
private UUID requestID;
/**
* Constructor with Parameters
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose Decision is required.
+ * @param onapName the <code>String</code> format of the onapName whose Decision is required.
* @param decisionAttributes the <code>Map</code> of <code>String,String</code> 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<String,String> decisionAttributes, UUID requestID){
- this.onapComponentName = onapComponentName;
+ public DecisionRequestParameters(String onapName, Map<String,String> 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 <code>String</code> format of the onapComponentName of the Decision Request Parameters.
+ * @return onapName the <code>String</code> 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 <code>String</code> 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 <code>String</code> format of the onapComponentName whose Decision is required.
+ * @param onapName the <code>String</code> 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 <code>String</code> 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.
*
* Indicates DCAE Micro Service based Policy.
*/
MicroService("MS"),
-
+ /**
+ * Indicates Custom Extended Policy type.
+ */
Extended("EXTENDED")
;
}
/**
- * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapComponentName
+ * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapName
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> format of the onapName whose configuration is required.
* @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
* @throws PolicyConfigException PolicyConfig Exception
* @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
*/
@Deprecated
- public Collection<PolicyConfig> getConfig(String onapComponentName) throws PolicyConfigException {
- return getConfig(setConfigRequestParameters(null, onapComponentName, null, null, null));
+ public Collection<PolicyConfig> getConfig(String onapName) throws PolicyConfigException {
+ return getConfig(setConfigRequestParameters(null, onapName, null, null, null));
}
/**
- * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapComponentName
+ * Gets the configuration from the PolicyDecisionPoint(PDP) for the <code>String</code> which represents the onapName
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> format of the onapName whose configuration is required.
* @return <code>Collection</code> 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.
* @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
*/
@Deprecated
- public Collection<PolicyConfig> getConfig(String onapComponentName, UUID requestID) throws PolicyConfigException {
- return getConfig(setConfigRequestParameters(null, onapComponentName, null, null, requestID));
+ public Collection<PolicyConfig> getConfig(String onapName, UUID requestID) throws PolicyConfigException {
+ return getConfig(setConfigRequestParameters(null, onapName, null, null, requestID));
}
/**
- * Requests the configuration of the <code>String</code> which represents the onapComponentName and <code>String</code>
+ * Requests the configuration of the <code>String</code> which represents the onapName and <code>String</code>
* which represents the configName and returns the configuration if different Configurations exist for the
- * particular onapComponentName.
+ * particular onapName.
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> format of the onapName whose configuration is required.
* @param configName the <code>String</code> format of the configurationName whose configuration is required.
* @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
* @throws PolicyConfigException PolicyConfig Exception
* @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
*/
@Deprecated
- public Collection<PolicyConfig> getConfig(String onapComponentName, String configName) throws PolicyConfigException {
- return getConfig(setConfigRequestParameters(null, onapComponentName, configName, null, null));
+ public Collection<PolicyConfig> getConfig(String onapName, String configName) throws PolicyConfigException {
+ return getConfig(setConfigRequestParameters(null, onapName, configName, null, null));
}
/**
- * Requests the configuration of the <code>String</code> which represents the onapComponentName and <code>String</code>
+ * Requests the configuration of the <code>String</code> which represents the onapName and <code>String</code>
* which represents the configName and returns the configuration if different Configurations exist for the
- * particular onapComponentName.
+ * particular onapName.
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> format of the onapName whose configuration is required.
* @param configName the <code>String</code> 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.
* @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
*/
@Deprecated
- public Collection<PolicyConfig> getConfig(String onapComponentName, String configName, UUID requestID) throws PolicyConfigException {
- return getConfig(setConfigRequestParameters(null, onapComponentName, configName, null, requestID));
+ public Collection<PolicyConfig> getConfig(String onapName, String configName, UUID requestID) throws PolicyConfigException {
+ return getConfig(setConfigRequestParameters(null, onapName, configName, null, requestID));
}
/**
- * Requests the configuration of the <code>String</code> which represents the onapComponentName, <code>String</code>
+ * Requests the configuration of the <code>String</code> which represents the onapName, <code>String</code>
* which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific
* configuration related to the configAttributes mentioned.
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> format of the onapName whose configuration is required.
* @param configName the <code>String</code> format of the configurationName whose configuration is required.
* @param configAttributes the <code>Map</code> of <code>String,String</code> format of the configuration attributes which are required.
* @return <code>Collection</code> of {@link org.onap.policy.api.PolicyConfig} which has the configuration.
* @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
*/
@Deprecated
- public Collection<PolicyConfig> getConfig(String onapComponentName, String configName, Map<String, String> configAttributes) throws PolicyConfigException{
- return getConfig(setConfigRequestParameters(null, onapComponentName, configName, configAttributes, null));
+ public Collection<PolicyConfig> getConfig(String onapName, String configName, Map<String, String> configAttributes) throws PolicyConfigException{
+ return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, null));
}
/**
- * Requests the configuration of the <code>String</code> which represents the onapComponentName, <code>String</code>
+ * Requests the configuration of the <code>String</code> which represents the onapName, <code>String</code>
* which represents the configName and <code>Map</code> of <code>String,String</code> which has the configAttribute and returns the specific
* configuration related to the configAttributes mentioned.
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose configuration is required.
+ * @param onapName the <code>String</code> format of the onapName whose configuration is required.
* @param configName the <code>String</code> format of the configurationName whose configuration is required.
* @param configAttributes the <code>Map</code> of <code>String,String</code> 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.
* @deprecated use {@link #getConfig(ConfigRequestParameters)} Instead.
*/
@Deprecated
- public Collection<PolicyConfig> getConfig(String onapComponentName, String configName, Map<String, String> configAttributes, UUID requestID) throws PolicyConfigException{
- return getConfig(setConfigRequestParameters(null, onapComponentName, configName, configAttributes, requestID));
+ public Collection<PolicyConfig> getConfig(String onapName, String configName, Map<String, String> configAttributes, UUID requestID) throws PolicyConfigException{
+ return getConfig(setConfigRequestParameters(null, onapName, configName, configAttributes, requestID));
}
/**
/**
* Sends the decision Attributes specified to the PEP and returns back the PolicyDecision.
*
- * @param onapComponentName the <code>String</code> format of the onapComponentName whose Decision is required.
+ * @param onapName the <code>String</code> format of the onapName whose Decision is required.
* @param decisionAttributes the <code>Map</code> of <code>String,String</code> 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<String,String> decisionAttributes) throws PolicyDecisionException {
- return stdPolicyEngine.getDecision(onapComponentName, decisionAttributes, null);
+ public DecisionResponse getDecision(String onapName, Map<String,String> 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 <code>String</code> format of the onapComponentName whose Decision is required.
+ * @param onapName the <code>String</code> format of the onapName whose Decision is required.
* @param decisionAttributes the <code>Map</code> of <code>String,String</code> 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.
* @deprecated use {@link #getDecision(DecisionRequestParameters)} Instead.
*/
@Deprecated
- public DecisionResponse getDecision(String onapComponentName, Map<String,String> decisionAttributes, UUID requestID) throws PolicyDecisionException {
- return stdPolicyEngine.getDecision(onapComponentName, decisionAttributes, requestID);
+ public DecisionResponse getDecision(String onapName, Map<String,String> decisionAttributes, UUID requestID) throws PolicyDecisionException {
+ return stdPolicyEngine.getDecision(onapName, decisionAttributes, requestID);
}
/**
}
// Internal Setter Method to help build configRequestParameters.
- private ConfigRequestParameters setConfigRequestParameters(String policyName, String onapComponentName, String configName, Map<String, String> configAttributes, UUID requestID){
+ private ConfigRequestParameters setConfigRequestParameters(String policyName, String onapName, String configName, Map<String, String> 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);
private RuleProvider ruleProvider;
private String controllerName;
private ArrayList<String> dependencyNames;
- private Date TTLDate;
+ private Date ttlDate;
private boolean guard = false;
private String riskLevel = "5";
private String riskType = "default";
public String getOnapName() {
return onapName;
}
+
+ /**
+ * Gets the ONAP Name value of the Policy Paramters.
+ *
+ * @return <code>String</code> 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.
public void setOnapName(String onapName) {
this.onapName = onapName;
}
+
+ /**
+ * Sets the ONAP Name field of the Policy Parameters.
+ *
+ * @param ecompName the <code>String</code> 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.
/**
* Sets the TTLDate field of the Policy Parameters.
*
- * @param TTLDate the <code>Date</code> format of the TTLDate value
+ * @param ttlDate the <code>Date</code> format of the TTLDate value
*/
- public void setTtlDate(Date TTLDate){
- this.TTLDate = TTLDate;
+ public void setTtlDate(Date ttlDate){
+ this.ttlDate = ttlDate;
}
/**
* @return the <code>Date</code> value of the TTLDate for Config Policies
*/
public Date getTtlDate(){
- return TTLDate;
+ return ttlDate;
}
/**
/*
* getDecision using the decision Attributes.
*/
- public DecisionResponse getDecision(String onapComponentName, Map<String, String> decisionAttributes, UUID requestID) throws PolicyDecisionException {
- return getDecisionImpl(onapComponentName, decisionAttributes, requestID);
+ public DecisionResponse getDecision(String onapName, Map<String, String> decisionAttributes, UUID requestID) throws PolicyDecisionException {
+ return getDecisionImpl(onapName, decisionAttributes, requestID);
}
/*
LOGGER.error(message);
throw new PolicyDecisionException(message);
}
- return getDecisionImpl(decisionRequestParameters.getONAPComponentName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID());
+ return getDecisionImpl(decisionRequestParameters.getOnapName(), decisionRequestParameters.getDecisionAttributes(), decisionRequestParameters.getRequestID());
}
/*
}
}
- public DecisionResponse getDecisionImpl(String onapComponentName,
+ public DecisionResponse getDecisionImpl(String onapName,
Map<String, String> decisionAttributes,
UUID requestID) throws PolicyDecisionException {
String resource= "getDecision";
try {
DecisionRequestParameters decisionRequestParameters = new DecisionRequestParameters();
decisionRequestParameters.setDecisionAttributes(decisionAttributes);
- decisionRequestParameters.setONAPComponentName(onapComponentName);
+ decisionRequestParameters.setOnapName(onapName);
decisionRequestParameters.setRequestID(requestID);
body = PolicyUtils.objectToJsonString(decisionRequestParameters);
} catch (JsonProcessingException e) {
// add additional test code here
assertNotNull(result);
- assertEquals(null, result.getONAPComponentName());
+ assertEquals(null, result.getOnapName());
assertEquals(null, result.getDecisionAttributes());
assertEquals(null, result.getRequestID());
}
// add additional test code here
assertNotNull(result);
- assertEquals("", result.getONAPComponentName());
+ assertEquals("", result.getOnapName());
}
/**
throws Exception {
DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
- String result = fixture.getONAPComponentName();
+ String result = fixture.getOnapName();
// add additional test code here
assertEquals("", result);
DecisionRequestParameters fixture = new DecisionRequestParameters("", new Hashtable<String, String>(), UUID.randomUUID());
String onapComponentName = "";
- fixture.setONAPComponentName(onapComponentName);
+ fixture.setOnapName(onapComponentName);
// add additional test code here
}