Fix bug for temp-service-delete
[transportpce.git] / servicehandler / src / main / java / org / opendaylight / transportpce / servicehandler / service / RendererServiceWrapper.java
index 0f9d908d8b04678317ac3d7c6d052992f44b8d9e..4bfaa6ebabef0b3d92c591f9a50beded7439bb8b 100644 (file)
@@ -25,8 +25,11 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.serviceha
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.ServiceNotificationTypes;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommon;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.configuration.response.common.ConfigurationResponseCommonBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceAEndBuilder;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.ServiceZEndBuilder;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.TempServiceDeleteInput;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.ServicesBuilder;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeader;
 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.service.handler.header.ServiceHandlerHeaderBuilder;
@@ -72,16 +75,61 @@ public class RendererServiceWrapper {
         }
     }
 
-    public ServiceDeleteOutput performRenderer(TempServiceDeleteInput tempServiceDeleteInput,
-            ServiceNotificationTypes notifType) {
+
+    // TODO: Here is where the  we are sending null values for the service and that is causing issues
+    // We are performing renderer using null values
+    public ServiceDeleteOutput performRenderer(
+            TempServiceDeleteInput tempServiceDeleteInput,
+            ServiceNotificationTypes notifType,
+            org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526
+                    .temp.service.list.Services tempService) {
         String commonId = tempServiceDeleteInput.getCommonId();
-        if (validateParams(commonId, null, true)) {
-            ServiceHandlerHeader serviceHandler = new ServiceHandlerHeaderBuilder().setRequestId(commonId).build();
-            return performRenderer(tempServiceDeleteInput.getCommonId(), serviceHandler,
-                    ServiceNotificationTypes.ServiceDeleteResult, null);
-        } else {
-            return returnRendererFailed();
-        }
+        return validateParams(commonId, null, true)
+            ? performRenderer(tempServiceDeleteInput,
+                new ServiceHandlerHeaderBuilder().setRequestId(commonId).build(),
+                ServiceNotificationTypes.ServiceDeleteResult,
+                tempService)
+            : returnRendererFailed();
+    }
+
+    private ServiceDeleteOutput performRenderer(
+            TempServiceDeleteInput tempServiceDeleteInput,
+            ServiceHandlerHeader serviceHandlerHeader,
+            ServiceNotificationTypes notifType,
+            org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526
+                    .temp.service.list.Services tempService) {
+        String commonId = tempServiceDeleteInput.getCommonId();
+        notification = new ServiceRpcResultShBuilder()
+                .setNotificationType(notifType)
+                .setServiceName(commonId)
+                .setStatus(RpcStatusEx.Pending)
+                .setStatusMessage("Service compliant, submitting temp service delete Request ...")
+                .build();
+        sendNotifications(notification);
+        FutureCallback<ServiceDeleteOutput> rendererCallback =
+                new ServiceDeleteOutputFutureCallback(notifType, commonId);
+        ServiceDeleteInput serviceDeleteInput = createRendererRequestInput(commonId, serviceHandlerHeader);
+        // Here build the regular service-list container from the temp-service-list
+        ListenableFuture<ServiceDeleteOutput> renderer =
+                this.rendererServiceOperations.serviceDelete(serviceDeleteInput,
+                        new ServicesBuilder()
+                                .setServiceName(commonId)
+                                .setServiceAEnd(new ServiceAEndBuilder(tempService.getServiceAEnd()).build())
+                                .setServiceZEnd(new ServiceZEndBuilder(tempService.getServiceZEnd()).build())
+                                .setCommonId(commonId)
+                                .build());
+        Futures.addCallback(renderer, rendererCallback, executor);
+        return new ServiceDeleteOutputBuilder()
+                .setConfigurationResponseCommon(
+                        new ConfigurationResponseCommonBuilder()
+                                .setAckFinalIndicator(ResponseCodes.FINAL_ACK_NO)
+                                .setRequestId(serviceDeleteInput
+                                        .getServiceHandlerHeader()
+                                        .getRequestId())
+                                .setResponseCode(ResponseCodes.RESPONSE_OK)
+                                .setResponseMessage("Renderer temp-service delete in progress")
+                                .build())
+                .build();
     }
 
     private ServiceDeleteOutput performRenderer(String serviceName, ServiceHandlerHeader serviceHandlerHeader,