aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2020-06-19 14:11:45 +0000
committerGerrit Code Review <gerrit@onap.org>2020-06-19 14:11:45 +0000
commit0abec191b0645a80c9bc5df4af3423a9377b83db (patch)
treed5a1c8aa302d8c1b8c689c8ed32e36d672581e0d /mso-api-handlers
parentdcca3afc8f9c4de72e84a7573932544996438c7c (diff)
parent9868f1749ac413b5b7df287d35983bf24ce517ea (diff)
Merge "Prepare for java 11"
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-common/.gitignore1
-rw-r--r--mso-api-handlers/mso-api-handler-common/pom.xml1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/.gitignore1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml29
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java2
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java3
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java4
-rw-r--r--mso-api-handlers/mso-requests-db/pom.xml5
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java4
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java2
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java1
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java312
-rw-r--r--mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java26
-rw-r--r--mso-api-handlers/pom.xml1
15 files changed, 164 insertions, 231 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/.gitignore b/mso-api-handlers/mso-api-handler-common/.gitignore
new file mode 100644
index 0000000000..da7560e07f
--- /dev/null
+++ b/mso-api-handlers/mso-api-handler-common/.gitignore
@@ -0,0 +1 @@
+/.apt_generated_tests/
diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml
index 865de7998f..2fbdbbfc3c 100644
--- a/mso-api-handlers/mso-api-handler-common/pom.xml
+++ b/mso-api-handlers/mso-api-handler-common/pom.xml
@@ -23,7 +23,6 @@
<reflections-version>0.9.9-RC1</reflections-version>
<paranamer-version>2.5.2</paranamer-version>
<scannotation-version>1.0.3</scannotation-version>
- <java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
diff --git a/mso-api-handlers/mso-api-handler-infra/.gitignore b/mso-api-handlers/mso-api-handler-infra/.gitignore
index ae3c172604..9920c72893 100644
--- a/mso-api-handlers/mso-api-handler-infra/.gitignore
+++ b/mso-api-handlers/mso-api-handler-infra/.gitignore
@@ -1 +1,2 @@
/bin/
+/.apt_generated_tests/
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index 7e891f1e33..2f25d409d2 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -25,7 +25,6 @@
<reflections-version>0.9.9-RC1</reflections-version>
<paranamer-version>2.5.2</paranamer-version>
<scannotation-version>1.0.3</scannotation-version>
- <java.version>1.8</java.version>
</properties>
<dependencyManagement>
<dependencies>
@@ -53,10 +52,14 @@
<artifactId>camunda-engine</artifactId>
</dependency>
<dependency>
+ <groupId>org.javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.25.0-GA</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
-
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
@@ -127,6 +130,10 @@
<version>${json4s-core-version}</version>
</dependency>
<dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
@@ -151,7 +158,6 @@
<artifactId>mso-catalog-db</artifactId>
<version>${project.version}</version>
</dependency>
-
<!-- Test Dependencies -->
<dependency>
<groupId>pl.pragmatists</groupId>
@@ -232,7 +238,7 @@
<dependency>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>aaf-cadi-aaf</artifactId>
- <version>2.1.9</version>
+ <version>${aaf.cadi.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
@@ -240,6 +246,21 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-core</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <version>2.3.0</version>
+ </dependency>
</dependencies>
<build>
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
index b21b468ce3..0b968520d6 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java
@@ -39,6 +39,7 @@ import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.onap.aaiclient.client.aai.AAIVersion;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandlerinfra.BaseTest;
import org.onap.so.apihandlerinfra.exceptions.ApiException;
@@ -46,7 +47,6 @@ import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestrationRequest;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Distribution;
import org.onap.so.apihandlerinfra.tenantisolationbeans.DistributionStatus;
import org.onap.so.apihandlerinfra.tenantisolationbeans.Status;
-import org.onap.aaiclient.client.aai.AAIVersion;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java
index f0d717df3c..ea1aeb95a6 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java
@@ -20,7 +20,6 @@
package org.onap.so.db.request.data.repository;
-import java.util.List;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatusId;
import org.springframework.data.jpa.repository.JpaRepository;
@@ -35,7 +34,7 @@ public interface OperationalEnvServiceModelStatusRepository
public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndRequestId(String operationalEnvId,
String requestId);
- public List<OperationalEnvServiceModelStatus> findAllByOperationalEnvIdAndRequestId(
+ public OperationalEnvServiceModelStatus[] findAllByOperationalEnvIdAndRequestId(
@Param("OPERATIONAL_ENV_ID") String operationalEnvId, @Param("REQUEST_ID") String requestId);
public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java
index 1093c79638..953361fd40 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OrchestrationTaskRepository.java
@@ -24,10 +24,9 @@ import org.onap.so.db.request.beans.OrchestrationTask;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-import java.util.List;
@RepositoryRestResource(collectionResourceRel = "orchestrationTask", path = "orchestrationTask")
public interface OrchestrationTaskRepository extends JpaRepository<OrchestrationTask, String> {
- public List<OrchestrationTask> findByStatus(@Param("status") String status);
+ public OrchestrationTask[] findByStatus(@Param("status") String status);
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java
index cb02b7c491..21bc2a697a 100644
--- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java
+++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/RequestProcessingDataRepository.java
@@ -37,11 +37,11 @@ public interface RequestProcessingDataRepository extends JpaRepository<RequestPr
RequestProcessingData findOneBySoRequestIdAndName(@Param("SO_REQUEST_ID") String soRequestId,
@Param("NAME") String name);
- List<RequestProcessingData> findBySoRequestIdOrderByGroupingIdDesc(@Param("SO_REQUEST_ID") String soRequestId);
+ RequestProcessingData[] findBySoRequestIdOrderByGroupingIdDesc(@Param("SO_REQUEST_ID") String soRequestId);
RequestProcessingData[] findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc(
@Param("SO_REQUEST_ID") String soRequestId, @Param("IS_INTERNAL_DATA") Boolean isDataInternal);
- List<RequestProcessingData> findByGroupingIdAndNameAndTag(@Param("GROUPING_ID") String groupingId,
+ RequestProcessingData[] findByGroupingIdAndNameAndTag(@Param("GROUPING_ID") String groupingId,
@Param("NAME") String name, @Param("TAG") String tag);
}
diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml
index 37bb4175a5..9a9d12a047 100644
--- a/mso-api-handlers/mso-requests-db/pom.xml
+++ b/mso-api-handlers/mso-requests-db/pom.xml
@@ -17,11 +17,6 @@
</properties>
<dependencies>
<dependency>
- <groupId>uk.co.blackpepper.bowman</groupId>
- <artifactId>bowman-client</artifactId>
- <version>0.3.0</version>
- </dependency>
- <dependency>
<groupId>org.onap.so</groupId>
<artifactId>common</artifactId>
<version>${project.version}</version>
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
index cf6cf687b0..cc721d38b6 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/InfraRequests.java
@@ -40,8 +40,6 @@ import javax.persistence.TemporalType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.onap.so.requestsdb.TimestampXMLAdapter;
-import uk.co.blackpepper.bowman.annotation.LinkedResource;
-import uk.co.blackpepper.bowman.annotation.ResourceId;
@MappedSuperclass
public abstract class InfraRequests implements java.io.Serializable {
@@ -164,7 +162,6 @@ public abstract class InfraRequests implements java.io.Serializable {
@JoinColumn(name = "SO_REQUEST_ID", referencedColumnName = "REQUEST_ID", updatable = false)
private List<CloudApiRequests> cloudApiRequests = new ArrayList<>();
- @ResourceId
public URI getRequestURI() {
return URI.create(this.requestId);
}
@@ -443,7 +440,6 @@ public abstract class InfraRequests implements java.io.Serializable {
return requestAction;
}
- @LinkedResource
public List<CloudApiRequests> getCloudApiRequests() {
return cloudApiRequests;
}
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java
index 2278c8cd9d..a7444a49d1 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/OperationalEnvServiceModelStatus.java
@@ -22,6 +22,7 @@ package org.onap.so.db.request.beans;
import java.io.Serializable;
import java.util.Date;
+import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@@ -31,7 +32,6 @@ import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-import java.util.Objects;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java
index e386789c7f..c52d311146 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/RequestProcessingData.java
@@ -48,7 +48,6 @@ import com.openpojo.business.annotation.BusinessKey;
*/
@Entity
-
@JsonInclude(Include.NON_NULL)
@Table(name = "request_processing_data")
public class RequestProcessingData implements Serializable {
diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
index 6aa00caeed..17b22ec216 100644
--- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
+++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java
@@ -22,32 +22,26 @@ package org.onap.so.db.request.client;
import java.net.URI;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
import javax.annotation.PostConstruct;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
-import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.request.beans.ArchivedInfraRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.OperationStatus;
import org.onap.so.db.request.beans.OperationalEnvDistributionStatus;
import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus;
+import org.onap.so.db.request.beans.OrchestrationTask;
import org.onap.so.db.request.beans.RequestProcessingData;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import org.onap.so.db.request.beans.SiteStatus;
import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus;
import org.onap.so.db.request.beans.WatchdogDistributionStatus;
import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup;
-import org.onap.so.db.request.beans.OrchestrationTask;
import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest;
-import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
@@ -56,14 +50,9 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
-import uk.co.blackpepper.bowman.ClientFactory;
-import uk.co.blackpepper.bowman.Configuration;
@Component("RequestsDbClient")
@Primary
@@ -166,25 +155,6 @@ public class RequestsDbClient {
return endpoint;
}
- protected ClientFactory getClientFactory() {
- URI baseUri = UriBuilder.fromUri(getEndpoint()).build();
- ClientHttpRequestFactory factory =
- new BufferingClientHttpRequestFactory(new HttpComponentsClientHttpRequestFactory());
-
- return Configuration.builder().setBaseUri(baseUri).setClientHttpRequestFactory(factory)
- .setRestTemplateConfigurer(restTemplate -> {
- restTemplate.getInterceptors().add((new SOSpringClientFilter()));
- restTemplate.getInterceptors().add((new SpringClientPayloadFilter()));
-
- restTemplate.getInterceptors().add((request, body, execution) -> {
-
- request.getHeaders().add(HttpHeaders.AUTHORIZATION, msoAdaptersAuth);
- return execution.execute(request, body);
- });
- }).build().buildClientFactory();
- }
-
-
public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(Map<String, String> orchestrationMap) {
URI uri = getUri(cloudOrchestrationFiltersFromInfraActive);
HttpHeaders headers = getHttpHeaders();
@@ -201,30 +171,21 @@ public class RequestsDbClient {
}
public List<InfraActiveRequests> getInProgressVolumeGroupsAndVfModules() {
- HttpHeaders headers = getHttpHeaders();
URI uri = getUri(endpoint + getInProgressVolumeGroupsAndVfModules);
- HttpEntity<Map<String, List<String>>> entity = new HttpEntity<>(headers);
- return restTemplate
- .exchange(uri, HttpMethod.GET, entity, new ParameterizedTypeReference<List<InfraActiveRequests>>() {})
- .getBody();
+
+ return getMultipleResponse(uri, new ParameterizedTypeReference<List<InfraActiveRequests>>() {});
+
}
public InfraActiveRequests getInfraActiveRequestbyRequestId(String requestId) {
- try {
- HttpEntity<?> entity = getHttpEntity();
- InfraActiveRequests infraActiveRequests =
- restTemplate.exchange(getUri(endpoint + "/infraActiveRequests/" + requestId), HttpMethod.GET,
- entity, InfraActiveRequests.class).getBody();
- if (infraActiveRequests != null) {
- infraActiveRequests.setRequestId(requestId);
- }
- return infraActiveRequests;
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
+
+
+ InfraActiveRequests infraActiveRequests =
+ getSingleResponse(getUri(endpoint + "/infraActiveRequests/" + requestId), InfraActiveRequests.class);
+ if (infraActiveRequests != null) {
+ infraActiveRequests.setRequestId(requestId);
}
+ return infraActiveRequests;
}
public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
@@ -238,9 +199,8 @@ public class RequestsDbClient {
}
public InfraActiveRequests checkVnfIdStatus(String operationalEnvironmentId) {
- HttpEntity<?> entity = getHttpEntity();
URI uri = getUri(checkVnfIdStatus + operationalEnvironmentId);
- return restTemplate.exchange(uri, HttpMethod.GET, entity, InfraActiveRequests.class).getBody();
+ return getSingleResponse(uri, InfraActiveRequests.class);
}
public InfraActiveRequests checkInstanceNameDuplicate(Map<String, String> instanceIdMap, String instanceName,
@@ -249,66 +209,40 @@ public class RequestsDbClient {
URI uri = getUri(checkInstanceNameDuplicate);
HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>(
new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers);
- try {
- ResponseEntity<InfraActiveRequests> response =
- restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class);
- if (response != null && response.hasBody()) {
- return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody();
- } else {
- return null;
- }
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
- }
+
+ return postSingleResponse(uri, entity, InfraActiveRequests.class);
}
public OperationStatus getOneByServiceIdAndOperationId(String serviceId, String operationId) {
- try {
- HttpEntity<?> entity = getHttpEntity();
- OperationStatus operationStatus = restTemplate.exchange(getUri(
- UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)).queryParam(SERVICE_ID, serviceId)
- .queryParam(OPERATION_ID, operationId).build().toString()),
- HttpMethod.GET, entity, OperationStatus.class).getBody();
- if (operationStatus != null) {
- operationStatus.setServiceId(serviceId);
- operationStatus.setOperationId(operationId);
- }
-
- return operationStatus;
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
+ OperationStatus operationStatus = getSingleResponse(
+ getUri(UriBuilder.fromUri(getUri(findOneByServiceIdAndOperationIdURI)).queryParam(SERVICE_ID, serviceId)
+ .queryParam(OPERATION_ID, operationId).build().toString()),
+ OperationStatus.class);
+ if (operationStatus != null) {
+ operationStatus.setServiceId(serviceId);
+ operationStatus.setOperationId(operationId);
}
+ return operationStatus;
}
public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(
String operationalEnvironmentId, String serviceModelVersionId, String requestId) {
- try {
- HttpEntity<?> entity = getHttpEntity();
- OperationalEnvServiceModelStatus modelStatus = restTemplate.exchange(
- getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI)
- .queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId)
- .queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId)
- .queryParam(REQUEST_ID, requestId).build().toString()),
- HttpMethod.GET, entity, OperationalEnvServiceModelStatus.class).getBody();
- if (null != modelStatus) {
- modelStatus.setOperationalEnvId(operationalEnvironmentId);
- modelStatus.setServiceModelVersionId(serviceModelVersionId);
- modelStatus.setRequestId(requestId);
- }
- return modelStatus;
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
+
+ OperationalEnvServiceModelStatus modelStatus =
+ getSingleResponse(
+ getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI)
+ .queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId)
+ .queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId)
+ .queryParam(REQUEST_ID, requestId).build().toString()),
+ OperationalEnvServiceModelStatus.class);
+ if (null != modelStatus) {
+ modelStatus.setOperationalEnvId(operationalEnvironmentId);
+ modelStatus.setServiceModelVersionId(serviceModelVersionId);
+ modelStatus.setRequestId(requestId);
}
+ return modelStatus;
+
}
public List<OperationalEnvServiceModelStatus> getAllByOperationalEnvIdAndRequestId(String operationalEnvironmentId,
@@ -320,30 +254,18 @@ public class RequestsDbClient {
}
public OperationalEnvDistributionStatus getDistributionStatusById(String distributionId) {
- try {
- HttpEntity<?> entity = getHttpEntity();
- OperationalEnvDistributionStatus distributionStatus =
- restTemplate.exchange(getUri(operationalEnvDistributionStatusURI + distributionId), HttpMethod.GET,
- entity, OperationalEnvDistributionStatus.class).getBody();
- if (null != distributionStatus) {
- distributionStatus.setDistributionId(distributionId);
- }
- return distributionStatus;
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
+
+ OperationalEnvDistributionStatus distributionStatus = getSingleResponse(
+ getUri(operationalEnvDistributionStatusURI + distributionId), OperationalEnvDistributionStatus.class);
+ if (null != distributionStatus) {
+ distributionStatus.setDistributionId(distributionId);
}
+ return distributionStatus;
+
}
private List<OperationalEnvServiceModelStatus> getMultipleOperationalEnvServiceModelStatus(URI uri) {
- Iterable<OperationalEnvServiceModelStatus> iterable =
- getClientFactory().create(OperationalEnvServiceModelStatus.class).getAll(uri);
- List<OperationalEnvServiceModelStatus> serviceModelStatuses = new ArrayList<>();
- Iterator<OperationalEnvServiceModelStatus> statusIterator = iterable.iterator();
- statusIterator.forEachRemaining(serviceModelStatuses::add);
- return serviceModelStatuses;
+ return getMultipleResponse(uri, new ParameterizedTypeReference<List<OperationalEnvServiceModelStatus>>() {});
}
public void save(InfraActiveRequests infraActiveRequests) {
@@ -376,38 +298,16 @@ public class RequestsDbClient {
}
public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) {
- RestTemplate template = new RestTemplate();
- HttpHeaders headers = new HttpHeaders();
- headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
- headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
- headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
+
URI uri = getUri(host + "/infraActiveRequests/" + requestId);
- try {
- InfraActiveRequests infraActiveRequests = template
- .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody();
- if (infraActiveRequests != null) {
- infraActiveRequests.setRequestId(requestId);
- }
- return infraActiveRequests;
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
- }
+
+ return getSingleResponse(uri, InfraActiveRequests.class);
}
public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) {
- RestTemplate template = new RestTemplate();
- template.getInterceptors().add(new SOSpringClientFilter());
- template.getInterceptors().add(new SpringClientPayloadFilter());
- HttpHeaders headers = new HttpHeaders();
- headers.set(HttpHeaders.AUTHORIZATION, basicAuth);
- headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
- headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId());
- HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers);
- template.put(uri, entity);
+ HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, getHttpHeaders());
+ restTemplate.put(uri, entity);
}
protected URI getUri(String uri) {
@@ -437,41 +337,30 @@ public class RequestsDbClient {
public List<RequestProcessingData> getExternalRequestProcessingDataBySoRequestId(String soRequestId) {
URI uri = getUri(UriBuilder.fromUri(getEndpoint() + findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc)
.queryParam(SO_REQUEST_ID, soRequestId).queryParam(IS_INTERNAL_DATA, false).build().toString());
- ResponseEntity<RequestProcessingData[]> array =
- restTemplate.exchange(uri, HttpMethod.GET, getHttpEntity(), RequestProcessingData[].class);
- if (array != null) {
- return Arrays.asList(array.getBody());
- } else {
- return null;
- }
+ return getMultipleResponse(uri, new ParameterizedTypeReference<List<RequestProcessingData>>() {});
}
public RequestProcessingData getRequestProcessingDataBySoRequestIdAndNameAndGrouping(String soRequestId,
String name, String groupingId) {
- return getClientFactory().create(RequestProcessingData.class)
- .get(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndGroupIdAndName)
- .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name)
- .queryParam(GROUPING_ID, groupingId).build().toString()));
+ return getSingleResponse(getUri(
+ UriBuilder.fromUri(endpoint + findBySoRequestIdAndGroupIdAndName).queryParam(SO_REQUEST_ID, soRequestId)
+ .queryParam(NAME, name).queryParam(GROUPING_ID, groupingId).build().toString()),
+ RequestProcessingData.class);
}
public List<RequestProcessingData> getRequestProcessingDataByGroupingIdAndNameAndTag(String groupingId, String name,
String tag) {
- Iterable<RequestProcessingData> requestProcessingDataListIt =
- getClientFactory().create(RequestProcessingData.class)
- .getAll(getUri(UriBuilder.fromUri(endpoint + findByGroupingIdAndNameAndTag)
- .queryParam(GROUPING_ID, groupingId).queryParam(NAME, name).queryParam(TAG, tag).build()
- .toString()));
-
- List<RequestProcessingData> requestProcessingDataList =
- StreamSupport.stream(requestProcessingDataListIt.spliterator(), false).collect(Collectors.toList());
- return requestProcessingDataList;
+ return getMultipleResponse(
+ getUri(UriBuilder.fromUri(endpoint + findByGroupingIdAndNameAndTag).queryParam(GROUPING_ID, groupingId)
+ .queryParam(NAME, name).queryParam(TAG, tag).build().toString()),
+ new ParameterizedTypeReference<List<RequestProcessingData>>() {});
}
public RequestProcessingData getRequestProcessingDataBySoRequestIdAndName(String soRequestId, String name) {
- return getClientFactory().create(RequestProcessingData.class)
- .get(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndName)
- .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name).build().toString()));
+ return getSingleResponse(getUri(UriBuilder.fromUri(endpoint + findBySoRequestIdAndName)
+ .queryParam(SO_REQUEST_ID, soRequestId).queryParam(NAME, name).build().toString()),
+ RequestProcessingData.class);
}
@@ -491,26 +380,14 @@ public class RequestsDbClient {
}
private List<RequestProcessingData> getRequestProcessingData(URI uri) {
- Iterable<RequestProcessingData> requestProcessingDataIterator =
- getClientFactory().create(RequestProcessingData.class).getAll(uri);
- List<RequestProcessingData> requestProcessingDataList = new ArrayList<>();
- Iterator<RequestProcessingData> it = requestProcessingDataIterator.iterator();
- it.forEachRemaining(requestProcessingDataList::add);
- return requestProcessingDataList;
+ return getMultipleResponse(uri, new ParameterizedTypeReference<List<RequestProcessingData>>() {});
}
public InfraActiveRequests findOneByRequestId(String requestId) {
- try {
- HttpEntity<?> entity = getHttpEntity();
- return restTemplate.exchange(
- getUri(UriBuilder.fromUri(findOneByRequestId).queryParam(REQUEST_ID, requestId).build().toString()),
- HttpMethod.GET, entity, InfraActiveRequests.class).getBody();
- } catch (HttpClientErrorException e) {
- if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
- return null;
- }
- throw e;
- }
+ return getSingleResponse(
+ getUri(UriBuilder.fromUri(findOneByRequestId).queryParam(REQUEST_ID, requestId).build().toString()),
+ InfraActiveRequests.class);
+
}
// From and To are defaulted to ignore start/endtime on query to database
@@ -525,11 +402,8 @@ public class RequestsDbClient {
}
public List<OrchestrationTask> getAllOrchestrationTasks() {
- String url = UriBuilder.fromUri(getUri(orchestrationTasksURI)).build().toString();
- HttpEntity<?> entity = getHttpEntity();
- return restTemplate
- .exchange(url, HttpMethod.GET, entity, new ParameterizedTypeReference<List<OrchestrationTask>>() {})
- .getBody();
+ return getMultipleResponse(getUri(orchestrationTasksURI),
+ new ParameterizedTypeReference<List<OrchestrationTask>>() {});
}
public OrchestrationTask getOrchestrationTask(String taskId) {
@@ -605,4 +479,54 @@ public class RequestsDbClient {
return new HttpEntity<>(headers);
}
+ private <T> T getSingleResponse(URI uri, Class<T> clazz) {
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate.exchange(uri, HttpMethod.GET, entity, clazz).getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return null;
+ }
+ throw e;
+ }
+ }
+
+ private <T> List<T> getMultipleResponse(URI uri, ParameterizedTypeReference<List<T>> type) {
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate.exchange(uri, HttpMethod.GET, entity, type).getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return new ArrayList<T>();
+ }
+ throw e;
+ }
+ }
+
+ private <T> T postSingleResponse(URI uri, HttpEntity<?> payload, Class<T> clazz) {
+ try {
+ HttpEntity<?> entity = new HttpEntity<>(payload.getBody(), getHttpHeaders());
+ return restTemplate.exchange(uri, HttpMethod.POST, entity, clazz).getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return null;
+ }
+ throw e;
+ }
+ }
+
+ private <T> List<T> postMultipleResponse(URI uri, HttpEntity<?> payload, ParameterizedTypeReference<List<T>> type) {
+ try {
+ HttpEntity<?> entity = new HttpEntity<>(payload.getBody(), getHttpHeaders());
+ ResponseEntity<List<T>> result = restTemplate.exchange(uri, HttpMethod.POST, entity, type);
+
+ return result.getBody();
+ } catch (HttpClientErrorException e) {
+ if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+ return new ArrayList<T>();
+ }
+ throw e;
+ }
+ }
+
}
diff --git a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java
index 0ad8d1458e..32886bf62e 100644
--- a/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java
+++ b/mso-api-handlers/mso-requests-db/src/test/java/org/onap/so/db/request/client/RequestDbClientTest.java
@@ -1,11 +1,14 @@
package org.onap.so.db.request.client;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.when;
import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
import javax.ws.rs.core.UriBuilder;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -13,21 +16,14 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.beans.RequestProcessingData;
-import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.BufferingClientHttpRequestFactory;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
-import uk.co.blackpepper.bowman.ClientFactory;
-import uk.co.blackpepper.bowman.Configuration;
@RunWith(MockitoJUnitRunner.class)
@@ -61,12 +57,16 @@ public class RequestDbClientTest {
@Test
public void testGetRequestProcessingDataBySoRequestIdAndIsInternalData() {
Mockito.doReturn("host").when(requestsDbClient).getEndpoint();
- requestsDbClient.getExternalRequestProcessingDataBySoRequestId("12345");
URI uri = URI.create(UriBuilder
.fromUri("host/requestProcessingData/search/findBySoRequestIdAndIsDataInternalOrderByGroupingIdDesc")
.queryParam("SO_REQUEST_ID", "12345").queryParam("IS_INTERNAL_DATA", false).build().toString());
- Mockito.verify(restTemplate, times(1)).exchange(eq(uri), eq(HttpMethod.GET), isA(HttpEntity.class),
- eq(RequestProcessingData[].class));
+ when(restTemplate.exchange(eq(uri), eq(HttpMethod.GET), isA(HttpEntity.class),
+ isA(ParameterizedTypeReference.class))).thenReturn(
+ new ResponseEntity<List<RequestProcessingData>>(new ArrayList<RequestProcessingData>(),
+ HttpStatus.NOT_FOUND));
+ assertTrue(requestsDbClient.getExternalRequestProcessingDataBySoRequestId("12345").isEmpty());
+
+
}
}
diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml
index db939a6868..86e1c5783f 100644
--- a/mso-api-handlers/pom.xml
+++ b/mso-api-handlers/pom.xml
@@ -19,7 +19,6 @@
<module>mso-api-handler-common</module>
<module>mso-api-handler-infra</module>
</modules>
-
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>