summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-requests-db/src/main/java
diff options
context:
space:
mode:
authorSmokowski, Steve (ss835w) <ss835w@us.att.com>2018-09-21 05:20:24 -0400
committerMarcus G K Williams <marcus.williams@intel.com>2018-09-24 17:47:59 -0700
commitf55174af939c15cb4eac3ba51022f51c166ec6ba (patch)
tree76de80571d7330e5c28532161a5f14cdec7017bf /mso-api-handlers/mso-requests-db/src/main/java
parentd3bbcec732486df9375c238594c81a5d526c48f0 (diff)
Fix Stream
Fix Bean scanning so it picks up the resttemplate removed unnecessary RestTemplate Bean configurations Change-Id: I094bec8e9513a2e02ebf00215291136ed6d54a18 Issue-ID: SO-1080 Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'mso-api-handlers/mso-requests-db/src/main/java')
-rw-r--r--mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java29
1 files changed, 18 insertions, 11 deletions
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;