summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-04-19 14:21:24 +0200
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-04-19 14:21:24 +0200
commitab284ec6e60c48eb9550c8fae16cc34ec9c3aeae (patch)
tree66788a41eff9226e235284907e8d128ad40a7145 /src/main/java/org/onap
parent4ce8842b960445dfbde390b60ee78732a2c67c92 (diff)
Fix CsarInstaller
Fix the CsarInstaller for policy input when deploying to DCAE, and fix UI so that default value is well displayed Issue-ID: CLAMP-153 Change-Id: I307d24782e6482590e709affe59bff84fb8a8526 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java/org/onap')
-rw-r--r--src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java11
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java61
2 files changed, 50 insertions, 22 deletions
diff --git a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
index cc6f02de3..c840bd138 100644
--- a/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
+++ b/src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
@@ -36,6 +36,8 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.camel.Exchange;
+import org.onap.clamp.clds.client.req.policy.PolicyClient;
+import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.exception.ModelBpmnException;
import org.onap.clamp.clds.model.CldsEvent;
import org.onap.clamp.clds.model.CldsModel;
@@ -223,6 +225,15 @@ public class ModelProperties {
}
/**
+ * @return The policyName that wil be used in input parameters of DCAE
+ * deploy
+ */
+ public String getPolicyNameForDcaeDeploy(ClampProperties refProp) {
+ return normalizePolicyScopeName(modelName + "."
+ + refProp.getStringValue(PolicyClient.POLICY_MS_NAME_PREFIX_PROPERTY_NAME) + getCurrentPolicyName());
+ }
+
+ /**
* @return the policyScopeAndNameWithUniqueId
*/
public String getPolicyScopeAndNameWithUniqueId() {
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
index 10a7cd556..4acbdeee3 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
@@ -35,17 +35,21 @@ import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.PostConstruct;
+import javax.xml.transform.TransformerException;
import org.json.simple.parser.ParseException;
import org.onap.clamp.clds.client.DcaeInventoryServices;
+import org.onap.clamp.clds.config.ClampProperties;
import org.onap.clamp.clds.config.sdc.BlueprintParserFilesConfiguration;
import org.onap.clamp.clds.config.sdc.BlueprintParserMappingConfiguration;
import org.onap.clamp.clds.dao.CldsDao;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.model.CldsTemplate;
+import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.service.CldsTemplateService;
+import org.onap.clamp.clds.transform.XslTransformer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
@@ -81,6 +85,10 @@ public class CsarInstallerImpl implements CsarInstaller {
CldsService cldsService;
@Autowired
DcaeInventoryServices dcaeInventoryService;
+ @Autowired
+ private XslTransformer cldsBpmnTransformer;
+ @Autowired
+ private ClampProperties refProp;
@PostConstruct
public void loadConfiguration() throws IOException {
@@ -197,28 +205,37 @@ public class CsarInstallerImpl implements CsarInstaller {
private CldsModel createFakeCldsModel(CsarHandler csar, BlueprintArtifact blueprintArtifact,
CldsTemplate cldsTemplate, String serviceTypeId) throws SdcArtifactInstallerException {
- CldsModel cldsModel = new CldsModel();
- String policyName = searchForPolicyName(blueprintArtifact);
- if (policyName.contains("*")) {
- // It's a filter must add a specific prefix
- cldsModel.setControlNamePrefix(policyName);
- } else {
- cldsModel.setControlNamePrefix(CONTROL_NAME_PREFIX);
+ try {
+ CldsModel cldsModel = new CldsModel();
+ cldsModel.setName(buildModelName(csar));
+ cldsModel.setBlueprintText(blueprintArtifact.getDcaeBlueprint());
+ cldsModel.setTemplateName(cldsTemplate.getName());
+ cldsModel.setTemplateId(cldsTemplate.getId());
+ cldsModel.setBpmnText(cldsTemplate.getBpmnText());
+ cldsModel.setTypeId(serviceTypeId);
+ ModelProperties modelProp = new ModelProperties(cldsModel.getName(), "test", "PUT", false,
+ cldsBpmnTransformer.doXslTransformToString(cldsTemplate.getBpmnText()), "{}");
+ String policyName = searchForPolicyName(blueprintArtifact);
+ String inputParams = "";
+ if (policyName.contains("*")) {
+ // It's a filter must add a specific prefix
+ cldsModel.setControlNamePrefix(policyName);
+ } else {
+ cldsModel.setControlNamePrefix(CONTROL_NAME_PREFIX);
+ inputParams = "{\"name\":\"deployParameters\",\"value\":{\n" + "\"policy_id\": \""
+ + modelProp.getPolicyNameForDcaeDeploy(refProp) + "\"" + "}}";
+ }
+ cldsModel.setPropText("{\"global\":[{\"name\":\"service\",\"value\":[\""
+ + blueprintArtifact.getBlueprintInvariantServiceUuid() + "\"]},{\"name\":\"vf\",\"value\":[\""
+ + blueprintArtifact.getResourceAttached().getResourceInvariantUUID()
+ + "\"]},{\"name\":\"actionSet\",\"value\":[\"vnfRecipe\"]},{\"name\":\"location\",\"value\":[\"DC1\"]},"
+ + inputParams + "]}");
+ cldsModel.save(cldsDao, null);
+ logger.info("Fake Clds Model created for blueprint " + blueprintArtifact.getBlueprintArtifactName()
+ + " with name " + cldsModel.getName());
+ return cldsModel;
+ } catch (TransformerException e) {
+ throw new SdcArtifactInstallerException("TransformerException when decoding the BpmnText", e);
}
- cldsModel.setName(buildModelName(csar));
- cldsModel.setBlueprintText(blueprintArtifact.getDcaeBlueprint());
- cldsModel.setTemplateName(cldsTemplate.getName());
- cldsModel.setTemplateId(cldsTemplate.getId());
- cldsModel.setPropText("{\"global\":[{\"name\":\"service\",\"value\":[\""
- + blueprintArtifact.getBlueprintInvariantServiceUuid() + "\"]},{\"name\":\"vf\",\"value\":[\""
- + blueprintArtifact.getResourceAttached().getResourceInvariantUUID()
- + "\"]},{\"name\":\"actionSet\",\"value\":[\"vnfRecipe\"]},{\"name\":\"location\",\"value\":[\"DC1\"]},{\"name\":\"deployParameters\",\"value\":{\n"
- + " \"policy_id\": \"" + "test" + "\"" + " }}]}");
- cldsModel.setBpmnText(cldsTemplate.getBpmnText());
- cldsModel.setTypeId(serviceTypeId);
- cldsModel.save(cldsDao, null);
- logger.info("Fake Clds Model created for blueprint " + blueprintArtifact.getBlueprintArtifactName()
- + " with name " + cldsModel.getName());
- return cldsModel;
}
}