platform hardening changes for appc-adapters 67/27067/4
authorkusuma kumari M <km583p@att.com>
Tue, 9 Jan 2018 16:19:57 +0000 (11:19 -0500)
committerSkip Wonnell <skip@att.com>
Tue, 9 Jan 2018 17:25:27 +0000 (17:25 +0000)
Issue-ID: APPC-362
Change-Id: I5dfcee3ea542b130916b055b408f89240e513bba
Signed-off-by: kusuma kumari M <km583p@att.com>
appc-adapters/appc-rest-adapter/appc-rest-adapter-bundle/src/main/java/org/onap/appc/adapter/rest/RestActivator.java
appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java
appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java
appc-adapters/appc-ssh-adapter/appc-ssh-adapter-api/src/main/java/org/onap/appc/adapter/ssh/Constants.java
appc-adapters/appc-ssh-adapter/appc-ssh-adapter-sshd/src/main/java/org/onap/appc/adapter/ssh/sshd/SshConnectionSshd.java

index 3e224b9..a1d2f40 100644 (file)
@@ -101,6 +101,8 @@ public class RestActivator implements BundleActivator {
         logger.info(Msg.COMPONENT_INITIALIZING, appName, "rest adapter");
         adapter = new RestAdapterImpl();
         if (registration == null) {
+        logger.info(Msg.REGISTERING_SERVICE, appName, adapter.getAdapterName(),RestAdapter.class.getSimpleName());
+
             registration = context.registerService(RestAdapter.class, adapter, null);
         }
 
index acd9d01..6dc4134 100644 (file)
@@ -36,17 +36,10 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
 public class RestHealthcheckActivator implements BundleActivator {
-
     /**
      * The bundle registration
      */
     private ServiceRegistration registration = null;
-
-    /**
-     * The reference to the actual implementation object that implements the services
-     */
-    private RestHealthcheckAdapter adapter;
-
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(RestHealthcheckActivator.class);
 
     /**
@@ -72,14 +65,14 @@ public class RestHealthcheckActivator implements BundleActivator {
     @Override
     public void start(BundleContext context) throws Exception {
         logger.info("Starting bundle " + getName());
+       /* The reference to the actual implementation object that implements the services */
+        RestHealthcheckAdapter adapter = new RestHealthcheckAdapterImpl();
 
-        adapter = new RestHealthcheckAdapterImpl();
         if (registration == null) {
             registration = context.registerService(RestHealthcheckAdapter.class, adapter, null);
         }
 
     }
-
     /**
      * Called when this bundle is stopped so the Framework can perform the bundle-specific activities necessary to stop
      * the bundle. In general, this method should undo the work that the BundleActivator.start method started. There
@@ -108,7 +101,6 @@ public class RestHealthcheckActivator implements BundleActivator {
 
         }
     }
-
     public String getName() {
         return "APPC Rest Healthcheck adapter";
     }
index 9cf046f..f2d3099 100644 (file)
@@ -55,6 +55,7 @@ import java.io.IOException;
 import java.net.InetAddress;
 
 public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
+
     /**
      * The constant for the status code for a failed outcome
      */
@@ -74,14 +75,11 @@ public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
      */
     public RestHealthcheckAdapterImpl() {
         initialize();
-
     }
-
     @Override
     public String getAdapterName() {
         return configuration.getProperty(Constants.PROPERTY_ADAPTER_NAME);
     }
-
     public void checkHealth(Map<String, String> params, SvcLogicContext ctx) {
         logger.info("VNF rest health check");
         String uri=params.get("VNF.URI");
@@ -91,7 +89,7 @@ public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
         rc.isAlive();
         try(CloseableHttpClient httpClient = HttpClients.createDefault()) {
             HttpGet httpGet = new HttpGet(tUrl);
-            HttpResponse response =null ;
+            HttpResponse response ;
             response = httpClient.execute(httpGet);
             int responseCode=response.getStatusLine().getStatusCode();
             HttpEntity entity = response.getEntity();
@@ -108,10 +106,6 @@ public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
             doFailure(rc, HttpStatus.INTERNAL_SERVER_ERROR_500, ex.toString());
         }
     }
-
-
-
-
     @SuppressWarnings("static-method")
     private void doFailure(RequestContext rc, HttpStatus code, String message) {
         SvcLogicContext svcLogic = rc.getSvcLogicContext();
@@ -119,7 +113,6 @@ public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
         if (msg.contains("\n")) {
             msg = msg.substring(msg.indexOf("\n"));
         }
-
         String status;
         try {
             status = Integer.toString(code.getStatusCode());
@@ -130,8 +123,6 @@ public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
         svcLogic.setAttribute("healthcheck.result.code", "200");
         svcLogic.setAttribute("healthcheck.result.message", status+" "+msg);
     }
-
-
     /**
      * @param rc
      *            The request context that manages the state and recovery of the
@@ -143,27 +134,20 @@ public class RestHealthcheckAdapterImpl implements RestHealthcheckAdapter {
         String msg = Integer.toString(code)+" "+message;
         svcLogic.setAttribute("healthcheck.result.code", "200");
         svcLogic.setAttribute("healthcheck.result.message", msg);
-
     }
-
-
     @SuppressWarnings("static-method")
     private void doSuccess(RequestContext rc, int code, String message) {
         SvcLogicContext svcLogic = rc.getSvcLogicContext();
         String msg = Integer.toString(code)+" "+message;
         svcLogic.setAttribute("healthcheck.result.code", "400");
         svcLogic.setAttribute("healthcheck.result.message", msg);
-
     }
-
-
     /**
      * initialize the provider adapter by building the context cache
      */
     private void initialize() {
-
-
         logger.info("init rest health check adapter!!!!!");
     }
 
+
 }
index d3ed28a..85a1422 100644 (file)
@@ -44,7 +44,7 @@ public class Constants {
     public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID";
     public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE";
     public static final String LOG_FIELD_NAME = "LOG";
-    public static final String ASDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS";
+    public static final String SDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS";
 
     // input fields names
     public static final String PAYLOAD = "payload";
index c35c587..44cedc3 100644 (file)
@@ -117,9 +117,9 @@ class SshConnectionSshd implements SshConnection {
 
     @Override
     public void connectWithRetry() {
-        int retryCount = 0;
-        int retryDelay = 0;
-        int retriesLeft = 0;
+        int retryCount ;
+        int retryDelay ;
+        int retriesLeft;
         retryCount = configuration.getIntegerProperty(Constants.CONNECTION_RETRY_COUNT,
             Constants.DEFAULT_CONNECTION_RETRY_COUNT);
         retryDelay = configuration.getIntegerProperty(Constants.CONNECTION_RETRY_DELAY,
@@ -139,9 +139,7 @@ class SshConnectionSshd implements SshConnection {
                 } else {
                     throw e;
                 }
-            } catch (Exception e) {
-                throw e;
-            }
+          }
         } while (retriesLeft > 0);
     }
 
@@ -184,7 +182,7 @@ class SshConnectionSshd implements SshConnection {
             client.setOut(out);
             client.setErr(err);
             OpenFuture openFuture = client.open();
-            int exitStatus = 0;
+            int exitStatus;
             try {
                 client.waitFor(ClientChannel.CLOSED, timeout);
                 openFuture.verify();
@@ -200,9 +198,9 @@ class SshConnectionSshd implements SshConnection {
             return exitStatus;
         } catch (RuntimeException e) {
             throw e;
-        } catch (Exception t) {
+        } catch (Exception e1) {
             throw new SshException(
-                "Error executing command [" + cmd + "] over SSH [" + username + "@" + host + ":" + port + "]", t);
+                "Error executing command [" + cmd + "] over SSH [" + username + "@" + host + ":" + port + "]", e1);
         }
     }