aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-02-18 08:13:45 -0500
committerJim Hahn <jrh3@att.com>2020-02-18 12:51:37 -0500
commitef562e809d00aea6fbdaf845b7dd1ada26f40e22 (patch)
treecf853dad82697813ed4ef639af918109f61b6095
parent1bb549251599ce7866e1143158a68b5f259d22b1 (diff)
Actor updates to support SO
Used SuperBuilder in operation Params classes. Added rawResponse to http setOutcome(). Made HttpOperation.operator private. Issue-ID: POLICY-2371 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ie894f2e6ae4a31b69a700e425f9e94c5e8a15daa
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java2
-rw-r--r--models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java4
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java2
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java19
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java13
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParams.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParams.java4
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java5
-rw-r--r--models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java2
9 files changed, 34 insertions, 21 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
index e32734b7d..427701505 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java
@@ -91,7 +91,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> {
// @formatter:off
return handleResponse(outcome, url,
- callback -> operator.getClient().put(callback, makePath(), entity, headers));
+ callback -> getOperator().getClient().put(callback, makePath(), entity, headers));
// @formatter:on
}
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
index ee1c4612d..dd3a4d6c0 100644
--- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
+++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java
@@ -98,7 +98,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> {
// @formatter:off
return handleResponse(outcome, url,
- callback -> operator.getClient().get(callback, makePath(), headers));
+ callback -> getOperator().getClient().get(callback, makePath(), headers));
// @formatter:on
}
@@ -109,7 +109,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> {
@Override
public String makePath() {
- return (operator.getPath() + "/" + params.getTargetEntity());
+ return (getOperator().getPath() + "/" + params.getTargetEntity());
}
/**
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
index 406722ef5..f6cacd97b 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncOperation.java
@@ -73,7 +73,7 @@ public abstract class SdncOperation extends HttpOperation<SdncResponse> {
// @formatter:off
return handleResponse(outcome, url,
- callback -> operator.getClient().post(callback, makePath(), entity, headers));
+ callback -> getOperator().getClient().post(callback, makePath(), entity, headers));
// @formatter:on
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
index a743f49c0..51d14a2c0 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActorServiceProvider.java
@@ -54,12 +54,13 @@ import org.slf4j.LoggerFactory;
public class SoActorServiceProvider extends ActorImpl {
private static final Logger logger = LoggerFactory.getLogger(SoActorServiceProvider.class);
+ public static final String NAME = "SO";
+
+ // TODO old code: remove lines down to **HERE**
+
private static final String TENANT_NOT_FOUND = "Tenant Item not found in AAI response {}";
private static final String CONSTRUCTED_SO_MSG = "Constructed SO request: {}";
- // Strings for SO Actor
- private static final String SO_ACTOR = "SO";
-
// Strings for targets
private static final String TARGET_VFC = "VFC";
@@ -89,13 +90,17 @@ public class SoActorServiceProvider extends ActorImpl {
private static String lastServiceItemServiceInstanceId;
private static String lastVfModuleItemVfModuleInstanceId;
+ // **HERE**
+
public SoActorServiceProvider() {
- super(SO_ACTOR);
+ super(NAME);
}
+ // TODO old code: remove lines down to **HERE**
+
@Override
public String actor() {
- return SO_ACTOR;
+ return NAME;
}
@Override
@@ -237,7 +242,7 @@ public class SoActorServiceProvider extends ActorImpl {
*/
public SoRequest constructRequestCq(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy,
AaiCqResponse aaiCqResponse) {
- if (!SO_ACTOR.equals(policy.getActor()) || !recipes().contains(policy.getRecipe())) {
+ if (!NAME.equals(policy.getActor()) || !recipes().contains(policy.getRecipe())) {
return null;
}
@@ -444,4 +449,6 @@ public class SoActorServiceProvider extends ActorImpl {
return cloudConfiguration;
}
+ // **HERE**
+
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
index c3c0f6dc2..da4887e15 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/impl/HttpOperation.java
@@ -54,7 +54,7 @@ public abstract class HttpOperation<T> extends OperationPartial {
/**
* Operator that created this operation.
*/
- protected final HttpOperator operator;
+ private final HttpOperator operator;
/**
* Response class.
@@ -188,11 +188,11 @@ public abstract class HttpOperation<T> extends OperationPartial {
if (!isSuccess(rawResponse, response)) {
logger.info("{}.{} request failed with http error code {} for {}", params.getActor(), params.getOperation(),
rawResponse.getStatus(), params.getRequestId());
- return CompletableFuture.completedFuture(setOutcome(outcome, PolicyResult.FAILURE, response));
+ return CompletableFuture.completedFuture(setOutcome(outcome, PolicyResult.FAILURE, rawResponse, response));
}
logger.info("{}.{} request succeeded for {}", params.getActor(), params.getOperation(), params.getRequestId());
- setOutcome(outcome, PolicyResult.SUCCESS, response);
+ setOutcome(outcome, PolicyResult.SUCCESS, rawResponse, response);
return postProcessResponse(outcome, url, rawResponse, response);
}
@@ -201,10 +201,13 @@ public abstract class HttpOperation<T> extends OperationPartial {
*
* @param outcome operation to be updated
* @param result result of the operation
- * @param response response used to populate the outcome
+ * @param rawResponse raw response
+ * @param response decoded response
* @return the updated operation
*/
- public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, T response) {
+ public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse,
+ T response) {
+
return setOutcome(outcome, result);
}
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParams.java
index cafca1fa6..d1d3faf1a 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParams.java
@@ -20,8 +20,8 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
-import lombok.Builder;
import lombok.Data;
+import lombok.experimental.SuperBuilder;
import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.annotations.Min;
@@ -34,7 +34,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotNull
@NotBlank
@Data
-@Builder(toBuilder = true)
+@SuperBuilder(toBuilder = true)
public class BidirectionalTopicParams {
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParams.java
index 2d3ab8b54..57270ac65 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParams.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParams.java
@@ -20,8 +20,8 @@
package org.onap.policy.controlloop.actorserviceprovider.parameters;
-import lombok.Builder;
import lombok.Data;
+import lombok.experimental.SuperBuilder;
import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.annotations.Min;
@@ -34,7 +34,7 @@ import org.onap.policy.common.parameters.annotations.NotNull;
@NotNull
@NotBlank
@Data
-@Builder(toBuilder = true)
+@SuperBuilder(toBuilder = true)
public class HttpParams {
/**
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java
index 7e44fa2e1..0ec0bb57c 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/BidirectionalTopicParamsTest.java
@@ -67,8 +67,11 @@ public class BidirectionalTopicParamsTest {
assertEquals(params, params.toBuilder().build());
}
+ // @formatter:off
private void testValidateField(String fieldName, String expected,
- Function<BidirectionalTopicParamsBuilder, BidirectionalTopicParamsBuilder> makeInvalid) {
+ @SuppressWarnings("rawtypes") Function<BidirectionalTopicParamsBuilder, BidirectionalTopicParamsBuilder>
+ makeInvalid) {
+ // @formatter:on
// original params should be valid
ValidationResult result = params.validate(CONTAINER);
diff --git a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java
index fdfb4b495..8d4d44685 100644
--- a/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java
+++ b/models-interactions/model-actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/parameters/HttpParamsTest.java
@@ -68,7 +68,7 @@ public class HttpParamsTest {
}
private void testValidateField(String fieldName, String expected,
- Function<HttpParamsBuilder, HttpParamsBuilder> makeInvalid) {
+ @SuppressWarnings("rawtypes") Function<HttpParamsBuilder, HttpParamsBuilder> makeInvalid) {
// original params should be valid
ValidationResult result = params.validate(CONTAINER);