diff options
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.java | 57 |
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; - } } |