aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2019-05-09 13:14:40 +0200
committerxg353y <xg353y@intl.att.com>2019-05-09 14:48:05 +0200
commita2f90ab5d88f9e91014e39be078e5c50a0d48e04 (patch)
tree1d79cf6bc4b019cf686bd7d47d580e7b3a11733e /src/main
parentbc753dfd1a7eeccecd34763674653d319b822f2b (diff)
Fix the deploy cl payload issue
Update the deploy cl payload to contain only the deployment parameters instead of the whole blue print. Issue-ID: CLAMP-375 Change-Id: Iecc13bf8d43c87f9ff7792a76170d36ea972dbd5 Signed-off-by: xg353y <xg353y@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/loop/LoopOperation.java69
1 files changed, 7 insertions, 62 deletions
diff --git a/src/main/java/org/onap/clamp/loop/LoopOperation.java b/src/main/java/org/onap/clamp/loop/LoopOperation.java
index c3eb08be7..518830aa0 100644
--- a/src/main/java/org/onap/clamp/loop/LoopOperation.java
+++ b/src/main/java/org/onap/clamp/loop/LoopOperation.java
@@ -25,17 +25,10 @@ package org.onap.clamp.loop;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.Collection;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import org.apache.camel.Exchange;
@@ -43,11 +36,9 @@ import org.apache.camel.Message;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
-import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.policy.operational.OperationalPolicy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import org.yaml.snakeyaml.Yaml;
/**
* Closed loop operations.
@@ -59,13 +50,12 @@ public class LoopOperation {
protected static final EELFLogger auditLogger = EELFManager.getInstance().getMetricsLogger();
private static final String DCAE_LINK_FIELD = "links";
private static final String DCAE_STATUS_FIELD = "status";
- private static final String DCAE_DEPLOYMENT_TEMPLATE = "dcae.deployment.template";
private static final String DCAE_SERVICETYPE_ID = "serviceTypeId";
private static final String DCAE_INPUTS = "inputs";
private static final String DCAE_DEPLOYMENT_PREFIX = "closedLoop_";
private static final String DCAE_DEPLOYMENT_SUFIX = "_deploymentId";
+ private static final String DEPLOYMENT_PARA = "dcaeDeployParameters";
private final LoopService loopService;
- private final ClampProperties refProp;
public enum TempLoopState {
NOT_SUBMITTED, SUBMITTED, DEPLOYED, NOT_DEPLOYED, PROCESSING, IN_ERROR;
@@ -77,9 +67,8 @@ public class LoopOperation {
* @param refProp The clamp properties
*/
@Autowired
- public LoopOperation(LoopService loopService, ClampProperties refProp) {
+ public LoopOperation(LoopService loopService) {
this.loopService = loopService;
- this.refProp = refProp;
}
/**
@@ -90,16 +79,15 @@ public class LoopOperation {
* @throws IOException IOException
*/
public String getDeployPayload(Loop loop) throws IOException {
- Yaml yaml = new Yaml();
- Map<String, Object> yamlMap = yaml.load(loop.getBlueprint());
- JsonObject bluePrint = wrapSnakeObject(yamlMap).getAsJsonObject();
+ JsonObject globalProp = loop.getGlobalPropertiesJson();
+ JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARA);
String serviceTypeId = loop.getDcaeBlueprintId();
- JsonObject rootObject = refProp.getJsonTemplate(DCAE_DEPLOYMENT_TEMPLATE).getAsJsonObject();
+ JsonObject rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId);
- if (bluePrint != null) {
- rootObject.add(DCAE_INPUTS, bluePrint);
+ if (deploymentProp != null) {
+ rootObject.add(DCAE_INPUTS, deploymentProp);
}
String apiBodyString = rootObject.toString();
logger.info("Dcae api Body String - " + apiBodyString);
@@ -251,47 +239,4 @@ public class LoopOperation {
return clState;
}
- private JsonElement wrapSnakeObject(Object obj) {
- // NULL => JsonNull
- if (obj == null) {
- return JsonNull.INSTANCE;
- }
-
- // Collection => JsonArray
- if (obj instanceof Collection) {
- JsonArray array = new JsonArray();
- for (Object childObj : (Collection<?>) obj) {
- array.add(wrapSnakeObject(childObj));
- }
- return array;
- }
-
- // Array => JsonArray
- if (obj.getClass().isArray()) {
- JsonArray array = new JsonArray();
-
- int length = Array.getLength(array);
- for (int i = 0; i < length; i++) {
- array.add(wrapSnakeObject(Array.get(array, i)));
- }
- return array;
- }
-
- // Map => JsonObject
- if (obj instanceof Map) {
- Map<?, ?> map = (Map<?, ?>) obj;
-
- JsonObject jsonObject = new JsonObject();
- for (final Map.Entry<?, ?> entry : map.entrySet()) {
- final String name = String.valueOf(entry.getKey());
- final Object value = entry.getValue();
- jsonObject.add(name, wrapSnakeObject(value));
- }
- return jsonObject;
- }
-
- // otherwise take it as a string
- return new JsonPrimitive(String.valueOf(obj));
- }
-
}