aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.guard/src/main
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-03-23 15:04:46 -0400
committerJim Hahn <jrh3@att.com>2020-03-23 16:03:48 -0400
commit56bc6f68baeb376b99e0dbe4de4790f494dbe3c2 (patch)
tree70e5282b76cbe48aa63bcdd4a88f67c3a4919c44 /models-interactions/model-actors/actor.guard/src/main
parentef5768de060c6cbf10b06569e00617b052dc7e61 (diff)
New Guard actor request structure is incorrect
Missing various fields within the request structure (e.g., ONAPName). Fixed. In the process, also modified makeGuardPayload() so that it only constructs the inner "guard" JSON object, making it easier for invoking code to modify it. Issue-ID: POLICY-2434 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: I7d34a279845bb98425caf66565eab7513d310815
Diffstat (limited to 'models-interactions/model-actors/actor.guard/src/main')
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java31
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java14
-rw-r--r--models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java11
3 files changed, 20 insertions, 36 deletions
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java
index 0e711d1be..7dca3bf37 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardConfig.java
@@ -20,19 +20,18 @@
package org.onap.policy.controlloop.actor.guard;
-import java.util.LinkedHashMap;
-import java.util.Map;
import java.util.concurrent.Executor;
import lombok.Getter;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig;
+import org.onap.policy.models.decisions.concepts.DecisionRequest;
/**
* Configuration for Guard Operators.
*/
public class GuardConfig extends HttpConfig {
- private final Map<String, Object> defaultRequest = new LinkedHashMap<>();
+ private final DecisionRequest defaultRequest = new DecisionRequest();
/**
* {@code True} if the associated guard operation is disabled.
@@ -50,32 +49,20 @@ public class GuardConfig extends HttpConfig {
public GuardConfig(Executor blockingExecutor, GuardParams params, HttpClientFactory clientFactory) {
super(blockingExecutor, params, clientFactory);
- addProperty("ONAPComponent", params.getOnapComponent());
- addProperty("ONAPInstance", params.getOnapInstance());
- addProperty("ONAPName", params.getOnapName());
- addProperty("action", params.getAction());
+ defaultRequest.setOnapComponent(params.getOnapComponent());
+ defaultRequest.setOnapInstance(params.getOnapInstance());
+ defaultRequest.setOnapName(params.getOnapName());
+ defaultRequest.setAction(params.getAction());
this.disabled = params.isDisabled();
}
/**
- * Adds a property to the default request, if the value is not {@code null}.
- *
- * @param key property key
- * @param value property value, or {@code null}
- */
- private void addProperty(String key, String value) {
- if (value != null) {
- defaultRequest.put(key, value);
- }
- }
-
- /**
* Creates a new request, with the default values.
*
- * @return a new request map
+ * @return a new request
*/
- public Map<String, Object> makeRequest() {
- return new LinkedHashMap<>(defaultRequest);
+ public DecisionRequest makeRequest() {
+ return new DecisionRequest(defaultRequest);
}
}
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
index b9dfb9eba..edd2e230d 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java
@@ -31,7 +31,6 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
import org.onap.policy.controlloop.actorserviceprovider.CallbackManager;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
-import org.onap.policy.controlloop.actorserviceprovider.Util;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation;
import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
@@ -109,8 +108,7 @@ public class GuardOperation extends HttpOperation<DecisionResponse> {
protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
outcome.setSubRequestId(String.valueOf(attempt));
- DecisionRequest request = Util.translate(getName(), makeRequest(), DecisionRequest.class);
-
+ DecisionRequest request = makeRequest();
Entity<DecisionRequest> entity = Entity.entity(request, MediaType.APPLICATION_JSON);
Map<String, Object> headers = makeHeaders();
@@ -129,16 +127,16 @@ public class GuardOperation extends HttpOperation<DecisionResponse> {
/**
* Makes a request from the payload.
*
- * @return a new request map
+ * @return a new request
*/
- protected Map<String, Object> makeRequest() {
+ protected DecisionRequest makeRequest() {
if (params.getPayload() == null) {
throw new IllegalArgumentException("missing payload");
}
- Map<String, Object> req = config.makeRequest();
- req.putAll(params.getPayload());
- req.computeIfAbsent("requestId", key -> UUID.randomUUID().toString());
+ DecisionRequest req = config.makeRequest();
+ req.setRequestId(UUID.randomUUID().toString());
+ req.setResource(Map.of("guard", params.getPayload()));
return req;
}
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java
index 5f8360377..959b4d3ef 100644
--- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java
+++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardParams.java
@@ -23,20 +23,19 @@ package org.onap.policy.controlloop.actor.guard;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams;
/**
- * Default values to be included if not specified in the payload.
+ * Guard parameters.
*/
+@NotBlank
+@NotNull
@Data
@EqualsAndHashCode(callSuper = true)
@SuperBuilder(toBuilder = true)
public class GuardParams extends HttpParams {
-
- /*
- * Optional, default values that are used if missing from the payload.
- */
-
private String onapName;
private String onapComponent;
private String onapInstance;