aboutsummaryrefslogtreecommitdiffstats
path: root/so-monitoring/so-monitoring-handler/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'so-monitoring/so-monitoring-handler/src/main')
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java49
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java87
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java28
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java85
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java4
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java36
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java37
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java37
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java33
-rw-r--r--so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java119
10 files changed, 28 insertions, 487 deletions
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java
deleted file mode 100644
index 34afd825cb..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/BasicAuthorizationHttpRequestInterceptor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.monitoring.configuration.rest;
-
-import java.io.IOException;
-
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpRequest;
-import org.springframework.http.client.ClientHttpRequestExecution;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
-import org.springframework.http.client.ClientHttpResponse;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class BasicAuthorizationHttpRequestInterceptor implements ClientHttpRequestInterceptor {
-
- private final String authorization;
-
- public BasicAuthorizationHttpRequestInterceptor(final String authorization) {
- this.authorization = authorization;
- }
-
- @Override
- public ClientHttpResponse intercept(final HttpRequest request, final byte[] body,
- final ClientHttpRequestExecution execution) throws IOException {
- final HttpHeaders headers = request.getHeaders();
- headers.add("Authorization", authorization);
- return execution.execute(request, body);
- }
-}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java
deleted file mode 100644
index 1260e535a1..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpClientConnectionConfiguration.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.monitoring.configuration.rest;
-
-import java.util.concurrent.TimeUnit;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-@Service
-public class HttpClientConnectionConfiguration {
-
- @Value(value = "${rest.http.client.configuration.connTimeOutInSec:10}")
- private int connectionTimeOutInSeconds;
-
- @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}")
- private int socketTimeOutInSeconds;
-
- @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}")
- private int timeToLiveInSeconds;
-
- @Value(value = "${rest.http.client.configuration.maxConnections:10}")
- private int maxConnections;
-
- @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}")
- private int maxConnectionsPerRoute;
-
- /**
- * @return the socketTimeOut
- */
- public int getSocketTimeOutInMiliSeconds() {
- return (int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds);
- }
-
- /**
- * @return the maxConnections
- */
- public int getMaxConnections() {
- return maxConnections;
- }
-
- /**
- * @return the maxConnectionsPerRoute
- */
- public int getMaxConnectionsPerRoute() {
- return maxConnectionsPerRoute;
- }
-
- /**
- * @return the connectionTimeOut
- */
- public int getConnectionTimeOutInMilliSeconds() {
- return (int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds);
- }
-
- /**
- * @return the timeToLive
- */
- public int getTimeToLiveInMins() {
- return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds);
- }
-
- @Override
- public String toString() {
- return "HttpClientConnectionConfiguration [connectionTimeOutInSeconds=" + connectionTimeOutInSeconds
- + ", socketTimeOutInSeconds=" + socketTimeOutInSeconds + ", timeToLiveInSeconds=" + timeToLiveInSeconds
- + ", maxConnections=" + maxConnections + ", maxConnectionsPerRoute=" + maxConnectionsPerRoute + "]";
- }
-
-}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java
index a590d7908f..11c4d1b4f4 100644
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java
+++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/HttpServiceProviderConfiguration.java
@@ -19,17 +19,17 @@
*/
package org.onap.so.monitoring.configuration.rest;
-import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.CAMUNDA_REST_TEMPLATE;
-import static org.onap.so.monitoring.configuration.rest.RestTemplateConfiguration.DATABASE_REST_TEMPLATE;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import org.onap.so.monitoring.rest.service.HttpRestServiceProvider;
-import org.onap.so.monitoring.rest.service.HttpRestServiceProviderImpl;
+import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
+import org.onap.so.configuration.rest.HttpHeadersProvider;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.rest.service.HttpRestServiceProviderImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate;
/**
@@ -45,28 +45,22 @@ public class HttpServiceProviderConfiguration {
@Bean
@Qualifier(CAMUNDA_HTTP_REST_SERVICE_PROVIDER)
public HttpRestServiceProvider camundaHttpRestServiceProvider(
- @Qualifier(CAMUNDA_REST_TEMPLATE) @Autowired final RestTemplate restTemplate,
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate,
@Value(value = "${camunda.rest.api.auth:#{null}}") final String authorization) {
- return getHttpRestServiceProvider(restTemplate, authorization);
+ return getHttpRestServiceProvider(restTemplate, new BasicHttpHeadersProvider(authorization));
}
@Bean
@Qualifier(DATABASE_HTTP_REST_SERVICE_PROVIDER)
public HttpRestServiceProvider databaseHttpRestServiceProvider(
- @Qualifier(DATABASE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate,
+ @Qualifier(CONFIGURABLE_REST_TEMPLATE) @Autowired final RestTemplate restTemplate,
@Value(value = "${mso.database.rest.api.auth:#{null}}") final String authorization) {
-
- return getHttpRestServiceProvider(restTemplate, authorization);
+ return getHttpRestServiceProvider(restTemplate, new BasicHttpHeadersProvider(authorization));
}
private HttpRestServiceProvider getHttpRestServiceProvider(final RestTemplate restTemplate,
- final String authorization) {
- if (authorization != null && !authorization.isEmpty()) {
- final ClientHttpRequestInterceptor authorizationInterceptor =
- new BasicAuthorizationHttpRequestInterceptor(authorization);
- restTemplate.getInterceptors().add(authorizationInterceptor);
- }
- return new HttpRestServiceProviderImpl(restTemplate);
+ final HttpHeadersProvider httpHeadersProvider) {
+ return new HttpRestServiceProviderImpl(restTemplate, httpHeadersProvider);
}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java
deleted file mode 100644
index f8f0f687cf..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/configuration/rest/RestTemplateConfiguration.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.so.monitoring.configuration.rest;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * @author waqas.ikram@ericsson.com
- */
-@Configuration
-public class RestTemplateConfiguration {
-
- public static final String DATABASE_REST_TEMPLATE = "databaseRestTemplate";
-
- public static final String CAMUNDA_REST_TEMPLATE = "camundaRestTemplate";
-
- @Autowired
- private HttpClientConnectionConfiguration clientConnectionConfiguration;
-
- @Bean
- @Qualifier(CAMUNDA_REST_TEMPLATE)
- public RestTemplate camundaRestTemplate() {
- return new RestTemplate(httpComponentsClientHttpRequestFactory());
- }
-
- @Bean
- @Qualifier(DATABASE_REST_TEMPLATE)
- public RestTemplate dataBasecamundaRestTemplate() {
- return new RestTemplate(httpComponentsClientHttpRequestFactory());
- }
-
- @Bean
- public HttpComponentsClientHttpRequestFactory httpComponentsClientHttpRequestFactory() {
- return new HttpComponentsClientHttpRequestFactory(httpClient());
- }
-
- @Bean
- public CloseableHttpClient httpClient() {
- return HttpClientBuilder.create().setConnectionManager(poolingHttpClientConnectionManager())
- .setMaxConnPerRoute(clientConnectionConfiguration.getMaxConnectionsPerRoute())
- .setMaxConnTotal(clientConnectionConfiguration.getMaxConnections())
- .setDefaultRequestConfig(requestConfig()).build();
- }
-
- @Bean
- public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {
- return new PoolingHttpClientConnectionManager(clientConnectionConfiguration.getTimeToLiveInMins(),
- TimeUnit.MINUTES);
- }
-
- @Bean
- public RequestConfig requestConfig() {
- return RequestConfig.custom().setSocketTimeout(clientConnectionConfiguration.getSocketTimeOutInMiliSeconds())
- .setConnectTimeout(clientConnectionConfiguration.getConnectionTimeOutInMilliSeconds()).build();
- }
-}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java
index 6be6367302..49e3d4f92f 100644
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java
+++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/db/service/DatabaseServiceProviderImpl.java
@@ -30,7 +30,7 @@ import org.onap.so.monitoring.camunda.model.SoActiveInfraRequests;
import org.onap.so.monitoring.configuration.database.DatabaseUrlProvider;
import org.onap.so.monitoring.model.SoInfraRequest;
import org.onap.so.monitoring.model.SoInfraRequestBuilder;
-import org.onap.so.monitoring.rest.service.HttpRestServiceProvider;
+import org.onap.so.rest.service.HttpRestServiceProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@@ -60,7 +60,7 @@ public class DatabaseServiceProviderImpl implements DatabaseServiceProvider {
final String url = urlProvider.getSearchUrl(startTime, endTime, maxResult);
final Optional<SoActiveInfraRequests[]> optionalRequests =
- httpRestServiceProvider.postHttpRequest(filters, url, SoActiveInfraRequests[].class);
+ httpRestServiceProvider.post(filters, url, SoActiveInfraRequests[].class);
if (optionalRequests.isPresent()) {
return getSoInfraRequest(optionalRequests.get());
}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java
deleted file mode 100644
index 4d3c489fa9..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/InvalidRestRequestException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.monitoring.exception;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class InvalidRestRequestException extends RuntimeException {
- private static final long serialVersionUID = -1158414939006977465L;
-
- public InvalidRestRequestException(final String message) {
- super(message);
- }
-
- public InvalidRestRequestException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java
deleted file mode 100644
index ab25854542..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/exception/RestProcessingException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.monitoring.exception;
-
-/**
- * @author waqas.ikram@ericsson.com
- *
- */
-public class RestProcessingException extends RuntimeException {
-
- private static final long serialVersionUID = 16862313537198441L;
-
- public RestProcessingException(final String message) {
- super(message);
- }
-
- public RestProcessingException(final String message, final Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java
index e6fbb68456..b7a439fc28 100644
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java
+++ b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/CamundaProcessDataServiceProviderImpl.java
@@ -35,15 +35,15 @@ import org.onap.so.monitoring.model.ProcessDefinitionDetail;
import org.onap.so.monitoring.model.ProcessInstanceDetail;
import org.onap.so.monitoring.model.ProcessInstanceIdDetail;
import org.onap.so.monitoring.model.ProcessInstanceVariableDetail;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.google.common.base.Optional;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* @author waqas.ikram@ericsson.com
*/
@@ -64,13 +64,12 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
@Override
public Optional<ProcessInstanceIdDetail> getProcessInstanceIdDetail(final String requestId) {
final String url = urlProvider.getHistoryProcessInstanceUrl(requestId);
- final Optional<ProcessInstance[]> processInstances =
- httpRestServiceProvider.getHttpResponse(url, ProcessInstance[].class);
+ final Optional<ProcessInstance[]> processInstances = httpRestServiceProvider.get(url, ProcessInstance[].class);
if (processInstances.isPresent()) {
final ProcessInstance[] instances = processInstances.get();
- final String message = "found process instance for request id: " + requestId +
- ", result size: " + instances.length;
+ final String message =
+ "found process instance for request id: " + requestId + ", result size: " + instances.length;
LOGGER.debug(message);
if (instances.length > 0) {
@@ -79,8 +78,8 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
if (processInstance.getSuperProcessInstanceId() == null) {
return Optional.of(new ProcessInstanceIdDetail(processInstance.getId()));
}
- LOGGER.debug("found sub process instance id with super process instanceId: " +
- processInstance.getSuperProcessInstanceId());
+ LOGGER.debug("found sub process instance id with super process instanceId: "
+ + processInstance.getSuperProcessInstanceId());
}
}
}
@@ -91,8 +90,7 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
@Override
public Optional<ProcessInstanceDetail> getSingleProcessInstanceDetail(final String processInstanceId) {
final String url = urlProvider.getSingleProcessInstanceUrl(processInstanceId);
- final Optional<ProcessInstance> processInstances =
- httpRestServiceProvider.getHttpResponse(url, ProcessInstance.class);
+ final Optional<ProcessInstance> processInstances = httpRestServiceProvider.get(url, ProcessInstance.class);
if (processInstances.isPresent()) {
final ProcessInstance processInstance = processInstances.get();
@@ -111,8 +109,7 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
@Override
public Optional<ProcessDefinitionDetail> getProcessDefinition(final String processDefinitionId) {
final String url = urlProvider.getProcessDefinitionUrl(processDefinitionId);
- final Optional<ProcessDefinition> response =
- httpRestServiceProvider.getHttpResponse(url, ProcessDefinition.class);
+ final Optional<ProcessDefinition> response = httpRestServiceProvider.get(url, ProcessDefinition.class);
if (response.isPresent()) {
final ProcessDefinition processDefinition = response.get();
final String xmlDefinition = processDefinition.getBpmn20Xml();
@@ -120,16 +117,14 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
return Optional.of(new ProcessDefinitionDetail(processDefinitionId, xmlDefinition));
}
}
- LOGGER.error("Unable to find process definition for processDefinitionId: " +
- processDefinitionId);
+ LOGGER.error("Unable to find process definition for processDefinitionId: " + processDefinitionId);
return Optional.absent();
}
@Override
public List<ActivityInstanceDetail> getActivityInstance(final String processInstanceId) {
final String url = urlProvider.getActivityInstanceUrl(processInstanceId);
- final Optional<ActivityInstance[]> response =
- httpRestServiceProvider.getHttpResponse(url, ActivityInstance[].class);
+ final Optional<ActivityInstance[]> response = httpRestServiceProvider.get(url, ActivityInstance[].class);
if (response.isPresent()) {
final ActivityInstance[] activityInstances = response.get();
final List<ActivityInstanceDetail> activityInstanceDetails = new ArrayList<>(activityInstances.length);
@@ -148,8 +143,7 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
}
return activityInstanceDetails;
}
- LOGGER.error("Unable to find activity intance detail for process instance id: " +
- processInstanceId);
+ LOGGER.error("Unable to find activity intance detail for process instance id: " + processInstanceId);
return Collections.emptyList();
}
@@ -157,7 +151,7 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
public List<ProcessInstanceVariableDetail> getProcessInstanceVariable(final String processInstanceId) {
final String url = urlProvider.getProcessInstanceVariablesUrl(processInstanceId);
final Optional<ProcessInstanceVariable[]> response =
- httpRestServiceProvider.getHttpResponse(url, ProcessInstanceVariable[].class);
+ httpRestServiceProvider.get(url, ProcessInstanceVariable[].class);
if (response.isPresent()) {
final ProcessInstanceVariable[] instanceVariables = response.get();
final List<ProcessInstanceVariableDetail> instanceVariableDetails =
@@ -171,8 +165,7 @@ public class CamundaProcessDataServiceProviderImpl implements CamundaProcessData
}
return instanceVariableDetails;
}
- LOGGER.error("Unable to find process intance variable details for process instance id: "
- + processInstanceId);
+ LOGGER.error("Unable to find process intance variable details for process instance id: " + processInstanceId);
return Collections.emptyList();
}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java
deleted file mode 100644
index 4606c04e05..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProvider.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.monitoring.rest.service;
-
-import com.google.common.base.Optional;
-
-/**
- * @author waqas.ikram@ericsson.com
- */
-public interface HttpRestServiceProvider {
-
- public <T> Optional<T> getHttpResponse(final String url, final Class<T> clazz);
-
- public <T> Optional<T> postHttpRequest(final Object object, final String url, final Class<T> clazz);
-
-}
diff --git a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java b/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java
deleted file mode 100644
index 82a54c10a2..0000000000
--- a/so-monitoring/so-monitoring-handler/src/main/java/org/onap/so/monitoring/rest/service/HttpRestServiceProviderImpl.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.monitoring.rest.service;
-
-import org.onap.so.monitoring.exception.InvalidRestRequestException;
-import org.onap.so.monitoring.exception.RestProcessingException;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.client.HttpClientErrorException;
-import org.springframework.web.client.RestClientException;
-import org.springframework.web.client.RestTemplate;
-
-import com.google.common.base.Optional;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author waqas.ikram@ericsson.com
- */
-public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(HttpRestServiceProviderImpl.class);
- private final RestTemplate restTemplate;
-
- public HttpRestServiceProviderImpl(final RestTemplate restTemplate) {
- this.restTemplate = restTemplate;
- }
-
- @Override
- public <T> Optional<T> getHttpResponse(final String url, final Class<T> clazz) {
- LOGGER.trace("Will invoke HTTP GET using URL: " + url);
- try {
- final ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.GET, null, clazz);
- if (!response.getStatusCode().equals(HttpStatus.OK)) {
- final String message = "Unable to invoke HTTP GET using URL: " + url +
- ", Response Code: " + response.getStatusCode();
- LOGGER.error(message);
- return Optional.absent();
- }
-
- if (response.hasBody()) {
- return Optional.of(response.getBody());
- }
- } catch (final HttpClientErrorException httpClientErrorException) {
- final String message = "Unable to invoke HTTP GET using url: " + url + ", Response: " +
- httpClientErrorException.getRawStatusCode();
- LOGGER.error(message, httpClientErrorException);
- final int rawStatusCode = httpClientErrorException.getRawStatusCode();
- if (rawStatusCode == HttpStatus.BAD_REQUEST.value() || rawStatusCode == HttpStatus.NOT_FOUND.value()) {
- throw new InvalidRestRequestException("No result found for given url: " + url);
- }
- throw new RestProcessingException("Unable to invoke HTTP GET using URL: " + url);
-
- } catch (final RestClientException restClientException) {
- LOGGER.error("Unable to invoke HTTP GET using url: " + url, restClientException);
- throw new RestProcessingException("Unable to invoke HTTP GET using URL: " +
- url, restClientException);
- }
-
- return Optional.absent();
- }
-
- @Override
- public <T> Optional<T> postHttpRequest(final Object object, final String url, final Class<T> clazz) {
- try {
- final HttpEntity<?> request = new HttpEntity<>(object);
- final ResponseEntity<T> response = restTemplate.exchange(url, HttpMethod.POST, request, clazz);
- if (!response.getStatusCode().equals(HttpStatus.OK)) {
- final String message = "Unable to invoke HTTP GET using URL: " + url +
- ", Response Code: " + response.getStatusCode();
- LOGGER.error(message);
- return Optional.absent();
- }
-
- if (response.hasBody()) {
- return Optional.of(response.getBody());
- }
-
- } catch (final HttpClientErrorException httpClientErrorException) {
- final String message = "Unable to invoke HTTP POST using url: " + url +
- ", Response: " + httpClientErrorException.getRawStatusCode();
- LOGGER.error(message, httpClientErrorException);
- final int rawStatusCode = httpClientErrorException.getRawStatusCode();
- if (rawStatusCode == HttpStatus.BAD_REQUEST.value() || rawStatusCode == HttpStatus.NOT_FOUND.value()) {
- throw new InvalidRestRequestException("No result found for given url: " + url);
- }
- throw new RestProcessingException("Unable to invoke HTTP POST using URL: " + url);
-
- } catch (final RestClientException restClientException) {
- LOGGER.error("Unable to invoke HTTP POST using url: " + url, restClientException);
- throw new RestProcessingException("Unable to invoke HTTP POST using URL: "
- + url, restClientException);
- }
-
- return Optional.absent();
- }
-
-
-}