summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-07-20 13:45:35 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-20 13:45:35 +0000
commit31482150f5048e2e3f7aad4ee0ef8cb611542870 (patch)
treef9a1a88bfbac5052c06082bc61cc25b53edc0d02 /runtime-controlloop
parentc16142da394ba515aa639aa87d88137a73c0c8ac (diff)
parent41811daa6079e07d95daf3d32719afe7ec15acbd (diff)
Merge "Added Camel Endpoints for decommissioning"
Diffstat (limited to 'runtime-controlloop')
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java15
2 files changed, 13 insertions, 5 deletions
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index bf6e39914..d9dee50bc 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -227,7 +227,8 @@ public class CommissioningProvider {
mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaTopologyTemplate.class), visitor);
break;
case "node_templates":
- mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaNodeTemplate.class), visitor);
+ mapper.acceptJsonFormatVisitor(mapper.getTypeFactory()
+ .constructCollectionType(List.class, ToscaNodeTemplate.class), visitor);
break;
default:
mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaServiceTemplate.class), visitor);
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
index b50e7a0ed..74548e724 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
@@ -23,8 +23,6 @@ package org.onap.policy.clamp.controlloop.runtime.main.rest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
-import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
-import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
@@ -347,15 +345,24 @@ public class CommissioningController extends AbstractRestController {
required = false) String version) {
try {
- return ResponseEntity.ok().body(provider.getToscaServiceTemplate(name, version));
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
+ String response = mapper.writerWithDefaultPrettyPrinter()
+ .writeValueAsString(provider.getToscaServiceTemplate(name, version));
+
+ return ResponseEntity.ok().body(response);
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of tosca service template failed", e);
var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return ResponseEntity.status(e.getErrorResponse().getResponseCode().getStatusCode()).body(resp);
+ } catch (JsonProcessingException e) {
+ LOGGER.warn("Get of tosca service template failed", e);
+ var resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getMessage());
+ return ResponseEntity.status(Status.BAD_REQUEST.getStatusCode()).body(resp);
}
-
}
/**