diff options
author | beili.zhou <beili.zhou@amdocs.com> | 2017-08-29 18:33:57 -0400 |
---|---|---|
committer | Marcus Williams <marcus.williams@intel.com> | 2017-08-30 16:29:28 +0000 |
commit | a1194798f406efe32cb33510f1a9d58b0b5f9bd9 (patch) | |
tree | 21931fa9ba7e4023dd4d1998525e5529b944d209 /appc-adapters | |
parent | 9a1e7032fae218bd820dc06436a52173fbae7d6e (diff) |
Remove catch throwable and error
Fix the following sonar blocker issue:
- Catch Exception instead of Throwable
- Catch Exception instead of Error
Issue-Id: APPC-175
Change-Id: I16a1018001b067216740ec11e5a97e52d714db69
Signed-off-by: beili.zhou <beili.zhou@amdocs.com>
Diffstat (limited to 'appc-adapters')
15 files changed, 64 insertions, 69 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java index 006cb9408..75dadae58 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/AppcProviderAdapterActivator.java @@ -98,11 +98,11 @@ public class AppcProviderAdapterActivator implements BundleActivator { configuration = ConfigurationFactory.getConfiguration(); String appName = configuration.getProperty(Constants.PROPERTY_APPLICATION_NAME); logger.info(Msg.COMPONENT_INITIALIZING, appName, "IAAS adapter"); - try{ + try { adapter = new ProviderAdapterImpl(configuration.getProperties()); - }catch(Throwable t){ - logger.error("Error initializing APPC IAAS ProviderAdapterImpl",t); - throw t; + } catch(Exception e){ + logger.error("Error initializing APPC IAAS ProviderAdapterImpl",e); + throw e; } if (registration == null) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java index 6dced63b5..4a5d8ea16 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/CreateSnapshot.java @@ -190,11 +190,11 @@ public class CreateSnapshot extends ProviderServerOperation { logger.error(msg); metricsLogger.error(msg, e); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), Operation.SNAPSHOT_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java index 26fbe8d1b..2902ea7e0 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/EvacuateServer.java @@ -263,12 +263,12 @@ public class EvacuateServer extends ProviderServerOperation { doFailure(rc, HttpStatus.NOT_FOUND_404, msg); } catch (RequestFailedException e) { doFailure(rc, e.getStatus(), e.getMessage()); - } catch (Throwable t) { - msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), Operation.EVACUATE_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); - metricsLogger.error(msg, t); + logger.error(msg, e1); + metricsLogger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/LookupServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/LookupServer.java index eb63f11a1..3d9bc0e39 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/LookupServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/LookupServer.java @@ -97,10 +97,11 @@ public class LookupServer extends ProviderServerOperation { //exception closing context String msg = EELFResourceManager.format(Msg.CLOSE_CONTEXT_FAILED, e, vm_url); logger.error(msg); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, + e1, e1.getClass().getSimpleName(), Operation.LOOKUP_SERVICE.toString(), vm_url, "Unknown" ); - logger.error(msg, t); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/MigrateServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/MigrateServer.java index 20b4f1061..2ca9e3e4e 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/MigrateServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/MigrateServer.java @@ -194,10 +194,10 @@ public class MigrateServer extends ProviderServerOperation { logger.error(msg); metricsLogger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), MIGRATE_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); + logger.error(msg, e1); metricsLogger.error(msg); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RebuildServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RebuildServer.java index a5b9b3fd7..ed219ac67 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RebuildServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RebuildServer.java @@ -392,11 +392,11 @@ public class RebuildServer extends ProviderServerOperation { logger.error(msg); metricsLogger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), STOP_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); ctx.setAttribute("REBUILD_STATUS", "ERROR"); - logger.error(msg, t); + logger.error(msg, e1); metricsLogger.error(msg); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestartServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestartServer.java index dd825f9c9..b57d076e7 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestartServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestartServer.java @@ -229,11 +229,11 @@ public class RestartServer extends ProviderServerOperation { logger.error(msg); metricsLogger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), RESTART_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); - metricsLogger.error(msg, t); + logger.error(msg, e1); + metricsLogger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestoreStack.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestoreStack.java index 8ce1707ad..24b2471f8 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestoreStack.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/RestoreStack.java @@ -137,11 +137,12 @@ public class RestoreStack extends ProviderStackOperation { logger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "restoreStack")); doFailure(rc, e.getStatus(), e.getMessage(), e); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, + e1, e1.getClass().getSimpleName(), "restoreStack", vm_url, null == context ? "n/a" : context.getTenantName()); - logger.error(msg, t); - doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, t); + logger.error(msg, e1); + doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, e1); } return stack; } diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java index 35bbae3ae..07053961a 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/SnapshotStack.java @@ -155,12 +155,13 @@ public class SnapshotStack extends ProviderStackOperation { metricsLogger.error(EELFResourceManager.format(Msg.MISSING_PARAMETER_IN_REQUEST, e.getReason(), "snapshotStack")); doFailure(rc, e.getStatus(), e.getMessage(), e); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, + e1, e1.getClass().getSimpleName(), "snapshotStack", vm_url, null == context ? "n/a" : context.getTenantName()); - logger.error(msg, t); + logger.error(msg, e1); metricsLogger.error(msg); - doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, t); + doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg, e1); } return stack; } diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StartServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StartServer.java index f2186e195..be30a8c46 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StartServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StartServer.java @@ -164,10 +164,10 @@ public class StartServer extends ProviderServerOperation { String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url); logger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), START_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StopServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StopServer.java index e5a6e8e4a..fcffa12ce 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StopServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/StopServer.java @@ -179,10 +179,10 @@ public class StopServer extends ProviderServerOperation { String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url); logger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), STOP_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateServer.java index c6ea1f40f..3f3749a6d 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateServer.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateServer.java @@ -221,10 +221,11 @@ public class TerminateServer extends ProviderServerOperation { logger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); ctx.setAttribute("TERMINATE_STATUS", "SERVER_NOT_FOUND"); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), - RESTART_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, + e1, e1.getClass().getSimpleName(), RESTART_SERVICE.toString(), + vm_url, context == null ? "Unknown" : context.getTenantName()); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateStack.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateStack.java index 4a82e160b..7400877e5 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateStack.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/TerminateStack.java @@ -107,10 +107,10 @@ public class TerminateStack extends ProviderStackOperation { String msg = EELFResourceManager.format(Msg.STACK_NOT_FOUND, e, vm_url); logger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.STACK_OPERATION_EXCEPTION, e1, e1.getClass().getSimpleName(), Operation.TERMINATE_STACK.toString(), vm_url, context.getTenantName()); - logger.error(msg, t); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java index e5464302a..5a3e92cf3 100644 --- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java +++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/provider/operation/impl/VmStatuschecker.java @@ -136,10 +136,11 @@ public class VmStatuschecker extends ProviderServerOperation { String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vm_url); logger.error(msg); doFailure(rc, HttpStatus.NOT_FOUND_404, msg); - } catch (Throwable t) { - String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, t, t.getClass().getSimpleName(), - RESTART_SERVICE.toString(), vm_url, context == null ? "Unknown" : context.getTenantName()); - logger.error(msg, t); + } catch (Exception e1) { + String msg = EELFResourceManager.format(Msg.SERVER_OPERATION_EXCEPTION, + e1, e1.getClass().getSimpleName(), RESTART_SERVICE.toString(), + vm_url, context == null ? "Unknown" : context.getTenantName()); + logger.error(msg, e1); doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, msg); } } catch (RequestFailedException e) { diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java index d55e3f5c2..04088166d 100644 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/main/java/org/openecomp/appc/adapter/netconf/internal/NetconfDataAccessServiceImpl.java @@ -24,22 +24,19 @@ package org.openecomp.appc.adapter.netconf.internal; -import javax.sql.rowset.CachedRowSet; - +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import org.openecomp.appc.adapter.netconf.ConnectionDetails; import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails; import org.openecomp.appc.adapter.netconf.NetconfDataAccessService; import org.openecomp.appc.adapter.netconf.exception.DataAccessException; import org.openecomp.appc.adapter.netconf.util.Constants; -import org.openecomp.appc.exceptions.APPCException; -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; import org.openecomp.sdnc.sli.resource.dblib.DbLibService; +import javax.sql.rowset.CachedRowSet; import java.sql.SQLException; import java.util.ArrayList; - public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { private static EELFLogger logger = EELFManager.getInstance().getLogger(NetconfDataAccessServiceImpl.class); @@ -66,13 +63,11 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { argList.add(xmlID); try { - final CachedRowSet data = dbLibService.getData(queryString, argList, schema); if (data.first()) { fileContent = data.getString(Constants.FILE_CONTENT_TABLE_FIELD_NAME); } - - } catch (Throwable e) { + } catch (Exception e) { logger.error("Error Accessing Database " + e); throw new DataAccessException(e); } @@ -85,7 +80,8 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { DataAccessException { boolean recordFound = false; - String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " + + String queryString = "select " + Constants.USER_NAME_TABLE_FIELD_NAME + "," + + Constants.PASSWORD_TABLE_FIELD_NAME + "," + Constants.PORT_NUMBER_TABLE_FIELD_NAME + " " + "from " + Constants.DEVICE_AUTHENTICATION_TABLE_NAME + " " + "where " + Constants.VNF_TYPE_TABLE_FIELD_NAME + " = ?"; @@ -93,7 +89,6 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { argList.add(vnfType); try { - final CachedRowSet data = dbLibService.getData(queryString, argList, schema); if (data.first()) { connectionDetails.setUsername(data.getString(Constants.USER_NAME_TABLE_FIELD_NAME)); @@ -101,7 +96,6 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { connectionDetails.setPort(data.getInt(Constants.PORT_NUMBER_TABLE_FIELD_NAME)); recordFound = true; } - } catch (SQLException e) { logger.error("Error Accessing Database " + e); throw new DataAccessException(e); @@ -111,9 +105,8 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { } @Override - public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) throws - DataAccessException - { + public boolean retrieveNetconfConnectionDetails(String vnfType, NetconfConnectionDetails connectionDetails) + throws DataAccessException { ConnectionDetails connDetails = new ConnectionDetails(); if(this.retrieveConnectionDetails(vnfType, connDetails)) { @@ -126,9 +119,8 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { } @Override - public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) throws - DataAccessException { - + public boolean logDeviceInteraction(String instanceId, String requestId, String creationDate, String logText) + throws DataAccessException { String queryString = "INSERT INTO "+ Constants.DEVICE_INTERFACE_LOG_TABLE_NAME+"("+ Constants.SERVICE_INSTANCE_ID_FIELD_NAME+","+ Constants.REQUEST_ID_FIELD_NAME+","+ @@ -143,9 +135,7 @@ public class NetconfDataAccessServiceImpl implements NetconfDataAccessService { argList.add(logText); try { - dbLibService.writeData(queryString, argList, schema); - } catch (SQLException e) { logger.error("Logging Device interaction failed - "+ queryString); throw new DataAccessException(e); |