X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Fservice%2FCldsService.java;h=9b68845c0e2e8f2dfbd77b12e17f94c9a3df8260;hb=2926050886f70d14c931fc86d1ae465ca7597e10;hp=ef7887537f901e53ad6be53a059211c71840b3fa;hpb=1d40770936891a836fb24e9c03dec78fd115c14b;p=clamp.git 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 ef788753..9b68845c 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -36,7 +36,6 @@ import java.util.Date; import java.util.List; import java.util.Properties; import java.util.UUID; -import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; import javax.ws.rs.BadRequestException; @@ -121,7 +120,6 @@ public class CldsService extends SecureServiceBase { private SecureServicePermission permissionUpdateCl; private SecureServicePermission permissionReadTemplate; private SecureServicePermission permissionUpdateTemplate; - private static final long DCAE_DEPLOY_WAITING_TIME = TimeUnit.SECONDS.toNanos(30); @PostConstruct private final void afterConstruction() { @@ -491,18 +489,19 @@ public class CldsService extends SecureServiceBase { || actionCd.equalsIgnoreCase(CldsEvent.ACTION_RESUBMIT) || actionCd.equalsIgnoreCase(CldsEvent.ACTION_SUBMITDCAE))) { 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()); - } else { + // SDC artifact case 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.setArtifactName(retrievedModel.getControlName() + ".yml"); dcaeEvent.setEvent(DcaeEvent.EVENT_DISTRIBUTION); CldsEvent.insEvent(cldsDao, dcaeEvent.getControlName(), userId, dcaeEvent.getCldsActionCd(), CldsEvent.ACTION_STATE_RECEIVED, null); + } else { + // 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()); } @@ -836,6 +835,10 @@ public class CldsService extends SecureServiceBase { fillInCldsModel(model); String bpmnJson = cldsBpmnTransformer.doXslTransformToString(model.getBpmnText()); logger.info("PUT bpmnJson={}", bpmnJson); + SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage, + cldsPermissionInstance, CldsEvent.ACTION_DEPLOY); + isAuthorized(permisionManage); + isAuthorizedForVf(model); ModelProperties modelProp = new ModelProperties(modelName, model.getControlName(), CldsEvent.ACTION_DEPLOY, false, bpmnJson, model.getPropText()); checkForDuplicateServiceVf(modelName, model.getPropText()); @@ -848,17 +851,7 @@ public class CldsService extends SecureServiceBase { } String createNewDeploymentStatusUrl = dcaeDispatcherServices.createNewDeployment(deploymentId, model.getTypeId(), modelProp.getGlobal().getDeployParameters()); - String operationStatus = "processing"; - long waitingTime = System.nanoTime() + DCAE_DEPLOY_WAITING_TIME; - while ("processing".equalsIgnoreCase(operationStatus)) { - if (waitingTime < System.nanoTime()) { - logger.info("Waiting is over for DCAE deployment"); - break; - } - logger.info("Waiting 5s before sending query to DCAE"); - Thread.sleep(5000); - operationStatus = dcaeDispatcherServices.getOperationStatus(createNewDeploymentStatusUrl); - } + String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(createNewDeploymentStatusUrl); if ("succeeded".equalsIgnoreCase(operationStatus)) { String artifactName = model.getControlName(); if (artifactName != null) { @@ -901,16 +894,13 @@ public class CldsService extends SecureServiceBase { LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName()); Boolean errorCase = false; try { + SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage, + cldsPermissionInstance, CldsEvent.ACTION_UNDEPLOY); + isAuthorized(permisionManage); + isAuthorizedForVf(model); String operationStatusUndeployUrl = dcaeDispatcherServices.deleteExistingDeployment(model.getDeploymentId(), model.getTypeId()); - String operationStatus = "processing"; - long waitingTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(10); - while ("processing".equalsIgnoreCase(operationStatus)) { - if (waitingTime < System.nanoTime()) { - break; - } - operationStatus = dcaeDispatcherServices.getOperationStatus(operationStatusUndeployUrl); - } + String operationStatus = dcaeDispatcherServices.getOperationStatusWithRetry(operationStatusUndeployUrl); if ("succeeded".equalsIgnoreCase(operationStatus)) { String artifactName = model.getControlName(); if (artifactName != null) {