aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-05-02 13:05:18 +0200
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-05-02 13:06:01 +0200
commit1d40770936891a836fb24e9c03dec78fd115c14b (patch)
tree53069602c92da31310ad5b06eb30fb0b7b1975c8 /src/main/java
parent27643f6e0e807c25230214df188f88a3cf0ab2a4 (diff)
Fix CsarInstaller
Add the getTypeName and fix submit operation insEvent missing for SDC case Issue-ID: CLAMP-151 Change-Id: Ibd176c3ff1c346003bd7b2b0594178867ca1a8e8 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java23
-rw-r--r--src/main/java/org/onap/clamp/clds/service/CldsService.java10
2 files changed, 22 insertions, 11 deletions
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 32f26e99..57fe7cd4 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
@@ -46,6 +46,7 @@ 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.dcae.DcaeInventoryResponse;
import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.service.CldsService;
import org.onap.clamp.clds.service.CldsTemplateService;
@@ -120,7 +121,8 @@ public class CsarInstallerImpl implements CsarInstaller {
policyScopePrefix = MODEL_NAME_PREFIX;
}
return policyScopePrefix + csar.getSdcCsarHelper().getServiceMetadata().getValue("name") + "_v"
- + csar.getSdcNotification().getServiceVersion().replace('.', '_') + "_" + resourceInstanceName;
+ + csar.getSdcNotification().getServiceVersion().replace('.', '_') + "_"
+ + resourceInstanceName.replaceAll(" ", "");
}
@Override
@@ -130,9 +132,10 @@ public class CsarInstallerImpl implements CsarInstaller {
logger.info("Installing the CSAR " + csar.getFilePath());
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
logger.info("Processing blueprint " + blueprint.getValue().getBlueprintArtifactName());
- String serviceTypeId = queryDcaeToGetServiceTypeId(blueprint.getValue());
- createFakeCldsModel(csar, blueprint.getValue(), createFakeCldsTemplate(csar, blueprint.getValue(),
- this.searchForRightMapping(blueprint.getValue())), serviceTypeId);
+ createFakeCldsModel(csar, blueprint.getValue(),
+ createFakeCldsTemplate(csar, blueprint.getValue(),
+ this.searchForRightMapping(blueprint.getValue())),
+ queryDcaeToGetServiceTypeId(blueprint.getValue()));
}
logger.info("Successfully installed the CSAR " + csar.getFilePath());
} catch (IOException e) {
@@ -202,16 +205,16 @@ public class CsarInstallerImpl implements CsarInstaller {
* call)
*
* @param blueprintArtifact
- * @return
+ * @return The DcaeInventoryResponse object containing the dcae values
* @throws IOException
* @throws ParseException
* @throws InterruptedException
*/
- private String queryDcaeToGetServiceTypeId(BlueprintArtifact blueprintArtifact)
+ private DcaeInventoryResponse queryDcaeToGetServiceTypeId(BlueprintArtifact blueprintArtifact)
throws IOException, ParseException, InterruptedException {
return dcaeInventoryService.getDcaeInformation(blueprintArtifact.getBlueprintArtifactName(),
blueprintArtifact.getBlueprintInvariantServiceUuid(),
- blueprintArtifact.getResourceAttached().getResourceInvariantUUID()).getTypeId();
+ blueprintArtifact.getResourceAttached().getResourceInvariantUUID());
}
private CldsTemplate createFakeCldsTemplate(CsarHandler csar, BlueprintArtifact blueprintArtifact,
@@ -233,7 +236,8 @@ public class CsarInstallerImpl implements CsarInstaller {
}
private CldsModel createFakeCldsModel(CsarHandler csar, BlueprintArtifact blueprintArtifact,
- CldsTemplate cldsTemplate, String serviceTypeId) throws SdcArtifactInstallerException {
+ CldsTemplate cldsTemplate, DcaeInventoryResponse dcaeInventoryResponse)
+ throws SdcArtifactInstallerException {
try {
CldsModel cldsModel = new CldsModel();
cldsModel.setName(buildModelName(csar, blueprintArtifact.getResourceAttached().getResourceInstanceName()));
@@ -241,7 +245,8 @@ public class CsarInstallerImpl implements CsarInstaller {
cldsModel.setTemplateName(cldsTemplate.getName());
cldsModel.setTemplateId(cldsTemplate.getId());
cldsModel.setBpmnText(cldsTemplate.getBpmnText());
- cldsModel.setTypeId(serviceTypeId);
+ cldsModel.setTypeId(dcaeInventoryResponse.getTypeId());
+ cldsModel.setTypeName(dcaeInventoryResponse.getTypeName());
cldsModel.setControlNamePrefix(CONTROL_NAME_PREFIX);
// We must save it otherwise object won't be created in db
// and proptext will always be null
diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java
index aebe2177..ef788753 100644
--- a/src/main/java/org/onap/clamp/clds/service/CldsService.java
+++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java
@@ -83,6 +83,7 @@ import org.onap.clamp.clds.model.properties.ModelProperties;
import org.onap.clamp.clds.model.sdc.SdcResource;
import org.onap.clamp.clds.model.sdc.SdcServiceDetail;
import org.onap.clamp.clds.model.sdc.SdcServiceInfo;
+import org.onap.clamp.clds.sdc.controller.installer.CsarInstallerImpl;
import org.onap.clamp.clds.transform.XslTransformer;
import org.onap.clamp.clds.util.JacksonUtils;
import org.onap.clamp.clds.util.LoggingUtils;
@@ -489,16 +490,21 @@ public class CldsService extends SecureServiceBase {
if (!isTest && (actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMIT)
|| actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT)
|| actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) {
- if (retrievedModel.getTypeId() == null) {
+ if (retrievedModel.getTemplateName().startsWith(CsarInstallerImpl.TEMPLATE_NAME_PREFIX)) {
// This should be done only when the call to DCAE
// has not yet been done. When CL comes from SDC
// this is not required as the DCAE inventory call is done
// during the CL deployment.
dcaeInventoryServices.setEventInventory(retrievedModel, getUserId());
- retrievedModel.save(cldsDao, getUserId());
} else {
logger.info("Skipping DCAE inventory call as closed loop has been created from SDC notification");
+ DcaeEvent dcaeEvent = new DcaeEvent();
+ dcaeEvent.setArtifactName("SDC artifact-" + retrievedModel.getName());
+ dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION);
+ CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(),
+ CldsEvent.ACTION_STATE_RECEIVED, null);
}
+ retrievedModel.save(cldsDao, getUserId());
}
// audit log
LoggingUtils.setTimeContext(startTime, new Date());