X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-interactions%2Fmodel-actors%2Factor.sdnr%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontrolloop%2Factor%2Fsdnr%2FSdnrOperation.java;h=c466963065090424cb142a456f5b6f8711533e53;hb=49f07db935d114b72a44e446867b16262dd552aa;hp=6c8f45d942776ce7b3c2bf6cd45cd92a9413cb7e;hpb=b6bef44f519f1da5d31daf5406a7c57d3d192218;p=policy%2Fmodels.git diff --git a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java index 6c8f45d94..c46696306 100644 --- a/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java +++ b/models-interactions/model-actors/actor.sdnr/src/main/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperation.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * SdnrOperation * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +22,13 @@ package org.onap.policy.controlloop.actor.sdnr; import java.util.List; -import java.util.concurrent.CompletableFuture; -import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; import org.onap.policy.controlloop.actorserviceprovider.topic.SelectorKey; -import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.sdnr.PciBody; import org.onap.policy.sdnr.PciCommonHeader; import org.onap.policy.sdnr.PciMessage; @@ -46,6 +46,8 @@ public class SdnrOperation extends BidirectionalTopicOperation PROPERTY_NAMES = List.of(OperationProperties.EVENT_PAYLOAD); + /** * Keys used to match the response with the request listener. The sub request ID is a * UUID, so it can be used to uniquely identify the response. @@ -57,7 +59,7 @@ public class SdnrOperation extends BidirectionalTopicOperation startPreprocessorAsync() { - return startGuardAsync(); - } - /* * NOTE: This should avoid throwing exceptions, so that a ControlLoopResponse can be * added to the outcome. Consequently, it returns FAILURE if a required field is @@ -87,43 +84,38 @@ public class SdnrOperation extends BidirectionalTopicOperation Status.SUCCESS; + case FAILURE, PARTIAL_FAILURE -> Status.FAILURE; + case ERROR, REJECT -> { logger.warn("SDNR request was not accepted, code={}", code); - return Status.FAILURE; - case ACCEPTED: - default: + yield Status.FAILURE; + } + default -> // awaiting a "final" response - return Status.STILL_WAITING; - } + Status.STILL_WAITING; + }; } /** * Sets the message to the status description, if available. */ @Override - public OperationOutcome setOutcome(OperationOutcome outcome, PolicyResult result, PciMessage responseWrapper) { + public OperationOutcome setOutcome(OperationOutcome outcome, OperationResult result, PciMessage responseWrapper) { outcome.setResponse(responseWrapper); if (responseWrapper.getBody() == null || responseWrapper.getBody().getOutput() == null) { return setOutcome(outcome, result); } - PciResponse pciResponse = responseWrapper.getBody().getOutput(); + var pciResponse = responseWrapper.getBody().getOutput(); if (pciResponse.getStatus() == null || pciResponse.getStatus().getValue() == null) { return setOutcome(outcome, result); } @@ -135,37 +127,36 @@ public class SdnrOperation extends BidirectionalTopicOperation