Add fix for guard db on disable 89/17389/2
authorTemoc Rodriguez <cr056n@att.com>
Fri, 6 Oct 2017 14:57:02 +0000 (07:57 -0700)
committerTemoc Rodriguez <cr056n@att.com>
Fri, 6 Oct 2017 14:57:02 +0000 (07:57 -0700)
Added a fix so that the guard database is not attempted to be accessed
while guard is set to disabled. The guard db access is done in the
operations manager which has no context of guardat the moment. Because
of this separation, the boolean must be grabbed from the PolicyEngine
properties. We should consider some guard refactoring.

Issue-ID: POLICY-296
Change-Id: Ida7a2a7c19e568b076731e0f04bdc8a9fd0fcb26
Signed-off-by: Temoc Rodriguez <cr056n@att.com>
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java

index 6e57b5e..89b702d 100644 (file)
@@ -44,6 +44,7 @@ import org.onap.policy.controlloop.actor.vfc.VFCActorServiceProvider;
 import org.onap.policy.controlloop.policy.Policy;
 import org.onap.policy.controlloop.policy.PolicyResult;
 import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
+import org.onap.policy.drools.system.PolicyEngine;
 import org.onap.policy.so.SOResponse;
 import org.onap.policy.vfc.VFCResponse;
 import org.slf4j.Logger;
@@ -541,6 +542,12 @@ public class ControlLoopOperationManager implements Serializable {
        }
 
        private void    storeOperationInDataBase(){
+               // Only store in DB if enabled
+               boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngine.manager.getEnvironmentProperty("guard.disabled"));
+               if( !guardEnabled ){
+                       return;
+               }
+
 
                // DB Properties
                Properties props = new Properties();