summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java3
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java3
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java26
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java17
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java16
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java70
6 files changed, 67 insertions, 68 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index a7c47f8f53..c4ef3678c3 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -363,7 +363,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
if (latestStack == null && notFoundIsSuccess) {
return null;
} else if (latestStack != null) {
- statusHandler.updateStackStatus(latestStack);
+ String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ statusHandler.updateStackStatus(latestStack, requestId);
if (stackStatus.equals(latestStack.getStackStatus())) {
if (LocalDateTime.now().isAfter(stopPolling)) {
logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus());
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
index bf29c39f99..8f1543e561 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/StackStatusHandler.java
@@ -43,9 +43,8 @@ public class StackStatusHandler {
private RequestsDbClient requestDBClient;
@Async
- public void updateStackStatus(Stack stack) {
+ public void updateStackStatus(Stack stack, String requestId) {
try {
- String requestId = MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
String stackStatus = mapper.writeValueAsString(stack);
RequestProcessingData requestProcessingData =
requestDBClient.getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId,
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index 4f7fed7df4..5bd7c29313 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -36,7 +36,6 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -46,6 +45,7 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -53,6 +53,7 @@ import org.onap.so.openstack.beans.CreateStackRequest;
import org.onap.so.openstack.exceptions.MsoException;
import org.onap.so.openstack.exceptions.MsoOpenstackException;
import org.onap.so.openstack.exceptions.MsoStackAlreadyExists;
+import org.slf4j.MDC;
import org.springframework.core.env.Environment;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.woorea.openstack.base.client.OpenStackResponseException;
@@ -63,6 +64,7 @@ import com.woorea.openstack.heat.StackResource.DeleteStack;
import com.woorea.openstack.heat.model.CreateStackParam;
import com.woorea.openstack.heat.model.Resources;
import com.woorea.openstack.heat.model.Stack;
+import java.util.UUID;
@RunWith(MockitoJUnitRunner.class)
public class MsoHeatUtilsTest extends MsoHeatUtils {
@@ -104,9 +106,15 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
private String cloudSiteId = "cloudSiteId";
private String tenantId = "tenantId";
+ private String getRequestId() {
+ return MDC.get(ONAPLogConstants.MDCs.REQUEST_ID);
+ }
+
@Before
public void setup() {
doReturn("15").when(env).getProperty("org.onap.so.adapters.po.pollInterval", "15");
+ String requestId = UUID.randomUUID().toString();
+ MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, requestId);
}
@Test
@@ -117,6 +125,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
stack.setStackStatus("CREATE_IN_PROGRESS");
stack.setStackStatusReason("Stack Finished");
+ String requestId = getRequestId();
Stack latestStack = new Stack();
latestStack.setId("id");
latestStack.setStackName("stackName");
@@ -125,7 +134,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
doReturn(latestStack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
- Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(latestStack);
+ Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(latestStack, requestId);
Mockito.verify(heatUtils, times(1)).queryHeatStack(isA(Heat.class), eq("stackName/id"));
assertEquals(true, actual != null);
}
@@ -137,12 +146,13 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
stack.setStackName("stackName");
stack.setStackStatus("CREATE_IN_PROGRESS");
stack.setStackStatusReason("Stack Finished");
- doNothing().when(stackStatusHandler).updateStackStatus(stack);
+ String requestId = getRequestId();
+ doNothing().when(stackStatusHandler).updateStackStatus(stack, requestId);
doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
doReturn("61").when(env).getProperty("org.onap.so.adapters.po.pollInterval", "15");
Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
- Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(stack);
+ Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(stack, requestId);
Mockito.verify(heatUtils, times(1)).queryHeatStack(isA(Heat.class), eq("stackName/id"));
assertEquals(true, actual != null);
}
@@ -154,11 +164,12 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
stack.setStackName("stackName");
stack.setStackStatus("CREATE_IN_PROGRESS");
stack.setStackStatusReason("Stack Finished");
- doNothing().when(stackStatusHandler).updateStackStatus(stack);
+ String requestId = getRequestId();
+ doNothing().when(stackStatusHandler).updateStackStatus(stack, requestId);
doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id"));
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
- Mockito.verify(stackStatusHandler, times(5)).updateStackStatus(stack);
+ Mockito.verify(stackStatusHandler, times(5)).updateStackStatus(stack, requestId);
Mockito.verify(heatUtils, times(5)).queryHeatStack(isA(Heat.class), eq("stackName/id"));
assertEquals(true, actual != null);
}
@@ -417,6 +428,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
CreateStackParam createStackParam = new CreateStackParam();
createStackParam.setStackName("stackName");
+ String requestId = getRequestId();
doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId);
doReturn(stackResource).when(heatClient).getStacks();
doReturn(mockCreateStack).when(stackResource).create(createStackParam);
@@ -425,7 +437,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
heatUtils.createStack(createStackParam, cloudSiteId, tenantId);
Mockito.verify(stackResource, times(1)).create(createStackParam);
- Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(createStackParam), isNull(), eq("stackName"));
+ Mockito.verify(heatUtils, times(1)).saveStackRequest(eq(createStackParam), eq(requestId), eq("stackName"));
Mockito.verify(heatClient, times(1)).getStacks();
Mockito.verify(stackResource, times(1)).create(createStackParam);
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java
index 985a39a76b..c210a8b6ad 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/StackStatusHandlerTest.java
@@ -26,6 +26,7 @@ import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import java.io.IOException;
+import java.util.UUID;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@@ -47,35 +48,41 @@ public class StackStatusHandlerTest {
@Mock
RequestsDbClient requestDBClient;
+ private String getRequestId() {
+ return UUID.randomUUID().toString();
+ }
+
@Test
public final void recordExists_Test() throws MsoException, IOException {
RequestProcessingData requestProcessingData = new RequestProcessingData();
requestProcessingData.setValue("testMe");
+ String requestId = getRequestId();
doReturn(requestProcessingData).when(requestDBClient)
- .getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "stackName", "id");
+ .getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId, "stackName", "id");
Stack latestStack = new Stack();
latestStack.setId("id");
latestStack.setStackName("stackName");
latestStack.setStackStatus("CREATE_COMPLETE");
latestStack.setStackStatusReason("Stack Finished");
- statusHandler.updateStackStatus(latestStack);
+ statusHandler.updateStackStatus(latestStack, requestId);
Mockito.verify(requestDBClient, times(1)).updateRequestProcessingData(requestProcessingData);
assertNotEquals("testMe", requestProcessingData.getValue());
}
@Test
public final void record_Not_Exists_Test() throws MsoException, IOException {
+ String requestId = getRequestId();
ArgumentCaptor<RequestProcessingData> requestCaptor = ArgumentCaptor.forClass(RequestProcessingData.class);
- doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(null, "stackName",
- "id");
+ doReturn(null).when(requestDBClient).getRequestProcessingDataBySoRequestIdAndNameAndGrouping(requestId,
+ "stackName", "id");
Stack latestStack = new Stack();
latestStack.setId("id");
latestStack.setStackName("stackName");
latestStack.setStackStatus("CREATE_COMPLETE");
latestStack.setStackStatusReason("Stack Finished");
- statusHandler.updateStackStatus(latestStack);
+ statusHandler.updateStackStatus(latestStack, requestId);
Mockito.verify(requestDBClient, times(1)).saveRequestProcessingData(requestCaptor.capture());
RequestProcessingData actualRequest = requestCaptor.getValue();
assertEquals("id", actualRequest.getGroupingId());
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
index 63f23038bc..c69b63fe16 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
@@ -41,9 +41,6 @@ import org.onap.so.adapters.cnf.model.ConfigTemplateEntity;
import org.onap.so.adapters.cnf.model.ConfigurationEntity;
import org.onap.so.adapters.cnf.model.ConfigurationRollbackEntity;
import org.onap.so.adapters.cnf.model.ConnectivityInfo;
-import org.onap.so.adapters.cnf.model.InstanceMiniResponseList;
-import org.onap.so.adapters.cnf.model.InstanceResponse;
-import org.onap.so.adapters.cnf.model.InstanceStatusResponse;
import org.onap.so.adapters.cnf.model.ProfileEntity;
import org.onap.so.adapters.cnf.model.ResourceBundleEntity;
import org.onap.so.adapters.cnf.model.Tag;
@@ -51,7 +48,6 @@ import org.onap.so.adapters.cnf.service.CnfAdapterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -77,7 +73,7 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/healthcheck"}, method = RequestMethod.GET,
produces = "application/json")
- public ResponseEntity<String> healthCheck() throws Exception {
+ public String healthCheck() throws Exception {
logger.info("healthCheck called.");
return cnfAdapterService.healthCheck();
@@ -97,7 +93,7 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}"}, method = RequestMethod.GET,
produces = "application/json")
- public ResponseEntity<InstanceResponse> getInstanceByInstanceId(@PathVariable("instID") String instanceId)
+ public String getInstanceByInstanceId(@PathVariable("instID") String instanceId)
throws JsonParseException, JsonMappingException, IOException {
logger.info("getInstanceByInstanceId called.");
@@ -109,8 +105,8 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}/status"}, method = RequestMethod.GET,
produces = "application/json")
- public ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId(
- @PathVariable("instID") String instanceId) throws JsonParseException, JsonMappingException, IOException {
+ public String getInstanceStatusByInstanceId(@PathVariable("instID") String instanceId)
+ throws JsonParseException, JsonMappingException, IOException {
logger.info("getInstanceStatusByInstanceId called.");
@@ -119,7 +115,7 @@ public class CnfAdapterRest {
}
@RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.GET, produces = "application/json")
- public ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName(
+ public String getInstanceByRBNameOrRBVersionOrProfileName(
@RequestParam(value = "rb-name", required = false) String rbName,
@RequestParam(value = "rb-version", required = false) String rbVersion,
@RequestParam(value = "profile-name", required = false) String profileName)
@@ -133,7 +129,7 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/instance/{instID}"}, method = RequestMethod.DELETE,
produces = "application/json")
- public ResponseEntity<String> deleteInstanceByInstanceId(@PathVariable("instID") String instanceID)
+ public String deleteInstanceByInstanceId(@PathVariable("instID") String instanceID)
throws JsonParseException, JsonMappingException, IOException {
logger.info("deleteInstanceByInstanceId called.");
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
index 7e22a09d6b..a134bace1f 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java
@@ -26,12 +26,7 @@ import java.util.List;
import javax.persistence.EntityNotFoundException;
import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpStatus;
-import org.apache.http.util.EntityUtils;
import org.onap.so.adapters.cnf.model.BpmnInstanceRequest;
-import org.onap.so.adapters.cnf.model.InstanceMiniResponse;
-import org.onap.so.adapters.cnf.model.InstanceMiniResponseList;
-import org.onap.so.adapters.cnf.model.InstanceResponse;
-import org.onap.so.adapters.cnf.model.InstanceStatusResponse;
import org.onap.so.adapters.cnf.model.MulticloudInstanceRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,14 +51,12 @@ public class CnfAdapterService {
private static final String INSTANCE_CREATE_PATH = "/v1/instance";
private static final String HEALTH_CHECK = "/v1/healthcheck";
- public ResponseEntity<String> healthCheck() {
+ public String healthCheck() {
- logger.info("CnfAdapterService createInstance called");
+ logger.info("CnfAdapterService healthCheck called");
ResponseEntity<String> result = null;
try {
- logger.info("CnfAdapterService createInstance called");
-
// String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
// This needs to be added as well
// for configuration
@@ -71,7 +64,7 @@ public class CnfAdapterService {
String endpoint = UriBuilder.fromUri(uri).path(HEALTH_CHECK).build().toString();
HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
result = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, String.class);
- return result;
+ return result.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -80,8 +73,7 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- return ResponseEntity.status(e.getStatusCode()).body(responseString);
+ throw e;
}
}
@@ -123,11 +115,11 @@ public class CnfAdapterService {
}
}
- public ResponseEntity<InstanceResponse> getInstanceByInstanceId(String instanceId)
+ public String getInstanceByInstanceId(String instanceId)
throws JsonParseException, JsonMappingException, IOException {
- logger.info("CnfAdapterService createInstance called");
- ResponseEntity<InstanceResponse> instanceResponse = null;
+ logger.info("CnfAdapterService getInstanceByInstanceId called");
+ ResponseEntity<String> instanceResponse = null;
try {
// String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
@@ -137,8 +129,8 @@ public class CnfAdapterService {
String path = "/v1/instance/" + instanceId;
String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
- instanceResponse = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, InstanceResponse.class);
- return instanceResponse;
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, String.class);
+ return instanceResponse.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -147,16 +139,15 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- InstanceResponse result = new InstanceResponse();
- return ResponseEntity.status(e.getStatusCode()).body(result);
+ throw e;
}
}
- public ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId(String instanceId)
+ public String getInstanceStatusByInstanceId(String instanceId)
throws JsonParseException, JsonMappingException, IOException {
- logger.info("CnfAdapterService createInstance called");
- ResponseEntity<InstanceStatusResponse> instanceResponse = null;
+ logger.info("CnfAdapterService getInstanceStatusByInstanceId called");
+ ResponseEntity<String> instanceResponse = null;
try {
// String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
@@ -166,9 +157,8 @@ public class CnfAdapterService {
String path = "/v1/instance/" + instanceId + "/status";
String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
- instanceResponse =
- restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, InstanceStatusResponse.class);
- return instanceResponse;
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.GET, requestEntity, String.class);
+ return instanceResponse.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -177,18 +167,16 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- InstanceStatusResponse result = new InstanceStatusResponse(responseString.trim());
- return ResponseEntity.status(e.getStatusCode()).body(result);
+ throw e;
}
}
- public ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName(String rbName,
- String rbVersion, String profileName) throws JsonParseException, JsonMappingException, IOException {
+ public String getInstanceByRBNameOrRBVersionOrProfileName(String rbName, String rbVersion, String profileName)
+ throws JsonParseException, JsonMappingException, IOException {
- logger.info("CnfAdapterService createInstance called");
- ResponseEntity<InstanceMiniResponseList> instanceMiniResponseList = null;
+ logger.info("CnfAdapterService getInstanceByRBNameOrRBVersionOrProfileName called");
+ ResponseEntity<String> instanceMiniResponseList = null;
try {
// String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
@@ -199,9 +187,8 @@ public class CnfAdapterService {
"/v1/instance" + "?rb-name=" + rbName + "&rb-version=" + rbVersion + "&profile-name=" + profileName;
String endPoint = uri + path;
HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
- instanceMiniResponseList =
- restTemplate.exchange(endPoint, HttpMethod.GET, requestEntity, InstanceMiniResponseList.class);
- return instanceMiniResponseList;
+ instanceMiniResponseList = restTemplate.exchange(endPoint, HttpMethod.GET, requestEntity, String.class);
+ return instanceMiniResponseList.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -210,16 +197,14 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- InstanceMiniResponseList result = new InstanceMiniResponseList(responseString.trim());
- return ResponseEntity.status(e.getStatusCode()).body(result);
+ throw e;
}
}
- public ResponseEntity<String> deleteInstanceByInstanceId(String instanceId)
+ public String deleteInstanceByInstanceId(String instanceId)
throws JsonParseException, JsonMappingException, IOException {
- logger.info("CnfAdapterService createInstance called");
+ logger.info("CnfAdapterService deleteInstanceByInstanceId called");
ResponseEntity<String> result = null;
try {
@@ -231,7 +216,7 @@ public class CnfAdapterService {
String endpoint = UriBuilder.fromUri(uri).path(path).build().toString();
HttpEntity<?> requestEntity = new HttpEntity<>(getHttpHeaders());
result = restTemplate.exchange(endpoint, HttpMethod.DELETE, requestEntity, String.class);
- return result;
+ return result.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -240,8 +225,7 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- return ResponseEntity.status(e.getStatusCode()).body(responseString);
+ throw e;
}
}