summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.appclcm/src/main
diff options
context:
space:
mode:
authorDaniel Cruz <dc443y@att.com>2019-10-23 17:33:28 -0500
committerDaniel Cruz <dc443y@att.com>2019-10-25 10:14:01 -0500
commitfb601b21a0b0c530c333b3e270285c804a99f3bb (patch)
tree5abc9cd6a414d2d3f03f90da1965c49f6680f6ce /models-interactions/model-actors/actor.appclcm/src/main
parent5f69582dfaf325a8552ebeaa7cd69f81bc7d478f (diff)
Refactor Appc LCM Model
Added model classes for APPC LCM Input and APPC LCM Output and removed adding the input/output tag to the JSON via the APPC LCM custom serializer. Issue-ID: POLICY-2043 Signed-off-by: Daniel Cruz <dc443y@att.com> Change-Id: I54e1b5f589a4b29357cf1a45dbdf2173610870ce
Diffstat (limited to 'models-interactions/model-actors/actor.appclcm/src/main')
-rw-r--r--models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java54
1 files changed, 34 insertions, 20 deletions
diff --git a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
index 21cce2fd6..447a2720d 100644
--- a/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
@@ -39,12 +39,12 @@ import org.onap.policy.aai.AaiNqQueryParameters;
import org.onap.policy.aai.AaiNqRequest;
import org.onap.policy.aai.AaiNqResponse;
import org.onap.policy.aai.util.AaiException;
-import org.onap.policy.appclcm.LcmCommonHeader;
-import org.onap.policy.appclcm.LcmRequest;
-import org.onap.policy.appclcm.LcmRequestWrapper;
-import org.onap.policy.appclcm.LcmResponse;
-import org.onap.policy.appclcm.LcmResponseCode;
-import org.onap.policy.appclcm.LcmResponseWrapper;
+import org.onap.policy.appclcm.AppcLcmBody;
+import org.onap.policy.appclcm.AppcLcmCommonHeader;
+import org.onap.policy.appclcm.AppcLcmDmaapWrapper;
+import org.onap.policy.appclcm.AppcLcmInput;
+import org.onap.policy.appclcm.AppcLcmOutput;
+import org.onap.policy.appclcm.AppcLcmResponseCode;
import org.onap.policy.controlloop.ControlLoopOperation;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
@@ -186,7 +186,7 @@ public class AppcLcmActorServiceProvider implements Actor {
* Policy GUI/API
* @return an APPC request conforming to the lcm API using the DMAAP wrapper
*/
- public static LcmRequestWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
+ public static AppcLcmDmaapWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
Policy policy, String targetVnf) {
/* Construct an APPC request using LCM Model */
@@ -197,17 +197,17 @@ public class AppcLcmActorServiceProvider implements Actor {
*/
AppcLcmRecipeFormatter lcmRecipeFormatter = new AppcLcmRecipeFormatter(policy.getRecipe());
- LcmRequestWrapper dmaapRequest = new LcmRequestWrapper();
+ AppcLcmDmaapWrapper dmaapRequest = new AppcLcmDmaapWrapper();
dmaapRequest.setVersion("2.0");
dmaapRequest.setCorrelationId(onset.getRequestId() + "-" + operation.getSubRequestId());
dmaapRequest.setRpcName(lcmRecipeFormatter.getUrlRecipe());
dmaapRequest.setType("request");
/* This is the actual request that is placed in the dmaap wrapper. */
- final LcmRequest appcRequest = new LcmRequest();
+ final AppcLcmInput appcRequest = new AppcLcmInput();
/* The common header is a required field for all APPC requests. */
- LcmCommonHeader requestCommonHeader = new LcmCommonHeader();
+ AppcLcmCommonHeader requestCommonHeader = new AppcLcmCommonHeader();
requestCommonHeader.setOriginatorId(onset.getRequestId().toString());
requestCommonHeader.setRequestId(onset.getRequestId());
requestCommonHeader.setSubRequestId(operation.getSubRequestId());
@@ -241,9 +241,15 @@ public class AppcLcmActorServiceProvider implements Actor {
}
/*
+ * The APPC request must be wrapped in an input object.
+ */
+ AppcLcmBody body = new AppcLcmBody();
+ body.setInput(appcRequest);
+
+ /*
* Once the LCM request is constructed, add it into the body of the dmaap wrapper.
*/
- dmaapRequest.setBody(appcRequest);
+ dmaapRequest.setBody(body);
/* Return the request to be sent through dmaap. */
return dmaapRequest;
@@ -293,9 +299,17 @@ public class AppcLcmActorServiceProvider implements Actor {
*
* @return an key-value pair that contains the Policy result and APPC response message
*/
- public static SimpleEntry<PolicyResult, String> processResponse(LcmResponseWrapper dmaapResponse) {
- /* The actual APPC response is inside the wrapper's body field. */
- LcmResponse appcResponse = dmaapResponse.getBody();
+ public static SimpleEntry<PolicyResult, String> processResponse(AppcLcmDmaapWrapper dmaapResponse) {
+ AppcLcmBody appcBody = dmaapResponse.getBody();
+ if (appcBody == null) {
+ throw new NullPointerException("APPC Body is null");
+ }
+
+ /* The actual APPC response is inside the dmaap wrapper's body.input field. */
+ AppcLcmOutput appcResponse = appcBody.getOutput();
+ if (appcResponse == null) {
+ throw new NullPointerException("APPC Response is null");
+ }
/* The message returned in the APPC response. */
String message;
@@ -310,7 +324,7 @@ public class AppcLcmActorServiceProvider implements Actor {
}
/* If there is no code, Policy cannot determine if the request was successful. */
- String responseValue = LcmResponseCode.toResponseValue(appcResponse.getStatus().getCode());
+ String responseValue = AppcLcmResponseCode.toResponseValue(appcResponse.getStatus().getCode());
if (responseValue == null) {
message = "Policy was unable to parse APP-C response status code field.";
return new AbstractMap.SimpleEntry<>(PolicyResult.FAILURE_EXCEPTION, message);
@@ -321,18 +335,18 @@ public class AppcLcmActorServiceProvider implements Actor {
/* Maps the APPC response result to a Policy result. */
switch (responseValue) {
- case LcmResponseCode.ACCEPTED:
+ case AppcLcmResponseCode.ACCEPTED:
/* Nothing to do if code is accept, continue processing */
result = null;
break;
- case LcmResponseCode.SUCCESS:
+ case AppcLcmResponseCode.SUCCESS:
result = PolicyResult.SUCCESS;
break;
- case LcmResponseCode.FAILURE:
+ case AppcLcmResponseCode.FAILURE:
result = PolicyResult.FAILURE;
break;
- case LcmResponseCode.REJECT:
- case LcmResponseCode.ERROR:
+ case AppcLcmResponseCode.REJECT:
+ case AppcLcmResponseCode.ERROR:
default:
result = PolicyResult.FAILURE_EXCEPTION;
}