diff options
Diffstat (limited to 'src/main/java')
3 files changed, 20 insertions, 95 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java index cdba29ae1..09d4d6332 100644 --- a/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/spring/CldsSdcControllerConfiguration.java @@ -32,13 +32,13 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.config.sdc.SdcControllersConfiguration; -import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfiguration; import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException; import org.onap.clamp.clds.sdc.controller.SdcSingleController; import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller; import org.onap.clamp.clds.sdc.controller.installer.CsarInstallerImpl; -import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -49,18 +49,23 @@ public class CldsSdcControllerConfiguration { private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsSdcControllerConfiguration.class); private List<SdcSingleController> sdcControllersList = new ArrayList<>(); + @Autowired + private ClampProperties clampProp; + @Autowired + protected CsarInstaller csarInstaller; @PostConstruct - public void loadSdcControllers( - @Qualifier("sdcControllersConfiguration") SdcControllersConfiguration sdcControllersConfig) { + public void loadSdcControllers() { + SdcControllersConfiguration sdcControllersConfig = getSdcControllersConfiguration(); sdcControllersConfig.getAllDefinedControllers().forEach((k, v) -> { - SdcSingleController sdcController = getSdcSingleController(v); + logger.info("Instantiating controller :" + k); + SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, v, true); try { sdcController.initSdc(); } catch (SdcControllerException e) { logger.error("Exception caught during initialization of sdc controller", e); } - sdcControllersList.add(getSdcSingleController(v)); + sdcControllersList.add(sdcController); }); } @@ -80,11 +85,6 @@ public class CldsSdcControllerConfiguration { return new CsarInstallerImpl(); } - @Bean(name = "sdcSingleController") - public SdcSingleController getSdcSingleController(SdcSingleControllerConfiguration sdcControllerConfig) { - return new SdcSingleController(sdcControllerConfig, true); - } - @Bean(name = "sdcControllersConfiguration") public SdcControllersConfiguration getSdcControllersConfiguration() { return new SdcControllersConfiguration(); diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java index 387548ffc..f8fef3943 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java @@ -49,19 +49,15 @@ import org.openecomp.sdc.impl.DistributionClientFactory; import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
import org.openecomp.sdc.utils.DistributionActionResultEnum;
import org.openecomp.sdc.utils.DistributionStatusEnum;
-import org.springframework.beans.factory.annotation.Autowired;
/**
- * This class handles one sdc controller defined in the config. It's
- * instantiated by Spring config.
+ * This class handles one sdc controller defined in the config.
*/
public class SdcSingleController {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcSingleController.class);
protected boolean isAsdcClientAutoManaged = false;
- @Autowired
- protected CsarInstaller resourceInstaller;
- @Autowired
+ protected CsarInstaller csarInstaller;
protected ClampProperties refProp;
public static final String CONFIG_SDC_FOLDER = "sdc.csarFolder";
@@ -129,9 +125,12 @@ public class SdcSingleController { protected SdcSingleControllerConfiguration sdcConfig;
private IDistributionClient distributionClient;
- public SdcSingleController(SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {
+ public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller,
+ SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {
this.isAsdcClientAutoManaged = isClientAutoManaged;
- sdcConfig = sdcSingleConfig;
+ this.sdcConfig = sdcSingleConfig;
+ this.refProp = clampProp;
+ this.csarInstaller = csarInstaller;
}
/**
@@ -206,12 +205,12 @@ public class SdcSingleController { this.changeControllerStatus(SdcSingleControllerStatus.BUSY);
csar = new CsarHandler(iNotif, this.sdcConfig.getSdcControllerName(),
refProp.getStringValue(CONFIG_SDC_FOLDER));
- if (resourceInstaller.isCsarAlreadyDeployed(csar)) {
+ if (csarInstaller.isCsarAlreadyDeployed(csar)) {
csar.save(downloadTheArtifact(csar.getArtifactElement()));
this.sendASDCNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),
sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_OK, null,
System.currentTimeMillis());
- resourceInstaller.installTheCsar(csar);
+ csarInstaller.installTheCsar(csar);
this.sendASDCNotification(NotificationType.DEPLOY, csar.getArtifactElement().getArtifactURL(),
sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DEPLOY_OK, null,
System.currentTimeMillis());
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 bce50e526..c23d2ec87 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -401,72 +401,8 @@ public class CldsService extends SecureServiceBase { @PathParam("modelName") String modelName, @QueryParam("test") String test, CldsModel model) throws TransformerException, ParseException, GeneralSecurityException, DecoderException { Date startTime = new Date(); -<<<<<<< Upstream, based on f7e5aab99d6c2a0a9d5e56b561ba0513aafd504e CldsModel retrievedModel = null; Boolean errorCase = false; -======= - LoggingUtils.setRequestContext("CldsService: Process model action", getPrincipalName()); - String actionCd = action.toUpperCase(); - SecureServicePermission permisionManage = SecureServicePermission.create(cldsPermissionTypeClManage, - cldsPermissionInstance, actionCd); - isAuthorized(permisionManage); - isAuthorizedForVf(model); - String userId = getUserId(); - String actionStateCd = CldsEvent.ACTION_STATE_INITIATED; - logger.info("PUT actionCd={}", actionCd); - logger.info("PUT actionStateCd={}", actionStateCd); - logger.info("PUT modelName={}", modelName); - logger.info("PUT test={}", test); - logger.info("PUT bpmnText={}", model.getBpmnText()); - logger.info("PUT propText={}", model.getPropText()); - logger.info("PUT userId={}", userId); - logger.info("PUT getTypeId={}", model.getTypeId()); - logger.info("PUT deploymentId={}", model.getDeploymentId()); - if (model.getTemplateName() != null) { - CldsTemplate template = cldsDao.getTemplate(model.getTemplateName()); - if (template != null) { - model.setTemplateId(template.getId()); - model.setDocText(template.getPropText()); - // This is to provide the Bpmn XML when Template part in UI is - // disabled - model.setBpmnText(template.getBpmnText()); - } - } - // save model to db - model.setName(modelName); - model.save(cldsDao, getUserId()); - // get vars and format if necessary - String prop = model.getPropText(); - String bpmn = model.getBpmnText(); - String docText = model.getDocText(); - String controlName = model.getControlName(); - String bpmnJson = cldsBpmnTransformer.doXslTransformToString(bpmn); - logger.info("PUT bpmnJson={}", bpmnJson); - // Flag indicates whether it is triggered by Validation Test button from - // UI - boolean isTest = false; - if (test != null && test.equalsIgnoreCase("true")) { - isTest = true; - } else { - String actionTestOverride = refProp.getStringValue("action.test.override"); - if (actionTestOverride != null && actionTestOverride.equalsIgnoreCase("true")) { - logger.info("PUT actionTestOverride={}", actionTestOverride); - logger.info("PUT override test indicator and setting it to true"); - isTest = true; - } - } - logger.info("PUT isTest={}", isTest); - boolean isInsertTestEvent = false; - String insertTestEvent = refProp.getStringValue("action.insert.test.event"); - if (insertTestEvent != null && insertTestEvent.equalsIgnoreCase("true")) { - isInsertTestEvent = true; - } - logger.info("PUT isInsertTestEvent={}", isInsertTestEvent); - // determine if requested action is permitted - model.validateAction(actionCd); - logger.info("modelProp - " + prop); - logger.info("docText - " + docText); ->>>>>>> 95a4d95 Remove the test flag try { LoggingUtils.setRequestContext("CldsService: Process model action", getPrincipalName()); String actionCd = action.toUpperCase(); @@ -476,10 +412,8 @@ public class CldsService extends SecureServiceBase { isAuthorizedForVf(model); String userId = getUserId(); String actionStateCd = CldsEvent.ACTION_STATE_INITIATED; - String processDefinitionKey = "clds-process-action-wf"; logger.info("PUT actionCd={}", actionCd); logger.info("PUT actionStateCd={}", actionStateCd); - logger.info("PUT processDefinitionKey={}", processDefinitionKey); logger.info("PUT modelName={}", modelName); logger.info("PUT test={}", test); logger.info("PUT bpmnText={}", model.getBpmnText()); @@ -870,12 +804,8 @@ public class CldsService extends SecureServiceBase { @Path("/deploy/{modelName}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) -<<<<<<< Upstream, based on f7e5aab99d6c2a0a9d5e56b561ba0513aafd504e public Response deployModel(@PathParam("modelName") String modelName, CldsModel model) { -======= - public CldsModel deployModel(@PathParam("modelName") String modelName, CldsModel model) { ->>>>>>> 95a4d95 Remove the test flag Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: Deploy model", getPrincipalName()); Boolean errorCase = false; @@ -942,12 +872,8 @@ public class CldsService extends SecureServiceBase { @Path("/undeploy/{modelName}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) -<<<<<<< Upstream, based on f7e5aab99d6c2a0a9d5e56b561ba0513aafd504e public Response unDeployModel(@PathParam("modelName") String modelName, CldsModel model) { -======= - public CldsModel unDeployModel(@PathParam("modelName") String modelName, CldsModel model) { ->>>>>>> 95a4d95 Remove the test flag Date startTime = new Date(); LoggingUtils.setRequestContext("CldsService: Undeploy model", getPrincipalName()); |