diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java | 23 | ||||
-rw-r--r-- | src/main/java/org/onap/clamp/clds/service/CldsService.java | 10 |
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()); |