<dependency>\r
<groupId>org.onap.holmes.common</groupId>\r
<artifactId>holmes-actions</artifactId>\r
- <version>1.2.7</version>\r
+ <version>1.2.8</version>\r
</dependency>\r
<dependency>\r
<groupId>io.dropwizard</groupId>\r
<directory>src/main/assembly/</directory>
<filtering>false</filtering>
<includes>
- <include>nginx.conf</include>
+ <include>nginx-*.conf</include>
<include>**/holmes-frontend*.*</include>
<include>**/*.pem</include>
</includes>
package org.onap.holmes.rulemgt;
import io.dropwizard.setup.Environment;
-
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import javax.servlet.DispatcherType;
-
import lombok.extern.slf4j.Slf4j;
import org.onap.holmes.common.config.MicroServiceConfig;
import org.onap.holmes.common.dropwizard.ioc.bundle.IOCApplication;
import org.onap.holmes.common.exception.CorrelationException;
+import org.onap.holmes.common.utils.HttpsUtils;
import org.onap.holmes.common.utils.MSBRegisterUtil;
import org.onap.holmes.common.utils.transactionid.TransactionIdFilter;
import org.onap.holmes.rulemgt.dcae.DcaeConfigurationPolling;
import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;
import org.onap.msb.sdk.discovery.entity.Node;
+import javax.servlet.DispatcherType;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
@Slf4j
public class RuleActiveApp extends IOCApplication<RuleAppConfig> {
}
private MicroServiceInfo createMicroServiceInfo() {
+ String msbAddrTemplate = (HttpsUtils.isHttpsEnabled() ? "https" : "http")
+ + "://%s:%s/api/holmes-rule-mgmt/v1/healthcheck";
String[] serviceAddrInfo = MicroServiceConfig.getMicroServiceIpAndPort();
MicroServiceInfo msinfo = new MicroServiceInfo();
msinfo.setServiceName("holmes-rule-mgmt");
msinfo.setUrl("/api/holmes-rule-mgmt/v1");
msinfo.setProtocol("REST");
msinfo.setVisualRange("0|1");
- msinfo.setEnable_ssl(true);
+ msinfo.setEnable_ssl(HttpsUtils.isHttpsEnabled());
Set<Node> nodes = new HashSet<>();
Node node = new Node();
node.setIp(serviceAddrInfo[0]);
node.setPort("9101");
node.setCheckType("HTTP");
- node.setCheckUrl(String.format("https://%s:%s/api/holmes-rule-mgmt/v1/healthcheck", serviceAddrInfo[0], "9101"));
+ node.setCheckUrl(String.format(msbAddrTemplate, serviceAddrInfo[0], "9101"));
node.setCheckTimeOut("60s");
node.setCheckInterval("60s");
nodes.add(node);
return msinfo;
}
}
+
import org.onap.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;\r
import org.onap.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;\r
import org.onap.holmes.rulemgt.constant.RuleMgtConstant;\r
-import org.onap.holmes.common.config.MicroServiceConfig;\r
\r
@Slf4j\r
@Service\r
public class EngineService {\r
\r
- private static final String PREFIX = "https://";\r
+ private static final String HTTPS = "https://";\r
+ private static final String HTTP = "http://";\r
private static final String PORT = ":9102";\r
\r
protected HttpResponse delete(String packageName, String ip) throws Exception {\r
HashMap headers = createHeaders();\r
- String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH + "/" + packageName;\r
+ String url = getRequestPref() + ip + PORT + RuleMgtConstant.ENGINE_PATH + "/" + packageName;\r
CloseableHttpClient httpClient = null;\r
HttpDelete httpDelete = new HttpDelete(url);\r
try {\r
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);\r
return HttpsUtils.delete(httpDelete, headers, httpClient);\r
} finally {\r
httpDelete.releaseConnection();\r
throws Exception {\r
String content = GsonUtil.beanToJson(correlationCheckRule4Engine);\r
HashMap headers = createHeaders();\r
- String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH;\r
+ String url = getRequestPref() + ip + PORT + RuleMgtConstant.ENGINE_PATH;\r
CloseableHttpClient httpClient = null;\r
HttpPost httpPost = new HttpPost(url);\r
try {\r
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);\r
return HttpsUtils.post(httpPost, headers, new HashMap<>(), new StringEntity(content), httpClient);\r
} finally {\r
httpPost.releaseConnection();\r
protected HttpResponse deploy(CorrelationDeployRule4Engine correlationDeployRule4Engine, String ip) throws Exception {\r
String content = GsonUtil.beanToJson(correlationDeployRule4Engine);\r
HashMap headers = createHeaders();\r
- String url = PREFIX + ip + PORT + RuleMgtConstant.ENGINE_PATH;\r
+ String url = getRequestPref() + ip + PORT + RuleMgtConstant.ENGINE_PATH;\r
CloseableHttpClient httpClient = null;\r
HttpPut httpPut = new HttpPut(url);\r
try {\r
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);\r
return HttpsUtils.put(httpPut, headers, new HashMap<>(), new StringEntity(content),httpClient);\r
} finally {\r
closeHttpClient(httpClient);\r
headers.put("Accept", MediaType.APPLICATION_JSON);\r
return headers;\r
}\r
+\r
+ private String getRequestPref(){\r
+ return HttpsUtils.isHttpsEnabled() ? HTTPS : HTTP;\r
+ }\r
}\r
*/
package org.onap.holmes.rulemgt.dcae;
-import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import javax.ws.rs.core.MediaType;
CloseableHttpClient httpClient = null;
HttpGet httpGet = new HttpGet(url);
try {
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpResponse httpResponse = HttpsUtils.get(httpGet, headers, httpClient);
String response = HttpsUtils.extractResponseEntity(httpResponse);
return JSONObject.parseObject(response, RuleQueryListResponse.class);
CloseableHttpClient httpClient = null;
HttpPut httpPut = new HttpPut(url);
try {
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
httpResponse = HttpsUtils
.put(httpPut, headers, new HashMap<>(), new StringEntity(content), httpClient);
} catch (UnsupportedEncodingException e) {
CloseableHttpClient httpClient = null;
HttpDelete httpDelete = new HttpDelete(url + "/" + correlationRule.getRuleId());
try {
- httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);
+ httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);
HttpsUtils.delete(httpDelete, headers, httpClient);
} catch (Exception e) {
log.warn("Failed to delete rule, the rule id is : " + correlationRule.getRuleId()
package org.onap.holmes.rulemgt.msb;
-import java.io.IOException;
-
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
public List<String> getInstanceList() throws Exception {
String response;
HttpGet httpGet = new HttpGet(url);
- try (CloseableHttpClient httpClient = HttpsUtils.getHttpClient(HttpsUtils.DEFUALT_TIMEOUT)) {
+ try (CloseableHttpClient httpClient = HttpsUtils.getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT)) {
HttpResponse httpResponse = HttpsUtils.get(httpGet, new HashMap<>(), httpClient);
response = HttpsUtils.extractResponseEntity(httpResponse);
} catch (Exception e) {
\r
\r
import static org.hamcrest.MatcherAssert.assertThat;\r
-import static org.hamcrest.Matchers.any;\r
import static org.hamcrest.Matchers.equalTo;\r
\r
import java.util.HashMap;\r
import org.apache.http.client.methods.CloseableHttpResponse;\r
import org.apache.http.impl.client.CloseableHttpClient;\r
import org.apache.http.impl.client.HttpClients;\r
-import org.easymock.EasyMock;\r
-import org.hamcrest.Matchers;\r
import org.junit.Before;\r
import org.junit.Rule;\r
import org.junit.Test;\r
public void testEngineService_closeHttpClient_ok() throws Exception {\r
PowerMock.resetAll();\r
CloseableHttpClient closeableHttpClient = HttpsUtils\r
- .getHttpClient(HttpsUtils.DEFUALT_TIMEOUT);\r
+ .getConditionalHttpsClient(HttpsUtils.DEFUALT_TIMEOUT);\r
Whitebox.invokeMethod(engineService, "closeHttpClient", closeableHttpClient);\r
}\r
\r
CloseableHttpClient clientMock = createMock(CloseableHttpClient.class);
HttpResponse httpResponseMock = createMock(HttpResponse.class);
- expect(HttpsUtils.getHttpClient(30000)).andReturn(clientMock);
+ expect(HttpsUtils.getConditionalHttpsClient(30000)).andReturn(clientMock);
expect(HttpsUtils.get(anyObject(HttpGet.class), anyObject(HashMap.class), anyObject(CloseableHttpClient.class)))
.andReturn(httpResponseMock);
expect(HttpsUtils.extractResponseEntity(httpResponseMock)).andReturn(JSONObject.toJSONString(ruleQueryListResponse));
clientMock.close();
expectLastCall();
- expect(HttpsUtils.getHttpClient(30000)).andReturn(clientMock);
+ expect(HttpsUtils.getConditionalHttpsClient(30000)).andReturn(clientMock);
expect(HttpsUtils.delete(anyObject(HttpDelete.class), anyObject(HashMap.class), anyObject(CloseableHttpClient.class)))
.andReturn(httpResponseMock);
clientMock.close();
expectLastCall();
- expect(HttpsUtils.getHttpClient(30000)).andReturn(clientMock);
+ expect(HttpsUtils.getConditionalHttpsClient(30000)).andReturn(clientMock);
expect(HttpsUtils.put(anyObject(HttpPut.class), anyObject(HashMap.class), anyObject(HashMap.class),
anyObject(StringEntity.class), anyObject(CloseableHttpClient.class)))
.andReturn(httpResponseMock);
CloseableHttpClient clientMock = createMock(CloseableHttpClient.class);
HttpResponse httpResponseMock = createMock(HttpResponse.class);
- expect(HttpsUtils.getHttpClient(30000)).andReturn(clientMock);
+ expect(HttpsUtils.getConditionalHttpsClient(30000)).andReturn(clientMock);
expect(HttpsUtils.delete(anyObject(HttpDelete.class), anyObject(HashMap.class), anyObject(CloseableHttpClient.class)))
.andReturn(httpResponseMock);
clientMock.close();
expectLastCall();
- expect(HttpsUtils.getHttpClient(30000)).andReturn(clientMock);
+ expect(HttpsUtils.getConditionalHttpsClient(30000)).andReturn(clientMock);
expect(HttpsUtils.put(anyObject(HttpPut.class), anyObject(HashMap.class), anyObject(HashMap.class),
anyObject(StringEntity.class), anyObject(CloseableHttpClient.class)))
.andReturn(httpResponseMock);
CloseableHttpClient clientMock = createMock(CloseableHttpClient.class);
HttpResponse httpResponseMock = createMock(HttpResponse.class);
- expect(HttpsUtils.getHttpClient(30000)).andReturn(clientMock);
+ expect(HttpsUtils.getConditionalHttpsClient(30000)).andReturn(clientMock);
expect(HttpsUtils.get(anyObject(HttpGet.class), anyObject(HashMap.class), anyObject(CloseableHttpClient.class)))
.andReturn(httpResponseMock);
expect(HttpsUtils.extractResponseEntity(httpResponseMock)).andReturn("{\"correlationRules\": [], \"totalCount\": 0}");