X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=rulemgt%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Frulemgt%2Fbolt%2Fenginebolt%2FEngineService.java;fp=rulemgt%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fholmes%2Frulemgt%2Fbolt%2Fenginebolt%2FEngineService.java;h=cc20caba84b9bdc165161e1804e6755863d4a4db;hb=6e783fe6e2b456486af69bd334aa167409b29fd7;hp=15af38d6803909ece27c4a63faeec2da6dad1119;hpb=4af1314bf34bc531ce6266a2aacfee91dd00c773;p=holmes%2Frule-management.git diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineService.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineService.java index 15af38d..cc20cab 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineService.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/bolt/enginebolt/EngineService.java @@ -31,22 +31,22 @@ import org.onap.holmes.common.utils.HttpsUtils; import org.onap.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine; import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine; import org.onap.holmes.rulemgt.constant.RuleMgtConstant; -import org.onap.holmes.common.config.MicroServiceConfig; @Slf4j @Service public class EngineService { - private static final String PREFIX = "https://"; + private static final String HTTPS = "https://"; + private static final String HTTP = "http://"; private static final String PORT = ":9102"; protected HttpResponse delete(String packageName, String ip) throws Exception { HashMap headers = createHeaders(); - String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH + "/" + packageName; + String url = getRequestPref() + ip + PORT + RuleMgtConstant.ENGINE_PATH + "/" + packageName; CloseableHttpClient httpClient = null; HttpDelete httpDelete = new HttpDelete(url); try { - httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT); + httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT); return HttpsUtils.delete(httpDelete, headers, httpClient); } finally { httpDelete.releaseConnection(); @@ -58,11 +58,11 @@ public class EngineService { throws Exception { String content = GsonUtil.beanToJson(correlationCheckRule4Engine); HashMap headers = createHeaders(); - String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH; + String url = getRequestPref() + ip + PORT + RuleMgtConstant.ENGINE_PATH; CloseableHttpClient httpClient = null; HttpPost httpPost = new HttpPost(url); try { - httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT); + httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT); return HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content), httpClient); } finally { httpPost.releaseConnection(); @@ -73,11 +73,11 @@ public class EngineService { protected HttpResponse deploy(CorrelationDeployRule4Engine correlationDeployRule4Engine, String ip) throws Exception { String content = GsonUtil.beanToJson(correlationDeployRule4Engine); HashMap headers = createHeaders(); - String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH; + String url = getRequestPref() + ip + PORT + RuleMgtConstant.ENGINE_PATH; CloseableHttpClient httpClient = null; HttpPut httpPut = new HttpPut(url); try { - httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT); + httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT); return HttpsUtils.put(httpPut, headers, new HashMap<>(), new StringEntity(content),httpClient); } finally { closeHttpClient(httpClient); @@ -100,4 +100,8 @@ public class EngineService { headers.put("Accept", MediaType.APPLICATION_JSON); return headers; } + + private String getRequestPref(){ + return HttpsUtils.isHttpsEnabled() ? HTTPS : HTTP; + } }