summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-rest-healthcheck-adapter
diff options
context:
space:
mode:
authorkusuma kumari M <km583p@att.com>2018-01-09 11:19:57 -0500
committerSkip Wonnell <skip@att.com>2018-01-09 17:25:27 +0000
commit9f4b9299a1bdfaffb669fb051707d3e540a9f529 (patch)
tree22e9123a68145a77b782865a8438781c5dc94683 /appc-adapters/appc-rest-healthcheck-adapter
parent55f9e7db829f1d8d01a71a8e44388f2c4f49d004 (diff)
platform hardening changes for appc-adapters
Issue-ID: APPC-362 Change-Id: I5dfcee3ea542b130916b055b408f89240e513bba Signed-off-by: kusuma kumari M <km583p@att.com>
Diffstat (limited to 'appc-adapters/appc-rest-healthcheck-adapter')
-rw-r--r--appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java12
-rw-r--r--appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java22
2 files changed, 5 insertions, 29 deletions
diff --git a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java
index acd9d013b..6dc413494 100644
--- a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java
+++ b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/RestHealthcheckActivator.java
@@ -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";
}
diff --git a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java
index 9cf046fc6..f2d309996 100644
--- a/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java
+++ b/appc-adapters/appc-rest-healthcheck-adapter/appc-rest-healthcheck-adapter-bundle/src/main/java/org/onap/appc/adapter/restHealthcheck/impl/RestHealthcheckAdapterImpl.java
@@ -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!!!!!");
}
+
}