aboutsummaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
authorsekharhuawei <reddi.shekhar@huawei.com>2020-12-04 14:34:00 +0530
committersekharhuawei <reddi.shekhar@huawei.com>2020-12-04 14:34:00 +0530
commit3a24325997e63efc8efaaa71f7def02410165393 (patch)
tree7d25ea586fca1ec9ca168a6772e6830691fbd176 /adapters
parentaeb0b33977af534c1af1451b7a7610bd6ea20745 (diff)
cnf-adapter further changes and UT
Issue-ID: SO-3412 Signed-off-by: sekharhuawei <reddi.shekhar@huawei.com> Change-Id: Ief97e983ad7be39a64215140512bb747677847ba
Diffstat (limited to 'adapters')
-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
2 files changed, 33 insertions, 53 deletions
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;
}
}