Refactor SH Renderer Listener notification support 80/106380/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 5 Jun 2023 07:52:05 +0000 (09:52 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 5 Jun 2023 07:52:49 +0000 (09:52 +0200)
JIRA: TRNSPRTPCE-743
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: If374613970639bdf15af2b55d334cc38bd3e5670

servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java

index e2e648cc2e15665800a14f7e57999aefbfdf684e..5ded8540ec39b00527bd865f44237f7c6e697b05 100644 (file)
@@ -172,45 +172,48 @@ public class RendererListenerImpl implements TransportpceRendererListener, Rende
             LOG.debug("serviceDataStoreOperations is null");
             return;
         }
-
         updateOtnTopology(notification, false);
-        PublishNotificationProcessServiceBuilder nbiNotificationBuilder = new PublishNotificationProcessServiceBuilder()
+        PublishNotificationProcessServiceBuilder nbiNotificationBuilder =
+            new PublishNotificationProcessServiceBuilder()
                 .setServiceName(input.getServiceName())
                 .setServiceAEnd(new ServiceAEndBuilder(input.getServiceAEnd()).build())
                 .setServiceZEnd(new ServiceZEndBuilder(input.getServiceZEnd()).build())
                 .setCommonId(input.getCommonId()).setConnectionType(input.getConnectionType())
                 .setPublisherName(PUBLISHER);
-        OperationResult operationResult;
         String serviceTemp = "";
         if (tempService) {
-            operationResult = this.serviceDataStoreOperations.modifyTempService(
+            OperationResult operationResult = this.serviceDataStoreOperations.modifyTempService(
                     serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
             serviceTemp = "Temp ";
-            LOG.info("Sending notification to the service-RPC-result");
+            if (operationResult.isSuccess()) {
+                sendNbiNotification(nbiNotificationBuilder
+                    .setResponseFailed("")
+                    .setMessage("Temp Service implemented !")
+                    .setOperationalState(State.InService)
+                    .build());
+                LOG.debug("For the Temp service, sending notification on service-result-rpc");
+                sendServiceRpcResultNotification(notification, ServiceNotificationTypes.ServiceCreateResult);
+                return;
+            }
         } else {
-            operationResult = this.serviceDataStoreOperations.modifyService(
+            OperationResult operationResult = this.serviceDataStoreOperations.modifyService(
                     serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService);
-        }
-        if (operationResult.isSuccess()) {
-            sendNbiNotification(nbiNotificationBuilder
+            if (operationResult.isSuccess()) {
+                sendNbiNotification(nbiNotificationBuilder
                     .setResponseFailed("")
                     .setMessage("Service implemented !")
                     .setOperationalState(State.InService)
                     .build());
-            if (!tempService) {
                 sendServiceHandlerNotification(notification, ServiceNotificationTypes.ServiceCreateResult);
-            } else {
-                LOG.info("For the Temp service, sending notification on service-result-rpc");
-                sendServiceRpcResultNotification(notification, ServiceNotificationTypes.ServiceCreateResult);
+                return;
             }
-        } else {
-            LOG.warn("{}Service status not updated in datastore !", serviceTemp);
-            sendNbiNotification(nbiNotificationBuilder
-                    .setResponseFailed(serviceTemp + "Service status not updated in datastore !")
-                    .setMessage("ServiceCreate request failed ...")
-                    .setOperationalState(State.OutOfService)
-                    .build());
         }
+        LOG.warn("{}Service status not updated in datastore !", serviceTemp);
+        sendNbiNotification(nbiNotificationBuilder
+            .setResponseFailed(serviceTemp + "Service status not updated in datastore !")
+            .setMessage("ServiceCreate request failed ...")
+            .setOperationalState(State.OutOfService)
+            .build());
     }
 
     /**