diff options
author | Jim Hahn <jrh3@att.com> | 2020-02-20 19:08:55 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-02-21 20:33:06 -0500 |
commit | 7f69c5ca0a6f6018166f8fee3e811edf4dee1eb8 (patch) | |
tree | e57ab3105adbe0752b30e0e0a60ea43588cfb384 /models-interactions/model-actors/actor.guard/src/main | |
parent | 3c8c5b2994e3f132385f0341283bc271e13cdb25 (diff) |
Change payload to Map<String,Object> so it's more versatile
This was supposed to be two separate commits, but I goofed something.
Added guard query to Operation superclass. Modified VfModuleCreate
to store the VF count, pass it to the guard, and bump it once the
create completes successfully.
Added code to check Actors for proper plug-in to ActorService.
Renamed "operation" property to "operations", to be more consistent
with other parameters (e.g., TopicParameterGroup).
The META-INF/services files for the actors had mixed case, which
did not match the package name of the Actor class, preventing the
ServiceLoader from recognizing them. Also modified the ActorService
to skip any that cannot actually be loaded, for whatever reason
(e.g., not in the classpath).
Issue-ID: POLICY-1625
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: Ifa97744543f2866cc553138ec5ec644b033de780
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/GuardActorServiceProvider.java | 3 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardOperation.java | 37 | ||||
-rw-r--r-- | models-interactions/model-actors/actor.guard/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor (renamed from models-interactions/model-actors/actor.guard/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor) | 0 |
3 files changed, 5 insertions, 35 deletions
diff --git a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java index ea08d13da..e37de57bb 100644 --- a/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java +++ b/models-interactions/model-actors/actor.guard/src/main/java/org/onap/policy/controlloop/actor/guard/GuardActorServiceProvider.java @@ -24,10 +24,11 @@ package org.onap.policy.controlloop.actor.guard; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpActor; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator; +import org.onap.policy.controlloop.actorserviceprovider.impl.OperationPartial; public class GuardActorServiceProvider extends HttpActor<GuardActorParams> { // actor name - public static final String NAME = "GUARD"; + public static final String NAME = OperationPartial.GUARD_ACTOR_NAME; /** * Constructs the object. 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 453a3e377..a5459f660 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 @@ -20,9 +20,7 @@ package org.onap.policy.controlloop.actor.guard; -import java.util.LinkedHashMap; import java.util.Map; -import java.util.Map.Entry; import java.util.UUID; import java.util.concurrent.CompletableFuture; import javax.ws.rs.client.Entity; @@ -33,13 +31,12 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; 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; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Guard Operation. The outcome message is set to the guard response. If the guard is @@ -57,17 +54,14 @@ import org.slf4j.LoggerFactory; * </dl> */ public class GuardOperation extends HttpOperation<DecisionResponse> { - private static final Logger logger = LoggerFactory.getLogger(GuardOperation.class); // operation name - public static final String NAME = "Decision"; + public static final String NAME = OperationPartial.GUARD_OPERATION_NAME; public static final String PERMIT = "Permit"; public static final String DENY = "Deny"; public static final String INDETERMINATE = "Indeterminate"; - private static final String RESOURCE = "resource"; - /** * Prefix for properties in the payload that should be copied to the "resource" field * of the request. @@ -118,34 +112,9 @@ public class GuardOperation extends HttpOperation<DecisionResponse> { throw new IllegalArgumentException("missing payload"); } - /* - * This code could be easily modified to allow the context and/or resource to be - * an encoded JSON string, that is decoded into a Map and stuffed into the - * appropriate field. - */ - Map<String, Object> req = config.makeRequest(); - Map<String, Object> resource = new LinkedHashMap<>(); - - for (Entry<String, String> ent : params.getPayload().entrySet()) { - String key = ent.getKey(); - - if (key.startsWith(RESOURCE_PREFIX)) { - // it's a resource property - put into the resource map - key = key.substring(RESOURCE_PREFIX.length()); - resource.put(key, ent.getValue()); - - } else if (key.indexOf('.') < 0) { - // it's a normal property - put into the request map - req.put(key, ent.getValue()); - - } else { - logger.warn("{}: unused key {} in payload for {}", getFullName(), key, params.getRequestId()); - } - } - + req.putAll(params.getPayload()); req.computeIfAbsent("requestId", key -> UUID.randomUUID().toString()); - req.put(RESOURCE, resource); return req; } diff --git a/models-interactions/model-actors/actor.guard/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor b/models-interactions/model-actors/actor.guard/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor index dd4368504..dd4368504 100644 --- a/models-interactions/model-actors/actor.guard/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorServiceProvider.spi.Actor +++ b/models-interactions/model-actors/actor.guard/src/main/resources/META-INF/services/org.onap.policy.controlloop.actorserviceprovider.spi.Actor |