summaryrefslogtreecommitdiffstats
path: root/wfenginemgrservice
diff options
context:
space:
mode:
authorajay priyadarshi <ajay.priyadarshi@ril.com>2018-03-26 12:21:43 +0530
committerajay priyadarshi <ajay.priyadarshi@ril.com>2018-03-26 12:21:43 +0530
commit16520cde5a149f6b164b433fa06f1a5aa3b8b7e1 (patch)
tree1a7f29641a6dd39f2b07ebef3fac3a8176e8e35f /wfenginemgrservice
parent9e8d8800f6e6ea566b60589a3b6ef1f7af9bf8f6 (diff)
Critical Bug fixes wfenginemgrservice
common/RestClient.java file name:RestClient.java Change-Id: Ia6f990c5ce3fd0b4c49bb09ed4a126d88e9b0dfb Issue-ID: VFC-845 Signed-off-by: ajay priyadarshi <ajay.priyadarshi@ril.com>
Diffstat (limited to 'wfenginemgrservice')
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java41
-rw-r--r--wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java7
2 files changed, 21 insertions, 27 deletions
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java
index 5dcef70..f38fe11 100644
--- a/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/common/RestClient.java
@@ -21,7 +21,6 @@ import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
-import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
@@ -45,6 +44,8 @@ import com.google.gson.Gson;
public class RestClient {
private static final String HTTP = "http";
private static final Logger logger = LoggerFactory.getLogger(RestClient.class);
+
+ //PublicExposureUsedInTest
public static boolean isTest = false;
public enum HttpMethod {
@@ -63,7 +64,7 @@ public class RestClient {
* @throws IOException
*/
public static RestResponse executeHttp(HttpMethod method, String ip, Integer port, String url,
- HttpEntity body) throws ClientProtocolException, IOException {
+ HttpEntity body) throws IOException {
if (isTest) {
return new RestResponse();
}
@@ -82,7 +83,8 @@ public class RestClient {
HttpHost target = new HttpHost(ip, port, HTTP);
HttpRequest request = getRequest(method, url, body);
logger.info("deployfile method send ip" + ip);
- request.addHeader(Constants.AUTHORIZATION, ToolUtil.getHeader());
+ if(null != request)
+ request.addHeader(Constants.AUTHORIZATION, ToolUtil.getHeader());
httpResponse = httpclient.execute(target, request);
HttpEntity entity = httpResponse.getEntity();
@@ -147,7 +149,7 @@ public class RestClient {
* @throws IOException
*/
public static RestResponse post(String ip, int port, String url, HttpEntity requestBody)
- throws ClientProtocolException, IOException {
+ throws IOException {
return executeHttp(HttpMethod.POST, ip, port, url, requestBody);
}
@@ -165,7 +167,7 @@ public class RestClient {
* @throws IOException
*/
public static RestResponse executeHttpDeleteDeploy(HttpMethod method, String ip, Integer port,
- String url) throws ClientProtocolException, IOException {
+ String url) throws IOException {
if (isTest) {
return new RestResponse();
}
@@ -176,9 +178,7 @@ public class RestClient {
port = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrPort();
}
RestResponse result = new RestResponse();
- CloseableHttpClient httpClient = HttpClients.createDefault();
- try {
- httpClient = HttpClients.createDefault();
+ try(CloseableHttpClient httpClient = HttpClients.createDefault()){
// "http://localhost:8080/activiti-rest/service/repository/deployments/167501"
/* String deleteUrl =
Constants.HTTP_HEADER + ip + Constants.COLON + port + url + "?cascade=true";*/
@@ -201,11 +201,8 @@ public class RestClient {
}
// result.setResult(EntityUtils.toString(httpResonse.getEntity()));
} catch (Exception e) {
- e.printStackTrace();
- } finally {
- closeHttpClient(httpClient);
- }
-
+ logger.error("executeHttpDeleteDeploy ",e);
+ }
return result;
}
@@ -221,16 +218,15 @@ public class RestClient {
* @throws IOException
*/
public static RestResponse executeHttpStartIntance(HttpMethod method, String ip, Integer port,
- String url, ActivitiStartProcessRequest object) throws ClientProtocolException, IOException {
+ String url, ActivitiStartProcessRequest object) throws IOException {
if (isTest) {
return new RestResponse();
}
String returnValue = "";
RestResponse result = new RestResponse();
- CloseableHttpClient httpClient = HttpClients.createDefault();
ResponseHandler<String> responseHandler = new BasicResponseHandler();
- try {
- httpClient = HttpClients.createDefault();
+ try (
+ CloseableHttpClient httpClient = HttpClients.createDefault()){
if (ip == null) {
ip = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
}
@@ -254,12 +250,9 @@ public class RestClient {
result.setResult(returnValue);
}
} catch (Exception e) {
- e.printStackTrace();
- }
-
- finally {
- closeHttpClient(httpClient);
+ logger.error("executeHttpStartIntance :",e);
}
+
return result;
}
@@ -275,7 +268,7 @@ public class RestClient {
* @throws IOException
*/
public static RestResponse post(String ip, Integer port, String url,
- ActivitiStartProcessRequest requestBody) throws ClientProtocolException, IOException {
+ ActivitiStartProcessRequest requestBody) throws IOException {
return executeHttpStartIntance(HttpMethod.POST, ip, port, url, requestBody);
}
@@ -290,7 +283,7 @@ public class RestClient {
* @throws IOException
*/
public static RestResponse post(String ip, Integer port, String url)
- throws ClientProtocolException, IOException {
+ throws IOException {
return executeHttpDeleteDeploy(HttpMethod.DELETE, ip, port, url);
}
diff --git a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java
index 3af7f66..30835b9 100644
--- a/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java
+++ b/wfenginemgrservice/src/main/java/org/onap/workflow/externalservice/service/activitiservice/ActivitiServiceConsumer.java
@@ -20,7 +20,6 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
-import org.apache.http.client.ClientProtocolException;
import org.onap.workflow.common.Config;
import org.onap.workflow.common.EnumModuleUrl;
import org.onap.workflow.common.RestClient;
@@ -58,6 +57,7 @@ public class ActivitiServiceConsumer {
try {
res = RestClient.post(null, null, Constants.DEPLOY_BPMNFILE_URL + "/" + deploymentId);
} catch (Exception e) {
+ logger.error("Exception: ",e);
return null;
}
@@ -69,13 +69,14 @@ public class ActivitiServiceConsumer {
try {
res = RestClient.post(null, null, Constants.ACITIVI_START_INSTANCE_URL, request);
} catch (Exception e) {
+ logger.error("Exception: ",e);
return null;
}
return res;
}
public static ActivitiDeployResponse deploybpmnfile(InputStream ins, String filename)
- throws ClientProtocolException, IOException {
+ throws IOException {
try {
return deployPackage2Activiti(ins, filename);
} finally {
@@ -84,7 +85,7 @@ public class ActivitiServiceConsumer {
}
private static ActivitiDeployResponse deployPackage2Activiti(InputStream ins, String filename)
- throws ClientProtocolException, IOException {
+ throws IOException {
String ip = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrIp();
int port = Config.getWorkflowAppConfig().getMsbClientConfig().getMsbSvrPort();
RestResponse res = RestClient.post(ip, port, DEPLOY_BPMNFILE_URL,