summaryrefslogtreecommitdiffstats
path: root/adapters/mso-cnf-adapter/src/main
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@orange.com>2020-12-01 22:35:03 +0000
committerLukasz Rajewski <lukasz.rajewski@orange.com>2020-12-03 00:18:00 +0000
commit679549feed7308541e3f57ed1a9991f5dc05398e (patch)
tree9a1a934e0333b386e58b0d49a260994146eddcf2 /adapters/mso-cnf-adapter/src/main
parent7f2254e92d36c90a07a723b69bd2e69a726714ac (diff)
Further changes for cnf-adpter in bpmn infra
Issue-ID: SO-3403 Change-Id: Iae2a27431797283553f0e329e8c2f3e4514001ef Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Diffstat (limited to 'adapters/mso-cnf-adapter/src/main')
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java26
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java2
-rw-r--r--adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/service/CnfAdapterService.java18
3 files changed, 28 insertions, 18 deletions
diff --git a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
index effaaf5f78..ae63f86c8a 100644
--- a/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
+++ b/adapters/mso-cnf-adapter/src/main/java/org/onap/so/adapters/cnf/model/InstanceResponse.java
@@ -27,22 +27,24 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
-@JsonPropertyOrder({"id", "request", "namespace", "resources"})
+@JsonPropertyOrder({"id", "request", "namespace", "release-name", "resources"})
@JsonIgnoreProperties(value = "true")
-public class InstanceResponse extends Response {
+public class InstanceResponse {
@JsonProperty("id")
private String id;
+
@JsonProperty("request")
private MulticloudInstanceRequest request;
+
@JsonProperty("namespace")
private String namespace;
- @JsonProperty("resources")
- private List<Resource> resources = null;
- public InstanceResponse(String errorMsg) {
- super(errorMsg);
- }
+ @JsonProperty("release-name")
+ private String releaseName;
+
+ @JsonProperty("resources")
+ private List<Resource> resources;
@JsonProperty("id")
public String getId() {
@@ -84,4 +86,14 @@ public class InstanceResponse extends Response {
this.resources = resources;
}
+ @JsonProperty("release-name")
+ public String getReleaseName() {
+ return releaseName;
+ }
+
+ @JsonProperty("release-name")
+ public void setReleaseName(String releaseName) {
+ this.releaseName = releaseName;
+ }
+
}
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 825778b89a..63f23038bc 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
@@ -87,7 +87,7 @@ public class CnfAdapterRest {
@ResponseBody
@RequestMapping(value = {"/api/cnf-adapter/v1/instance"}, method = RequestMethod.POST,
produces = "application/json", consumes = "application/json")
- public ResponseEntity<InstanceResponse> createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest)
+ public String createInstance(@RequestBody BpmnInstanceRequest bpmnInstanceRequest)
throws JsonParseException, JsonMappingException, IOException {
logger.info("createInstance 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 06c09e3431..7e22a09d6b 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,6 +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;
@@ -84,12 +85,12 @@ public class CnfAdapterService {
}
}
- public ResponseEntity<InstanceResponse> createInstance(BpmnInstanceRequest bpmnInstanceRequest)
+ public String createInstance(BpmnInstanceRequest bpmnInstanceRequest)
throws JsonParseException, JsonMappingException, IOException {
try {
logger.info("CnfAdapterService createInstance called");
MulticloudInstanceRequest multicloudInstanceRequest = new MulticloudInstanceRequest();
- ResponseEntity<InstanceResponse> instanceResponse = null;
+ ResponseEntity<String> instanceResponse = null;
if (bpmnInstanceRequest.getK8sRBProfileName() != null) {
multicloudInstanceRequest.setCloudRegion(bpmnInstanceRequest.getCloudRegionId());
multicloudInstanceRequest.setLabels(bpmnInstanceRequest.getLabels());
@@ -100,7 +101,7 @@ public class CnfAdapterService {
multicloudInstanceRequest.setVfModuleUuid(bpmnInstanceRequest.getVfModuleUUID());
} else {
logger.error("k8sProfileName should not be null");
- return instanceResponse;
+ // return instanceResponse;
}
// String uri = env.getRequiredProperty("multicloud.endpoint"); //TODO:
// This needs to be added as well
@@ -108,8 +109,8 @@ public class CnfAdapterService {
String uri = "http://multicloud-k8s:9015"; // TODO: What is the correct uri?
String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString();
HttpEntity<?> entity = getHttpEntity(multicloudInstanceRequest);
- instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class);
- return instanceResponse;
+ instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, String.class);
+ return instanceResponse.getBody();
} catch (HttpClientErrorException e) {
logger.error("Error Calling Multicloud, e");
if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
@@ -118,9 +119,7 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- InstanceResponse result = new InstanceResponse(responseString.trim());
- return ResponseEntity.status(e.getStatusCode()).body(result);
+ throw e;
}
}
@@ -148,8 +147,7 @@ public class CnfAdapterService {
throw e;
} catch (HttpStatusCodeException e) {
logger.error("Error in Multicloud, e");
- String responseString = e.getResponseBodyAsString();
- InstanceResponse result = new InstanceResponse(responseString.trim());
+ InstanceResponse result = new InstanceResponse();
return ResponseEntity.status(e.getStatusCode()).body(result);
}
}