X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-interactions%2Fmodel-actors%2FactorServiceProvider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontrolloop%2Factorserviceprovider%2Fparameters%2FControlLoopOperationParams.java;h=d0b7c26a8ab47f4b36192c9915e01b7924dbed39;hb=72f4497f573d2b4f2306a99419021b659fb7d21f;hp=f5dd49877b03d8e4a5e787a74599e9bdfcf07180;hpb=00e48acdc51fa2a64b0f7fdc221c28308d7f214d;p=policy%2Fmodels.git diff --git a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java index f5dd49877..d0b7c26a8 100644 --- a/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java +++ b/models-interactions/model-actors/actorServiceProvider/src/main/java/org/onap/policy/controlloop/actorserviceprovider/parameters/ControlLoopOperationParams.java @@ -33,6 +33,7 @@ import lombok.Getter; import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.common.parameters.BeanValidator; import org.onap.policy.common.parameters.annotations.NotNull; +import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.ActorService; import org.onap.policy.controlloop.actorserviceprovider.Operation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; @@ -68,9 +69,13 @@ public class ControlLoopOperationParams { /** * Event for which the operation applies. */ - @NotNull private ControlLoopEventContext context; + /** + * If {@code null}, this value is extracted from the context. + */ + private UUID requestId; + /** * Executor to use to run the operation. */ @@ -175,7 +180,12 @@ public class ControlLoopOperationParams { * @return the event's request ID, or {@code null} if no request ID is available */ public UUID getRequestId() { - return (context == null || context.getEvent() == null ? null : context.getEvent().getRequestId()); + if (requestId == null && context != null && context.getEvent() != null) { + // cache the request ID + requestId = context.getEvent().getRequestId(); + } + + return requestId; } /** @@ -230,6 +240,34 @@ public class ControlLoopOperationParams { * @return the validation result */ public BeanValidationResult validate() { - return new BeanValidator().validateTop(ControlLoopOperationParams.class.getSimpleName(), this); + BeanValidationResult result = + new BeanValidator().validateTop(ControlLoopOperationParams.class.getSimpleName(), this); + + // validate that we have a request ID, or that we can get it from the context's + // event + + if (context == null) { + // no context specified - invoker must provide a request ID then + result.validateNotNull("requestId", requestId); + + } else if (requestId == null) { + // have a context, but no request ID - check the context's event for the + // request ID + BeanValidationResult contextResult = new BeanValidationResult("context", context); + VirtualControlLoopEvent event = context.getEvent(); + contextResult.validateNotNull("event", event); + + if (event != null) { + // cache the request id for later use + BeanValidationResult eventResult = new BeanValidationResult("event", event); + eventResult.validateNotNull("requestId", event.getRequestId()); + + contextResult.addResult(eventResult); + } + + result.addResult(contextResult); + } + + return result; } }