aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-08-13 15:52:22 -0400
committerJim Hahn <jrh3@att.com>2019-08-15 09:21:28 -0400
commitfdaae76549bafb2e482c02fb26de719c69431b48 (patch)
treea3f477da55f80fe7e4bed3d959d8089cf1971438 /controlloop/common/eventmanager/src/main
parent9e8023a455633c7daf0dd291c6268986e39352d7 (diff)
Modify to work with new drools-pdp
Due to sonar fixes, drools-pdp changed in a way that requires changes to drools-applications. In the case of template.demo, lots of test cases had to be modified, so they were refactored to extract common setup and tear down code. Fixed checkstyle issues. Fixed license date. Change-Id: Ie9e0239b95916ae7ef8c1b669987f7bb07d841b9 Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src/main')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java22
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java40
2 files changed, 33 insertions, 29 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 298513619..aaccef60b 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -58,7 +58,7 @@ import org.onap.policy.controlloop.VirtualControlLoopNotification;
import org.onap.policy.controlloop.policy.FinalResult;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.guard.GuardResult;
import org.onap.policy.guard.LockCallback;
import org.onap.policy.guard.PolicyGuard;
@@ -888,9 +888,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
try {
if (vserverName != null) {
- String aaiHostUrl = PolicyEngine.manager.getEnvironmentProperty(AAI_URL);
- String aaiUser = PolicyEngine.manager.getEnvironmentProperty(AAI_USERNAME_PROPERTY);
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty(AAI_PASS_PROPERTY);
+ String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL);
+ String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY);
+ String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY);
String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name=";
String url = aaiHostUrl + aaiGetQueryByVserver;
logger.info("AAI Host URL by VServer: {}", url);
@@ -918,9 +918,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
String vnfName = event.getAai().get(GENERIC_VNF_VNF_NAME);
String vnfId = event.getAai().get(GENERIC_VNF_VNF_ID);
- String aaiHostUrl = PolicyEngine.manager.getEnvironmentProperty(AAI_URL);
- String aaiUser = PolicyEngine.manager.getEnvironmentProperty(AAI_USERNAME_PROPERTY);
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty(AAI_PASS_PROPERTY);
+ String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL);
+ String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY);
+ String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY);
try {
if (vnfName != null) {
@@ -1024,7 +1024,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
* @return the property value
*/
private static String getPeManagerEnvProperty(String enginePropertyName) {
- String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName);
+ String enginePropertyValue = PolicyEngineConstants.getManager().getEnvironmentProperty(enginePropertyName);
if (enginePropertyValue == null) {
throw new IllegalArgumentException("The value of policy engine manager environment property \""
+ enginePropertyName + "\" may not be null");
@@ -1082,9 +1082,9 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
AaiCqResponse response = null;
String vserverId = event.getAai().get(VSERVER_VSERVER_NAME);
- String aaiHostUrl = PolicyEngine.manager.getEnvironmentProperty(AAI_URL);
- String aaiUser = PolicyEngine.manager.getEnvironmentProperty(AAI_USERNAME_PROPERTY);
- String aaiPassword = PolicyEngine.manager.getEnvironmentProperty(AAI_PASS_PROPERTY);
+ String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL);
+ String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY);
+ String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY);
response = new AaiManager(new RestManager()).getCustomQueryResponse(aaiHostUrl, aaiUser, aaiPassword, reqId,
vserverId);
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index cac1b8ee3..293fa43aa 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -52,7 +52,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.database.operationshistory.Dbao;
-import org.onap.policy.drools.system.PolicyEngine;
+import org.onap.policy.drools.system.PolicyEngineConstants;
import org.onap.policy.guard.Util;
import org.onap.policy.sdnc.SdncResponse;
import org.onap.policy.sdnr.PciResponseWrapper;
@@ -141,7 +141,7 @@ public class ControlLoopOperationManager implements Serializable {
* The target vnf-id may not be the same as the source vnf-id specified in the yaml, the target
* vnf-id is retrieved by a named query to A&AI.
*/
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
GenericVnf genvnf = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset)
.getGenericVnfByModelInvariantId(policy.getTarget().getResourceID());
if (genvnf == null) {
@@ -153,9 +153,9 @@ public class ControlLoopOperationManager implements Serializable {
} else {
this.targetEntity =
AppcLcmActorServiceProvider.vnfNamedQuery(policy.getTarget().getResourceID(),
- this.targetEntity, PolicyEngine.manager.getEnvironmentProperty("aai.url"),
- PolicyEngine.manager.getEnvironmentProperty("aai.username"),
- PolicyEngine.manager.getEnvironmentProperty("aai.password"));
+ this.targetEntity, PolicyEngineConstants.getManager().getEnvironmentProperty("aai.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("aai.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("aai.password"));
}
}
}
@@ -260,7 +260,7 @@ public class ControlLoopOperationManager implements Serializable {
*/
try {
String vnfId;
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
vnfId = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset).getDefaultGenericVnf()
.getVnfId();
} else {
@@ -347,7 +347,7 @@ public class ControlLoopOperationManager implements Serializable {
private Object startSoOperation(ControlLoopEvent onset, Operation operation) throws AaiException {
SoActorServiceProvider soActorSp = new SoActorServiceProvider();
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
this.operationRequest =
soActorSp.constructRequestCq((VirtualControlLoopEvent) onset, operation.clOperation,
this.policy, eventManager.getCqResponse((VirtualControlLoopEvent) onset));
@@ -368,16 +368,16 @@ public class ControlLoopOperationManager implements Serializable {
private Object startVfcOperation(ControlLoopEvent onset, Operation operation) throws AaiException {
- if (Boolean.valueOf(PolicyEngine.manager.getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
+ if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) {
this.operationRequest = VfcActorServiceProvider.constructRequestCq((VirtualControlLoopEvent) onset,
operation.clOperation, this.policy,
eventManager.getCqResponse((VirtualControlLoopEvent) onset));
} else {
this.operationRequest = VfcActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset,
operation.clOperation, this.policy, this.eventManager.getVnfResponse(),
- PolicyEngine.manager.getEnvironmentProperty("vfc.url"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.username"),
- PolicyEngine.manager.getEnvironmentProperty("vfc.password"));
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.url"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.username"),
+ PolicyEngineConstants.getManager().getEnvironmentProperty("vfc.password"));
}
this.currentOperation = operation;
if (this.operationRequest == null) {
@@ -951,7 +951,8 @@ public class ControlLoopOperationManager implements Serializable {
private void storeOperationInDataBase() {
// Only store in DB if enabled
- boolean guardEnabled = "false".equalsIgnoreCase(PolicyEngine.manager.getEnvironmentProperty("guard.disabled"));
+ boolean guardEnabled = "false"
+ .equalsIgnoreCase(PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled"));
if (!guardEnabled) {
return;
}
@@ -959,12 +960,15 @@ public class ControlLoopOperationManager implements Serializable {
// DB Properties
Properties props = new Properties();
- if (PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL) != null
- && PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER) != null
- && PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS) != null) {
- props.put(Util.ECLIPSE_LINK_KEY_URL, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_URL));
- props.put(Util.ECLIPSE_LINK_KEY_USER, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_USER));
- props.put(Util.ECLIPSE_LINK_KEY_PASS, PolicyEngine.manager.getEnvironmentProperty(Util.ONAP_KEY_PASS));
+ if (PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_URL) != null
+ && PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_USER) != null
+ && PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_PASS) != null) {
+ props.put(Util.ECLIPSE_LINK_KEY_URL,
+ PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_URL));
+ props.put(Util.ECLIPSE_LINK_KEY_USER,
+ PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_USER));
+ props.put(Util.ECLIPSE_LINK_KEY_PASS,
+ PolicyEngineConstants.getManager().getEnvironmentProperty(Util.ONAP_KEY_PASS));
props.put(PersistenceUnitProperties.CLASSLOADER, ControlLoopOperationManager.class.getClassLoader());
}