summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop/src/main/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-controlloop/src/main/java/org/onap')
-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 f291c4e89..e5dccde7b 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
@@ -252,7 +252,8 @@ public class CommissioningProvider implements Closeable {
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);
}
-
}
/**