diff options
author | 2020-08-18 09:39:19 -0400 | |
---|---|---|
committer | 2020-08-18 17:11:52 -0400 | |
commit | 8722cb8a654ddcdcb472546a58809e041fe84eba (patch) | |
tree | eba3aee017377733f6a44840a58fc322f7e4f807 /models-interactions/model-actors/actor.aai/src/main/java/org | |
parent | ca3827f43ada2b160f6966d205ca97d4402a0935 (diff) |
Make targetEntity a property
The target entity is not always known when an Operation is first
constructed, thus it should be treated as an Operation property instead
of being included within the ControlLoopParams. Started the process of
moving it from the Params to the properties.
Also fixed a bug in custom query - it was setting the outcome response
to the String response instead of setting it to the AaiCqResponse
object.
Also added logging when an Operation's properties are set.
Issue-ID: POLICY-2746
Change-Id: I56c0cd90985f6140363548b0b8d031471b586e88
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.aai/src/main/java/org')
4 files changed, 22 insertions, 5 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 388959ddf..54801358c 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 @@ -40,6 +40,7 @@ import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; +import org.onap.policy.controlloop.policy.PolicyResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -186,6 +187,19 @@ public class AaiCustomQueryOperation extends HttpOperation<String> { return AaiUtil.makeHeaders(params); } + @Override + public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, Response rawResponse, + String response) { + + super.setOutcome(outcome, result, rawResponse, response); + + if (response != null) { + outcome.setResponse(new AaiCqResponse(response)); + } + + return outcome; + } + /** * Injects the response into the context. */ 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 c91e2a0d6..3fb978d88 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 @@ -20,7 +20,7 @@ package org.onap.policy.controlloop.actor.aai; -import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.CompletableFuture; @@ -29,6 +29,7 @@ import javax.ws.rs.client.WebTarget; import javax.ws.rs.core.Response; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; @@ -45,6 +46,8 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> { public static final int DEFAULT_RETRY = 3; + private static final List<String> PROPERTY_NAMES = List.of(OperationProperties.AAI_TARGET_ENTITY); + /** * Responses that are retrieved from A&AI are placed in the operation context under @@ -59,7 +62,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> { * @param config configuration for this operation */ public AaiGetOperation(ControlLoopOperationParams params, HttpConfig config) { - super(params, config, StandardCoderObject.class, Collections.emptyList()); + super(params, config, StandardCoderObject.class, PROPERTY_NAMES); this.propertyPrefix = getFullName() + "."; } @@ -110,9 +113,9 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> { @Override protected CompletableFuture<OperationOutcome> postProcessResponse(OperationOutcome outcome, String url, Response rawResponse, StandardCoderObject response) { - String entity = params.getTargetEntity(); if (params.getContext() != null) { + String entity = getTargetEntity(); logger.info("{}: caching response of {} for {}", getFullName(), entity, params.getRequestId()); params.getContext().setProperty(propertyPrefix + entity, response); } diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java index fbf40967c..d89d8350a 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetPnfOperation.java @@ -74,7 +74,7 @@ public class AaiGetPnfOperation extends AaiGetOperation { StringBuilder str = new StringBuilder(getClient().getBaseUrl()); - String path = getPath() + URI_SEP + URLEncoder.encode(params.getTargetEntity(), StandardCharsets.UTF_8); + String path = getPath() + URI_SEP + URLEncoder.encode(getTargetEntity(), StandardCharsets.UTF_8); WebTarget web = getClient().getWebTarget().path(path); str.append(path); diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java index cbd179189..fe1179833 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetTenantOperation.java @@ -76,7 +76,7 @@ public class AaiGetTenantOperation extends AaiGetOperation { str.append(path); web = addQuery(web, str, "?", "search-node-type", "vserver"); - web = addQuery(web, str, "&", "filter", "vserver-name:EQUALS:" + params.getTargetEntity()); + web = addQuery(web, str, "&", "filter", "vserver-name:EQUALS:" + getTargetEntity()); Builder webldr = web.request(); addHeaders(webldr, headers); |