aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-impl/sdnc/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-05 21:07:07 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-08 10:42:22 -0400
commitada55be1b59899e461dc5177782e381f89cbc407 (patch)
tree7bdb3eb5fe44e166a75a3333bf81f2293a3585de /models-interactions/model-impl/sdnc/src/main/java
parenteb7127ac85b3df30a09277721a5f9271033843e7 (diff)
Remove drools PDP dependency
Removing working memory and use of PolicyEngine from drools in these classes. Cleaned up some unused imports and checkstyle. Issue-ID: POLICY-1264 Change-Id: Id059da9689a721b0eafc6b310adcbdad43574ce7 Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'models-interactions/model-impl/sdnc/src/main/java')
-rw-r--r--models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java57
1 files changed, 23 insertions, 34 deletions
diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java
index 864ddf506..3679625ec 100644
--- a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java
+++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java
@@ -22,17 +22,14 @@
package org.onap.policy.sdnc;
-
import com.google.gson.JsonSyntaxException;
import java.util.HashMap;
import java.util.Map;
-import org.drools.core.WorkingMemory;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
-import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.rest.RestManager;
import org.onap.policy.rest.RestManager.Pair;
import org.onap.policy.sdnc.util.Serialization;
@@ -46,31 +43,41 @@ public final class SdncManager implements Runnable {
private String username;
private String password;
private SdncRequest sdncRequest;
- private WorkingMemory workingMem;
+ private SdncCallback callback;
private static final Logger logger = LoggerFactory.getLogger(SdncManager.class);
// The REST manager used for processing REST calls for this Sdnc manager
private RestManager restManager;
+ public interface SdncCallback {
+ public void onCallback(SdncResponse response);
+ }
+
/**
* Constructor.
*
- * @param wm Drools working memory
+ * @param cb Callback method
* @param request request
*/
- public SdncManager(WorkingMemory wm, SdncRequest request) {
- if (wm == null || request == null) {
+ public SdncManager(SdncCallback cb, SdncRequest request, String url,
+ String user, String password) {
+ if (cb == null || request == null) {
throw new IllegalArgumentException(
- "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null"
+ "the parameters \"callback\" and \"request\" on the SdncManager constructor may not be null"
);
}
- workingMem = wm;
- sdncRequest = request;
+ this.callback = cb;
+ this.sdncRequest = request;
+ if (url == null) {
+ throw new IllegalArgumentException(
+ "the \"url\" parameter on the SdncManager constructor may not be null"
+ );
+ }
+ this.sdncUrlBase = url;
+ this.username = user;
+ this.password = password;
restManager = new RestManager();
-
- setSdncParams(getPeManagerEnvProperty("sdnc.url"), getPeManagerEnvProperty("sdnc.username"),
- getPeManagerEnvProperty("sdnc.password"));
}
/**
@@ -108,12 +115,12 @@ public final class SdncManager implements Runnable {
sdncRequestJson);
} catch (Exception e) {
logger.info(e.getMessage(), e);
- workingMem.insert(responseError);
+ this.callback.onCallback(responseError);
return;
}
if (httpDetails == null) {
- workingMem.insert(responseError);
+ this.callback.onCallback(responseError);
return;
}
@@ -132,7 +139,7 @@ public final class SdncManager implements Runnable {
);
}
- workingMem.insert(response);
+ this.callback.onCallback(response);
} catch (JsonSyntaxException e) {
logger.info("Failed to deserialize into SdncResponse {}", e.getLocalizedMessage(), e);
} catch (Exception e) {
@@ -147,22 +154,4 @@ public final class SdncManager implements Runnable {
protected void setRestManager(final RestManager restManager) {
this.restManager = restManager;
}
-
- /**
- * This method reads and validates environmental properties coming from the policy engine. Null properties cause
- * an {@link IllegalArgumentException} runtime exception to be thrown
- * @param enginePropertyName name of the parameter to retrieve
- * @return the property value
- */
-
- private String getPeManagerEnvProperty(String enginePropertyName) {
- String enginePropertyValue = PolicyEngine.manager.getEnvironmentProperty(enginePropertyName);
- if (enginePropertyValue == null) {
- throw new IllegalArgumentException(
- "The value of policy engine manager environment property \""
- + enginePropertyName + "\" may not be null"
- );
- }
- return enginePropertyValue;
- }
}