summaryrefslogtreecommitdiffstats
path: root/BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java')
-rw-r--r--BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java41
1 files changed, 20 insertions, 21 deletions
diff --git a/BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java b/BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java
index 2cc178736..67713420e 100644
--- a/BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java
+++ b/BRMSGateway/src/main/java/org/openecomp/policy/brmsInterface/BRMSHandler.java
@@ -29,15 +29,13 @@ import org.openecomp.policy.api.PDPNotification;
import org.openecomp.policy.api.PolicyConfig;
import org.openecomp.policy.api.PolicyConfigStatus;
import org.openecomp.policy.api.PolicyEngine;
+import org.openecomp.policy.api.PolicyException;
import org.openecomp.policy.api.RemovedPolicy;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.utils.BackUpHandler;
-
import org.openecomp.policy.xacml.api.XACMLErrorConstants;
-
//import org.apache.log4j.Logger;
-
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
/**
* BRMSHandler: Notification Handler which listens for PDP Notifications.
@@ -47,24 +45,25 @@ import org.openecomp.policy.common.logging.flexlogger.Logger;
*/
public class BRMSHandler implements BackUpHandler{
-// private static final Logger logger = Logger.getLogger(BRMSHandler.class.getName());
private static final Logger logger = FlexLogger.getLogger(BRMSHandler.class.getName());
- // This Values are fixed for BRMS based rules. Don't change until they are changed during creation in PAP-ADMIN.
- //private static final String ecompName = "DROOLS";
- //private static final String configName = "BRMS_RAW_RULE";
private BRMSPush bRMSPush = null;
- public BRMSHandler(String propertiesFile) throws Exception{
- bRMSPush = new BRMSPush(propertiesFile, this);
+ public BRMSHandler(String propertiesFile) throws PolicyException{
+ setBRMSPush(new BRMSPush(propertiesFile, this));
+ }
+
+ public void setBRMSPush(BRMSPush brmsPush) {
+ this.bRMSPush = brmsPush;
}
@Override
public void notificationReceived(PDPNotification notification) {
logger.info("Notification Recieved");
logger.info(notification.getNotificationType().toString());
- bRMSPush.initiate();
- if(BRMSPush.getBackUpMonitor().getFlag()){
+ Boolean flag = BRMSPush.getBackUpMonitor().getFlag();
+ bRMSPush.initiate(flag);
+ if(flag){
logger.info("Master Application performing on Notification ");
runOnNotification(notification);
}else{
@@ -80,10 +79,8 @@ public class BRMSHandler implements BackUpHandler{
logger.info(removedPolicy.getVersionNo());
if(removedPolicy.getPolicyName().contains("_BRMS_")){
try{
- String name = removedPolicy.getPolicyName().substring(removedPolicy.getPolicyName().indexOf("_BRMS_")+6, removedPolicy.getPolicyName().length());
- name= name.substring(name.indexOf("_")+1,name.length());
- logger.info("Policy Removed with this policy Name : " + name);
- bRMSPush.removeRule(name);
+ logger.info("Policy Removed with this policy Name : " + removedPolicy.getPolicyName());
+ bRMSPush.removeRule(removedPolicy.getPolicyName());
removed = true;
}catch(Exception e){
logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Rertriving policy failed " + e.getMessage());
@@ -107,17 +104,15 @@ public class BRMSHandler implements BackUpHandler{
// Checking the Name is correct or not.
if(updatedPolicy.getPolicyName().contains("_BRMS_")){
try{
- PolicyEngine policyEngine = BRMSGateway.getPolicyEngine();
+ PolicyEngine policyEngine = getPolicyEngine();
if(policyEngine!=null){
ConfigRequestParameters configRequestParameters = new ConfigRequestParameters();
configRequestParameters.setPolicyName(updatedPolicy.getPolicyName());
Collection<PolicyConfig> policyConfigs = policyEngine.getConfig(configRequestParameters);
for(PolicyConfig policyConfig: policyConfigs){
if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
- String name = policyConfig.getPolicyName().substring(policyConfig.getPolicyName().indexOf("_BRMS_")+6, policyConfig.getPolicyName().length());
- name= name.substring(name.indexOf("_")+1,name.length());
- logger.info("Policy Retrieved with this Name notified: " + name);
- bRMSPush.addRule(name,policyConfig.toOther(),policyConfig.getResponseAttributes());
+ logger.info("Policy Retrieved with this Name notified: " + policyConfig.getPolicyName());
+ bRMSPush.addRule(policyConfig.getPolicyName(),policyConfig.toOther(),policyConfig.getResponseAttributes());
}else{
logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Fail to retrieve policy so rule will not be pushed to PolicyRepo !!!!\n\n");
}
@@ -131,4 +126,8 @@ public class BRMSHandler implements BackUpHandler{
bRMSPush.pushRules();
}
}
+
+ public PolicyEngine getPolicyEngine() {
+ return BRMSGateway.getPolicyEngine();
+ }
}