From d1ed0a9ba6ffea4006fadf3847495563d11dc12e Mon Sep 17 00:00:00 2001 From: sebdet Date: Wed, 21 Apr 2021 16:28:33 +0200 Subject: ToscaFileSelector The UI code that manages the tosca file selector that will be sent to clamp be + fix Rest Camel endpoint that always want ot convert http body to JSON (due to Camel upgrade) Issue-ID: POLICY-3229 Signed-off-by: sebdet Change-Id: I6148276d4c527f29db904a76655055c19d4e2023 --- .../policy/clamp/clds/config/sdc/SdcControllersConfiguration.java | 2 -- .../org/onap/policy/clamp/configuration/ClampGsonDataFormat.java | 5 ++++- src/main/resources/clds/camel/rest/clamp-api-v2.xml | 4 +++- src/main/resources/clds/camel/routes/policy-flows.xml | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java b/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java index d0b116f71..5d8cbb05e 100644 --- a/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java +++ b/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java @@ -27,7 +27,6 @@ package org.onap.policy.clamp.clds.config.sdc; import com.google.gson.JsonObject; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.HashMap; @@ -38,7 +37,6 @@ import org.onap.policy.clamp.clds.util.JsonUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; -import org.springframework.core.io.Resource; /** * This class maps the SDC config JSON file. This JSON can have multiple diff --git a/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java b/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java index 95d1fe182..6479cf767 100644 --- a/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java +++ b/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java @@ -36,6 +36,7 @@ import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.DataFormatName; import org.apache.camel.support.service.ServiceSupport; import org.apache.camel.util.IOHelper; +import org.apache.commons.io.IOUtils; import org.onap.policy.clamp.clds.util.JsonUtils; public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, DataFormatName { @@ -113,7 +114,9 @@ public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, D public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception { try (final InputStreamReader isr = new InputStreamReader(stream, StandardCharsets.UTF_8); final BufferedReader reader = IOHelper.buffered(isr)) { - if (unmarshalGenericType == null) { + if (unmarshalType.equals(String.class)) { + return IOUtils.toString(reader); + } else if (unmarshalGenericType == null) { return gson.fromJson(reader, unmarshalType); } else { return gson.fromJson(reader, unmarshalGenericType); diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 3238822d3..c789735d2 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -1501,7 +1501,7 @@ - + @@ -1513,6 +1513,8 @@ true + diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml index 19092bfac..01862692c 100644 --- a/src/main/resources/clds/camel/routes/policy-flows.xml +++ b/src/main/resources/clds/camel/routes/policy-flows.xml @@ -624,6 +624,9 @@ POST + + application/yaml + ${exchangeProperty[X-ONAP-RequestID]} -- cgit 1.2.3-korg