Update transportpce-common-types model
[transportpce.git] / renderer / src / main / java / org / opendaylight / transportpce / renderer / provisiondevice / tasks / DeviceRenderingTask.java
index a997336c67c58707e67ba5f746181d611ed4cc6c..6a30f950d7f00efc5d24eb19c638e32a57b364b5 100644 (file)
@@ -14,8 +14,8 @@ import org.opendaylight.transportpce.renderer.ServicePathInputData;
 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
 import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRenderingResult;
 import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev210618.ServicePathOutput;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210618.optical.renderer.nodes.Nodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePathOutput;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.optical.renderer.nodes.Nodes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -37,30 +37,30 @@ public class DeviceRenderingTask implements Callable<DeviceRenderingResult> {
     @Override
     public DeviceRenderingResult call() throws Exception {
         ServicePathOutput output;
+        String operation;
+        List<Nodes> olmList = null;
         switch (this.servicePathInputData.getServicePathInput().getOperation()) {
             case Create:
+                operation = "setup";
                 output = this.deviceRenderer.setupServicePath(this.servicePathInputData.getServicePathInput(),
                     this.direction);
-                if (!output.getSuccess()) {
-                    LOG.error("Device rendering setup service path failed.");
-                    return DeviceRenderingResult.failed("Operation Failed");
-                }
-                List<Nodes> olmList = this.servicePathInputData.getNodeLists().getOlmNodeList();
-                LOG.info("Device rendering setup service path finished successfully.");
-                return DeviceRenderingResult.ok(olmList, new ArrayList<>(output.nonnullNodeInterface().values()),
-                    new ArrayList<>(output.nonnullLinkTp()));
+                olmList = this.servicePathInputData.getNodeLists().getOlmNodeList();
+                break;
             case Delete:
+                operation = "delete";
                 output = this.deviceRenderer.deleteServicePath(this.servicePathInputData.getServicePathInput());
-                if (!output.getSuccess()) {
-                    LOG.error("Device rendering delete service path failed.");
-                    return DeviceRenderingResult.failed("Operation Failed");
-                }
-                LOG.info("Device rendering delete service path finished successfully.");
-                return DeviceRenderingResult.ok(null, new ArrayList<>(output.nonnullNodeInterface().values()),
-                    new ArrayList<>(output.nonnullLinkTp()));
+                break;
             default:
-                return DeviceRenderingResult.failed("Device rendering failed - unknwon operation");
+                return DeviceRenderingResult.failed("Device rendering failed - unknown operation");
         }
+        if (!output.getSuccess()) {
+            LOG.error("Device rendering {} service path failed.", operation);
+            return DeviceRenderingResult.failed("Operation Failed");
+        }
+        LOG.info("Device rendering {} service path finished successfully.", operation);
+        return DeviceRenderingResult.ok(olmList, new ArrayList<>(output.nonnullNodeInterface().values()),
+            new ArrayList<>(output.nonnullLinkTp()));
+
     }
 
 }