diff options
Diffstat (limited to 'mso-api-handlers')
2 files changed, 19 insertions, 16 deletions
diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java index 5b6fbc8378..9bb5cab9b5 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/TestApplication.java @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Profile; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; -@SpringBootApplication(scanBasePackages = { "org.onap.so.db" }) +@SpringBootApplication(scanBasePackages = { "org.onap.so" }) @Profile("test") public class TestApplication { public static void main(String... args) { @@ -35,8 +35,4 @@ public class TestApplication { System.getProperties().setProperty("mso.db", "MARIADB"); System.getProperties().setProperty("server.name", "Springboot"); } - @Bean - public RestTemplate restTemplate() { - return new RestTemplate( new HttpComponentsClientHttpRequestFactory()); - } } 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 e68bdb3772..07d185b3af 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 @@ -20,6 +20,17 @@ package org.onap.so.db.request.client; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.annotation.PostConstruct; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriBuilder; + import org.apache.http.HttpStatus; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -41,6 +52,7 @@ import org.springframework.core.ParameterizedTypeReference; 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; @@ -50,16 +62,6 @@ import org.springframework.web.client.RestTemplate; import uk.co.blackpepper.bowman.ClientFactory; import uk.co.blackpepper.bowman.Configuration; -import javax.annotation.PostConstruct; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriBuilder; -import java.net.URI; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Iterator; - @Component("RequestsDbClient") @Primary public class RequestsDbClient { @@ -188,7 +190,12 @@ public class RequestsDbClient { URI uri = getUri(checkInstanceNameDuplicate); HttpEntity<InstanceNameDuplicateCheckRequest> entity = new HttpEntity<>(new InstanceNameDuplicateCheckRequest(instanceIdMap, instanceName, requestScope), headers); try{ - return restTemplate.exchange(uri, HttpMethod.POST, entity, InfraActiveRequests.class).getBody(); + 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; |