*/
public class PolicyClient {
+ protected static final String POLICY_PREFIX_BASE = "Config_";
+ protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_";
+ protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_";
+
protected static final String LOG_POLICY_PREFIX = "Response is ";
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ protected static final EELFLogger logger = EELFManager.getInstance()
+ .getLogger(PolicyClient.class);
+ protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
@Value("${org.onap.clamp.config.files.cldsPolicyConfig:'classpath:/clds/clds-policy-config.properties'}")
protected String cldsPolicyConfigFile;
protected RefProp refProp;
/**
- * Perform send of microservice policy.
+ * Perform BRMS policy type.
*
* @param attributes
* A map of attributes
* In case of issues with the PolicyEngine class
*
*/
- public String sendBrms(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
+ public String sendBrmsPolicy(Map<AttributeType, Map<String, String>> attributes, ModelProperties prop,
String policyRequestUuid) throws PolicyEngineException, IOException {
PolicyParameters policyParameters = new PolicyParameters();
}
/**
- * Perform send of microservice policy.
+ * Perform send of microservice policy in JSON.
*
* @param policyJson
* The policy JSON
* @throws IOException
* In case of issue with the Stream
*/
- public String sendMicroService(String policyJson, ModelProperties prop, String policyRequestUuid)
+ public String sendMicroServiceInJson(String policyJson, ModelProperties prop, String policyRequestUuid)
throws IOException, PolicyEngineException {
PolicyParameters policyParameters = new PolicyParameters();
return rtnMsg;
}
+ /**
+ * Perform send of base policy in OTHER type.
+ *
+ * @param configBody
+ * The config policy string body
+ * @param prop
+ * The ModelProperties
+ * @param policyRequestUuid
+ * The policy request UUID
+ * @return
+ * @throws IOException
+ * In case of issues with the policy engine class creation
+ * @throws PolicyEngineException
+ * In case of issue with the Stream
+ */
+ public String sendBasePolicyInOther(String configBody, ModelProperties prop, String policyRequestUuid)
+ throws IOException, PolicyEngineException {
+
+ PolicyParameters policyParameters = new PolicyParameters();
+
+ // Set Policy Type
+ policyParameters.setPolicyConfigType(PolicyConfigType.Base);
+ policyParameters.setEcompName(refProp.getStringValue("policy.ecomp.name"));
+ policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
+
+ policyParameters.setConfigBody(configBody);
+ policyParameters.setConfigBodyType(PolicyType.OTHER);
+ policyParameters.setConfigName("HolmesPolicy");
+
+ policyParameters.setRequestID(UUID.fromString(policyRequestUuid));
+
+ // Adding this line to clear the policy id from policy name while
+ // pushing to policy engine
+ prop.setPolicyUniqueId("");
+
+ String rtnMsg = send(policyParameters, prop, POLICY_PREFIX_BASE);
+ push(PolicyConfigType.Base.toString(), prop);
+
+ return rtnMsg;
+ }
+
/**
* Perform send of policy.
*
responseMessage = response.getResponseMessage();
}
} catch (Exception e) {
- logger.error("Exception occurred during policy communnication", e);
+ logger.error("Exception occurred during policy communication", e);
}
logger.info(LOG_POLICY_PREFIX + responseMessage);
response = policyEngine.pushPolicy(pushPolicyParameters);
responseMessage = response.getResponseMessage();
} catch (Exception e) {
- logger.error("Exception occurred during policy communnication", e);
+ logger.error("Exception occurred during policy communication", e);
}
logger.info(LOG_POLICY_PREFIX + responseMessage);
* In case of issues with the PolicyEngine creation
*/
public String deleteMicrosService(ModelProperties prop) throws PolicyEngineException, IOException {
- String policyNamePrefix = refProp.getStringValue("policy.ms.policyNamePrefix");
String policyType = refProp.getStringValue("policy.ms.type");
- return deletePolicy(policyNamePrefix, prop, policyType);
+ return deletePolicy(prop, policyType);
+ }
+
+ /**
+ * This method delete the Base policy.
+ *
+ * @param prop The model Properties
+ * @return A string with the answer from policy
+ * @throws PolicyEngineException In case of issues with the policy engine
+ * @throws IOException In case of issues with the stream
+ */
+ public String deleteBasePolicy(ModelProperties prop) throws PolicyEngineException, IOException {
+ return deletePolicy(prop, PolicyConfigType.Base.toString());
}
/**
* In case of issues with the PolicyEngine creation
*/
public String deleteBrms(ModelProperties prop) throws PolicyEngineException, IOException {
- String policyNamePrefix = refProp.getStringValue("policy.op.policyNamePrefix");
String policyType = refProp.getStringValue("policy.op.type");
- return deletePolicy(policyNamePrefix, prop, policyType);
+ return deletePolicy(prop, policyType);
}
/**
* Format and send delete PAP and PDP requests to Policy.
*
- * @param policyNamePrefix
- * The String policyNamePrefix
* @param prop
* The ModelProperties
+ *
* @return The response message from policy
* @throws IOException
* in case of issues with the Stream
* @throws PolicyEngineException
* In case of issues with the PolicyEngine class creation
*/
- protected String deletePolicy(String policyNamePrefix, ModelProperties prop, String policyType)
- throws PolicyEngineException, IOException {
+ protected String deletePolicy(ModelProperties prop, String policyType) throws PolicyEngineException, IOException {
DeletePolicyParameters deletePolicyParameters = new DeletePolicyParameters();
if (prop.getPolicyUniqueId() != null && !prop.getPolicyUniqueId().isEmpty()) {