Remove unused code in vnfapi
[sdnc/northbound.git] / vnfapi / provider / src / main / java / org / onap / sdnc / vnfapi / VnfApiProvider.java
index bfec080..15af1f2 100644 (file)
@@ -24,13 +24,14 @@ package org.onap.sdnc.vnfapi;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.base.Optional;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
@@ -130,6 +131,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
@@ -144,6 +146,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.concurrent.Future;
 
 /**
@@ -151,15 +154,26 @@ import java.util.concurrent.Future;
  * the most commonly used components of the MD-SAL. Additionally the base class provides some basic logging and
  * initialization / clean up methods.
  */
-public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeListener {
 
+public class VnfApiProvider implements AutoCloseable, VNFAPIService {
+    protected DataBroker dataBroker;
+    protected NotificationPublishService notificationService;
+    protected RpcProviderRegistry rpcRegistry;
+    protected BindingAwareBroker.RpcRegistration<VNFAPIService> rpcRegistration;
     private final Logger log = LoggerFactory.getLogger(VnfApiProvider.class);
     private final ExecutorService executor;
 
+    private static final String PRELOAD_DATA = "] PreloadData: ";
+    private static final String SENDING_SUCCESS_RPC = "Sending Success rpc result due to external error";
+    public static final String REASON = "', Reason: '";
+    public static final String ERROR_CODE = "] error code: '";
+    public static final String INVALID_INPUT_INVALID_PRELOAD_TYPE = "invalid input, invalid preload-type";
+    public static final String BECAUSE_OF_INVALID_PRELOAD_TYPE = " because of invalid preload-type";
+    public static final String INVALID_INPUT_NULL_OR_EMPTY_SERVICE_INSTANCE_ID = "invalid input, null or empty service-instance-id";
+    public static final String BECAUSE_OF_INVALID_INPUT_NULL_OR_EMPTY_SERVICE_INSTANCE_ID = " because of invalid input, null or empty service-instance-id";
     private static final String APP_NAME = "vnfapi";
     private static final String VNF_API = "VNF-API";
     private static final String OPERATIONAL_DATA = "operational-data";
-
     private static final String READ_MD_SAL_STR = "Read MD-SAL (";
     private static final String DATA_FOR_STR = ") data for [";
     private static final String SERVICE_DATA_STR = "] ServiceData: ";
@@ -183,10 +197,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
     private static final String INVALID_INPUT_VNF_INSTANCE_STR = "invalid input, null or empty vnf-instance-id";
 
     private VNFSDNSvcLogicServiceClient svcLogicClient;
-    protected DataBroker dataBroker;
-    protected NotificationPublishService notificationService;
-    protected RpcProviderRegistry rpcRegistry;
-    protected BindingAwareBroker.RpcRegistration<VNFAPIService> rpcRegistration;
 
     public VnfApiProvider(DataBroker dataBroker2, NotificationPublishService notificationPublishService,
         RpcProviderRegistry rpcProviderRegistry, VNFSDNSvcLogicServiceClient client) {
@@ -267,166 +277,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         log.info("Successfully closed provider for " + APP_NAME);
     }
 
-    // On data change not used
-    @Override
-    public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
-
-        log.info("   IN ON DATA CHANGE: ");
-
-        boolean changed = false;
-        WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
-        DataObject updatedSubTree = change.getUpdatedSubtree();
-
-        if (updatedSubTree != null) {
-            if (log.isDebugEnabled()) {
-                log.debug("updatedSubTree was non-null:" + updatedSubTree);
-            }
-            if (updatedSubTree instanceof Vnfs) {
-                changed = isChanged(changed, (Vnfs) updatedSubTree);
-            }
-            if (updatedSubTree instanceof PreloadVnfs) {
-                changed = isChanged(changed, (PreloadVnfs) updatedSubTree);
-            }
-            //1610
-            if (updatedSubTree instanceof PreloadVnfInstances) {
-                changed = isChanged(changed, (PreloadVnfInstances) updatedSubTree);
-            }
-            //1610
-            if (updatedSubTree instanceof VnfInstances) {
-                changed = isChanged(changed, (VnfInstances) updatedSubTree);
-            }
-            //1610
-            if (updatedSubTree instanceof PreloadVfModules) {
-                changed = isChanged(changed, (PreloadVfModules) updatedSubTree);
-            }
-            //1610
-            if (updatedSubTree instanceof VfModules) {
-                changed = isChanged(changed, (VfModules) updatedSubTree);
-            }
-        }
-
-        // Do the write transaction only if something changed.
-        if (changed) {
-            CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = writeTransaction.submit();
-            Futures.addCallback(checkedFuture, new FutureCallback<Void>() {
 
-                @Override
-                public void onSuccess(Void arg0) {
-                    log.debug("Successfully updated Service Status");
-                }
-
-                @Override
-                public void onFailure(Throwable e) {
-                    log.debug("Failed updating Service Status", e);
-                }
-            }, executor);
-        }
-    }
-
-    private boolean isChanged(boolean changed, VfModules updatedSubTree) {
-        ArrayList<VfModuleList> vfModuleList =
-            (ArrayList<VfModuleList>) updatedSubTree.getVfModuleList();
-        if (vfModuleList != null) {
-            for (VfModuleList entry : vfModuleList) {
-                VfModuleServiceData vfModuleServiceData = entry.getVfModuleServiceData();
-                ServiceStatus serviceStatus = entry.getServiceStatus();
-                if (vfModuleServiceData != null && serviceStatus != null) {
-                    // VfModuleServiceData change detected, check the AckFinal indicator and request-status to
-                    // see if we need to proceed.
-                    return isChanged(changed, serviceStatus);
-                }
-            }
-        }
-        return changed;
-    }
-
-    private boolean isChanged(boolean changed, PreloadVfModules updatedSubTree) {
-        ArrayList<VfModulePreloadList> vnfInstanceList =
-            (ArrayList<VfModulePreloadList>) updatedSubTree.getVfModulePreloadList();
-        if (vnfInstanceList != null) {
-            for (VfModulePreloadList entry : vnfInstanceList) {
-                VfModulePreloadData vnfInstancePreloadData = entry.getVfModulePreloadData();
-                if (vnfInstancePreloadData != null) {
-                    return true;
-                }
-            }
-        }
-        return changed;
-    }
-
-    private boolean isChanged(boolean changed, VnfInstances updatedSubTree) {
-        ArrayList<VnfInstanceList> vnfInstanceList =
-            (ArrayList<VnfInstanceList>) updatedSubTree.getVnfInstanceList();
-        if (vnfInstanceList != null) {
-            for (VnfInstanceList entry : vnfInstanceList) {
-                VnfInstanceServiceData vnfInstanceServiceData = entry.getVnfInstanceServiceData();
-                ServiceStatus serviceStatus = entry.getServiceStatus();
-                if (vnfInstanceServiceData != null && serviceStatus != null) {
-                    // VnfInstanceServiceData change detected, check the AckFinal indicator and request-status
-                    // to see if we need to proceed.
-                    return isChanged(changed, serviceStatus);
-                }
-            }
-        }
-        return changed;
-    }
-
-    private boolean isChanged(boolean changed, PreloadVnfInstances updatedSubTree) {
-        ArrayList<VnfInstancePreloadList> vnfInstanceList =
-            (ArrayList<VnfInstancePreloadList>) updatedSubTree
-                .getVnfInstancePreloadList();
-        if (vnfInstanceList != null) {
-            for (VnfInstancePreloadList entry : vnfInstanceList) {
-                VnfInstancePreloadData vnfInstancePreloadData = entry.getVnfInstancePreloadData();
-                if (vnfInstancePreloadData != null) {
-                    return true;
-                }
-            }
-        }
-        return changed;
-    }
-
-    private boolean isChanged(boolean changed, PreloadVnfs updatedSubTree) {
-        ArrayList<VnfPreloadList> vnfList =
-            (ArrayList<VnfPreloadList>) updatedSubTree.getVnfPreloadList();
-        if (vnfList != null) {
-            for (VnfPreloadList entry : vnfList) {
-                PreloadData preloadData = entry.getPreloadData();
-                if (preloadData != null) {
-                    return true;
-                }
-            }
-        }
-        return changed;
-    }
-
-    private boolean isChanged(boolean changed, Vnfs updatedSubTree) {
-        ArrayList<VnfList> vnfList = (ArrayList<VnfList>) updatedSubTree.getVnfList();
-        if (vnfList != null) {
-            for (VnfList entry : vnfList) {
-                ServiceData serviceData = entry.getServiceData();
-                ServiceStatus serviceStatus = entry.getServiceStatus();
-                if (serviceData != null && serviceStatus != null) {
-                    //
-                    // ServiceData change detected, check the AckFinal indicator and request-status to see if we need to proceed.
-                    //
-                    return isChanged(changed, serviceStatus);
-                }
-            }
-        }
-        return changed;
-    }
-
-    private boolean isChanged(boolean changed, ServiceStatus serviceStatus) {
-        if ((!"Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete
-            .equals(serviceStatus.getRequestStatus()))) {
-            if (log.isDebugEnabled()) {
-                log.debug("Final Indicator is not Y, calling handleServiceDataUpdated");
-            }
-            return true;
-        }
-        return changed;
-    }
 
     private static class Iso8601Util {
 
@@ -705,7 +556,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         if (data.isPresent()) {
             PreloadData preloadData = (PreloadData) data.get().getPreloadData();
             if (preloadData != null) {
-                log.info(READ_MD_SAL_STR + type + DATA_FOR_STR + preloadName + "," + preloadType + "] PreloadData: "
+              log.info(READ_MD_SAL_STR + type + DATA_FOR_STR  + preloadName + "," + preloadType + PRELOAD_DATA
                     + preloadData);
                 preloadDataBuilder.setVnfTopologyInformation(preloadData.getVnfTopologyInformation());
                 preloadDataBuilder.setNetworkTopologyInformation(preloadData.getNetworkTopologyInformation());
@@ -805,7 +656,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VnfList> path = InstanceIdentifier
             .builder(Vnfs.class)
-            .child(VnfList.class, entry.getKey())
+            .child(VnfList.class, entry.key())
             .build();
 
         int optimisticLockTries = 2;
@@ -826,13 +677,22 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                 tryAgain = true;
 
             } catch (final TransactionCommitFailedException e) {
-
-                if (e.getCause() instanceof ModifiedNodeDoesNotExistException) {
-                    log.debug("Ignoring MpdifiedNodeDoesNotExistException");
+               Throwable eCause = e.getCause();
+               
+               
+               if (eCause instanceof org.opendaylight.mdsal.common.api.TransactionCommitFailedException) {
+                       log.debug("Nested TransactionCommitFailed exception - getting next cause");
+                       eCause = eCause.getCause();
+               } else {
+                       log.debug("Got TransactionCommitFailedException, caused by {}", eCause.getClass().getName());
+               }
+
+                if (eCause instanceof ModifiedNodeDoesNotExistException) {
+                    log.debug("Ignoring ModifiedNodeDoesNotExistException");
                     break;
                 }
 
-                log.debug("Delete DataStore failed");
+                log.debug("Delete DataStore failed due to exception", eCause);
                 throw new IllegalStateException(e);
             }
         }
@@ -842,7 +702,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VnfList> path = InstanceIdentifier
             .builder(Vnfs.class)
-            .child(VnfList.class, entry.getKey())
+            .child(VnfList.class, entry.key())
             .build();
 
         tryUpdateDataStore(entry, merge, storeType, path);
@@ -853,7 +713,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VnfInstanceList> path = InstanceIdentifier
             .builder(VnfInstances.class)
-            .child(VnfInstanceList.class, entry.getKey())
+            .child(VnfInstanceList.class, entry.key())
             .build();
 
         tryUpdateDataStore(entry, merge, storeType, path);
@@ -864,7 +724,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VfModuleList> path = InstanceIdentifier
             .builder(VfModules.class)
-            .child(VfModuleList.class, entry.getKey())
+            .child(VfModuleList.class, entry.key())
             .build();
 
         tryUpdateDataStore(entry, merge, storeType, path);
@@ -875,7 +735,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VnfPreloadList> path = InstanceIdentifier
             .builder(PreloadVnfs.class)
-            .child(VnfPreloadList.class, entry.getKey())
+            .child(VnfPreloadList.class, entry.key())
             .build();
 
         tryUpdateDataStore(entry, merge, storeType, path);
@@ -888,7 +748,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VnfInstancePreloadList> path = InstanceIdentifier
             .builder(PreloadVnfInstances.class)
-            .child(VnfInstancePreloadList.class, entry.getKey())
+            .child(VnfInstancePreloadList.class, entry.key())
             .build();
 
         tryUpdateDataStore(entry, merge, storeType, path);
@@ -901,7 +761,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // Each entry will be identifiable by a unique key, we have to create that identifier
         InstanceIdentifier<VfModulePreloadList> path = InstanceIdentifier
             .builder(PreloadVfModules.class)
-            .child(VfModulePreloadList.class, entry.getKey())
+            .child(VfModulePreloadList.class, entry.key())
             .build();
 
         tryUpdateDataStore(entry, merge, storeType, path);
@@ -941,8 +801,28 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
     }
 
     //1610 vnf-instance-topology-operation
+
+    private Boolean validateVnfInstanceTopologyOperationInput(VnfInstanceTopologyOperationInput input) {
+        return input != null
+                && input.getVnfInstanceRequestInformation() != null
+                && input.getVnfInstanceRequestInformation().getVnfInstanceId() != null
+                && input.getVnfInstanceRequestInformation().getVnfInstanceId().length() != 0;
+    }
+
+    private ListenableFuture<RpcResult<VnfInstanceTopologyOperationOutput>> buildVnfInstanceTopologyOperationOutputWithtError(
+            String responseCode, String responseMessage, String ackFinalIndicator) {
+        VnfInstanceTopologyOperationOutputBuilder responseBuilder = new VnfInstanceTopologyOperationOutputBuilder();
+        responseBuilder.setResponseCode(responseCode);
+        responseBuilder.setResponseMessage(responseMessage);
+        responseBuilder.setAckFinalIndicator(ackFinalIndicator);
+        return Futures.immediateFuture(RpcResultBuilder
+                .<VnfInstanceTopologyOperationOutput>status(true)
+                .withResult(responseBuilder.build())
+                .build());
+    }
+
     @Override
-    public Future<RpcResult<VnfInstanceTopologyOperationOutput>> vnfInstanceTopologyOperation(
+    public ListenableFuture<RpcResult<VnfInstanceTopologyOperationOutput>> vnfInstanceTopologyOperation(
         VnfInstanceTopologyOperationInput input) {
 
         final String svcOperation = "vnf-instance-topology-operation";
@@ -954,18 +834,11 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         // create a new response object
         VnfInstanceTopologyOperationOutputBuilder responseBuilder = new VnfInstanceTopologyOperationOutputBuilder();
 
-        if (input == null || input.getVnfInstanceRequestInformation() == null
-            || input.getVnfInstanceRequestInformation().getVnfInstanceId() == null) {
+        if (!validateVnfInstanceTopologyOperationInput(input)) {
             log.debug(EXITING_STR + svcOperation + " because of " + INVALID_INPUT_VNF_INSTANCE_STR);
-            responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage(INVALID_INPUT_VNF_INSTANCE_STR);
-            responseBuilder.setAckFinalIndicator("Y");
-            RpcResult<VnfInstanceTopologyOperationOutput> rpcResult = RpcResultBuilder
-                .<VnfInstanceTopologyOperationOutput>status(true)
-                .withResult(responseBuilder.build())
-                .build();
-            // return error
-            return Futures.immediateFuture(rpcResult);
+            return buildVnfInstanceTopologyOperationOutputWithtError("403",
+                    INVALID_INPUT_VNF_INSTANCE_STR,
+                    "Y" );
         }
 
         // Grab the service instance ID from the input buffer
@@ -973,20 +846,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         String preloadName = input.getVnfInstanceRequestInformation().getVnfInstanceName();
         String preloadType = input.getVnfInstanceRequestInformation().getVnfModelId();
 
-        // Make sure we have a valid viid
-        if (viid == null || viid.length() == 0) {
-            log.debug(EXITING_STR + svcOperation + " because of invalid vnf-instance-id");
-            responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage(INVALID_INPUT_VNF_INSTANCE_STR);
-            responseBuilder.setAckFinalIndicator("Y");
-            RpcResult<VnfInstanceTopologyOperationOutput> rpcResult = RpcResultBuilder
-                .<VnfInstanceTopologyOperationOutput>status(true)
-                .withResult(responseBuilder.build())
-                .build();
-            // return error
-            return Futures.immediateFuture(rpcResult);
-        }
-
         if (input.getSdncRequestHeader() != null) {
             responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
             setRequestIdAsMDC(input.getSdncRequestHeader().getSvcRequestId());
@@ -1047,19 +906,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-
-                try {
-                    respProps = svcLogicClient
-                        .execute(VNF_API, svcOperation, null, "sync", vnfInstanceServiceDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+                respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", vnfInstanceServiceDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -1153,7 +1008,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
     //1610 vf-module-topology-operation
     @Override
-    public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation(
+    public ListenableFuture<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation(
         VfModuleTopologyOperationInput input) {
 
         final String svcOperation = "vf-module-topology-operation";
@@ -1287,20 +1142,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-
-                try {
-                    respProps = svcLogicClient
-                        .execute(VNF_API, svcOperation, null, "sync", vfModuleServiceDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic on vf-module for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
-
+                respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", vfModuleServiceDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -1390,7 +1240,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
     }
 
     @Override
-    public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
+    public ListenableFuture<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
         final String svcOperation = "vnf-topology-operation";
         ServiceData serviceData;
         ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
@@ -1405,7 +1255,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             || input.getServiceInformation().getServiceInstanceId().length() == 0) {
             log.debug(EXITING_STR + svcOperation + " because of invalid input, null or empty service-instance-id");
             responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
+            responseBuilder.setResponseMessage(INVALID_INPUT_NULL_OR_EMPTY_SERVICE_INSTANCE_ID);
             responseBuilder.setAckFinalIndicator("Y");
             RpcResult<VnfTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<VnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
@@ -1483,19 +1333,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-
-                try {
-                    respProps =
-                        svcLogicClient.execute(VNF_API, svcOperation, null, "sync", serviceDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+                respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", serviceDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + siid, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -1586,7 +1432,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
     }
 
     @Override
-    public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
+    public ListenableFuture<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
         NetworkTopologyOperationInput input) {
 
         final String svcOperation = "network-topology-operation";
@@ -1603,7 +1449,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             || input.getServiceInformation().getServiceInstanceId().length() == 0) {
             log.debug(EXITING_STR + svcOperation + " because of invalid input, null or empty service-instance-id");
             responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
+            responseBuilder.setResponseMessage(INVALID_INPUT_NULL_OR_EMPTY_SERVICE_INSTANCE_ID);
             responseBuilder.setAckFinalIndicator("Y");
             RpcResult<NetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
@@ -1616,7 +1462,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             || input.getNetworkRequestInformation().getNetworkName() == null) {
             log.debug(EXITING_STR + svcOperation + " because of invalid input, null or empty service-instance-id");
             responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
+            responseBuilder.setResponseMessage(INVALID_INPUT_NULL_OR_EMPTY_SERVICE_INSTANCE_ID);
             responseBuilder.setAckFinalIndicator("Y");
             RpcResult<NetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
@@ -1657,19 +1503,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-
-                try {
-                    respProps =
-                        svcLogicClient.execute(VNF_API, svcOperation, null, "sync", preloadDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+                respProps =  svcLogicClient.execute(VNF_API, svcOperation, null, "sync", preloadDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -1732,7 +1574,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
     }
 
     @Override
-    public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation(
+    public ListenableFuture<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation(
         PreloadVnfTopologyOperationInput input) {
 
         final String svcOperation = "preload-vnf-topology-operation";
@@ -1767,17 +1609,18 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
         if (preloadName == null || preloadName.length() == 0) {
             log.debug(EXITING_STR + svcOperation + " because of invalid preload-name");
             responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage("invalid input, invalid preload-name");
+            responseBuilder.setResponseMessage(INVALID_INPUT_INVALID_PRELOAD_TYPE);
             responseBuilder.setAckFinalIndicator("Y");
             RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
                     .build();
             return Futures.immediateFuture(rpcResult);
         }
+
         if (preloadType == null || preloadType.length() == 0) {
             log.debug(EXITING_STR + svcOperation + " because of invalid preload-type");
             responseBuilder.setResponseCode("403");
-            responseBuilder.setResponseMessage("invalid input, invalid preload-type");
+            responseBuilder.setResponseMessage(INVALID_INPUT_INVALID_PRELOAD_TYPE);
             responseBuilder.setAckFinalIndicator("Y");
             RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
@@ -1821,19 +1664,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-
-                try {
-                    respProps =
-                        svcLogicClient.execute(VNF_API, svcOperation, null, "sync", preloadDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+              respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", preloadDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -1866,7 +1705,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                     CAUGHT_EXCEPTION_STR + svcOperation + " [" + preloadName + "," + preloadType
                         + "] \n", e);
             }
-            log.debug("Sending Success rpc result due to external error");
+            log.debug(SENDING_SUCCESS_RPC);
             RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
                     .build();
@@ -1922,7 +1761,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
     //1610 preload-vnf-instance-topology-operation
     @Override
-    public Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> preloadVnfInstanceTopologyOperation(
+    public ListenableFuture<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> preloadVnfInstanceTopologyOperation(
         PreloadVnfInstanceTopologyOperationInput input) {
 
         final String svcOperation = "preload-vnf-instance-topology-operation";
@@ -1964,6 +1803,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                     .withResult(responseBuilder.build()).build();
             return Futures.immediateFuture(rpcResult);
         }
+
         if (preloadType == null || preloadType.length() == 0) {
             log.debug(EXITING_STR + svcOperation + " because of invalid preload-type");
             responseBuilder.setResponseCode("403");
@@ -1982,7 +1822,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         VnfInstancePreloadDataBuilder vnfInstancePreloadDataBuilder = new VnfInstancePreloadDataBuilder();
         getVnfInstancePreloadData(preloadName, preloadType, vnfInstancePreloadDataBuilder);
-
         VnfInstancePreloadDataBuilder operDataBuilder = new VnfInstancePreloadDataBuilder();
         getVnfInstancePreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
 
@@ -2011,19 +1850,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-
-                try {
-                    respProps = svcLogicClient
-                        .execute(VNF_API, svcOperation, null, "sync", vnfInstancePreloadDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+                respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", vnfInstancePreloadDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -2057,7 +1892,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                     CAUGHT_EXCEPTION_STR + svcOperation + " [" + preloadName + "," + preloadType
                         + "] \n", e);
             }
-            log.debug("Sending Success rpc result due to external error");
+            log.debug(SENDING_SUCCESS_RPC);
             RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(true)
                     .withResult(responseBuilder.build()).build();
@@ -2115,7 +1950,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
     //1610 preload-vf-module-topology-operation
     @Override
-    public Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation(
+    public ListenableFuture<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation(
         PreloadVfModuleTopologyOperationInput input) {
 
         final String svcOperation = "preload-vf-module-topology-operation";
@@ -2176,7 +2011,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         VfModulePreloadDataBuilder vfModulePreloadDataBuilder = new VfModulePreloadDataBuilder();
         getVfModulePreloadData(preloadName, preloadType, vfModulePreloadDataBuilder);
-
         VfModulePreloadDataBuilder operDataBuilder = new VfModulePreloadDataBuilder();
         getVfModulePreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
 
@@ -2208,18 +2042,16 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-                try {
-                    respProps = svcLogicClient
-                        .execute(VNF_API, svcOperation, null, "sync", vfModulePreloadDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+                respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", vfModulePreloadDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
+
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -2252,7 +2084,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                     CAUGHT_EXCEPTION_STR + svcOperation + " [" + preloadName + "," + preloadType
                         + "] \n", e);
             }
-            log.debug("Sending Success rpc result due to external error");
+            log.debug(SENDING_SUCCESS_RPC);
             RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(true)
                     .withResult(responseBuilder.build()).build();
@@ -2308,7 +2140,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
 
     @Override
-    public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
+    public ListenableFuture<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
         PreloadNetworkTopologyOperationInput input) {
 
         final String svcOperation = "preload-network-topology-operation";
@@ -2353,6 +2185,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             return Futures.immediateFuture(rpcResult);
         }
 
+
         if (preloadType == null || preloadType.length() == 0) {
             log.debug(EXITING_STR + svcOperation + " because of invalid preload-type");
             responseBuilder.setResponseCode("403");
@@ -2402,18 +2235,15 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         try {
             if (svcLogicClient.hasGraph(VNF_API, svcOperation, null, "sync")) {
-                try {
-                    respProps =
-                        svcLogicClient.execute(VNF_API, svcOperation, null, "sync", preloadDataBuilder, parms);
-                } catch (Exception e) {
-                    log.error("Caught exception executing service logic for " + svcOperation, e);
-                    errorMessage = e.getMessage();
-                    errorCode = "500";
-                }
+                respProps = svcLogicClient.execute(VNF_API, svcOperation, null, "sync", preloadDataBuilder, parms);
             } else {
                 errorMessage = "No service logic active for VNF-API: '" + svcOperation + "'";
                 errorCode = "503";
             }
+        } catch (SvcLogicException e) {
+            log.error("Caught exception executing service logic for " + svcOperation, e);
+            errorMessage = e.getMessage();
+            errorCode = "500";
         } catch (Exception e) {
             errorCode = "500";
             errorMessage = e.getMessage();
@@ -2446,7 +2276,7 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                         + "] \n", e);
 
             }
-            log.debug("Sending Success rpc result due to external error");
+            log.debug(SENDING_SUCCESS_RPC);
             RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
                 RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
                     .build();
@@ -2499,4 +2329,6 @@ public class VnfApiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                 .build();
         return Futures.immediateFuture(rpcResult);
     }
+
+
 }