summaryrefslogtreecommitdiffstats
path: root/runtime-controlloop
diff options
context:
space:
mode:
authorsaul.gill <saul.gill@est.tech>2021-07-15 11:45:02 +0100
committersaul.gill <saul.gill@est.tech>2021-07-19 15:15:54 +0100
commit41811daa6079e07d95daf3d32719afe7ec15acbd (patch)
tree220c2235db383eff5db4181601f89800e8e82b0e /runtime-controlloop
parent258fdc2ddb8b5e130ccc2b287c10c3fd782b7ee9 (diff)
Added Camel Endpoints for decommissioning
Added endpoint in camel for decommissioning Changed get tosca service template get endpoint to return snake case Added endpoints in camel to retrieve control loop definitions and element definitions Added integration tests Allowed error messages and status codes to come through from runtime-controlloop backend Small refactor of clamp python emulator Issue-ID: POLICY-3443 Change-Id: I2f6103ca0f2058651a43e7ae1e0974cb1d3e69a7 Signed-off-by: saul.gill <saul.gill@est.tech>
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 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);
}
-
}
/**