summaryrefslogtreecommitdiffstats
path: root/bpmn/mso-infrastructure-bpmn/src
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-06-05 16:24:37 -0400
committerSmokowski, Steve (ss835w) <ss835w@us.att.com>2019-06-06 11:26:38 -0400
commit560e84158798cb884de65e3cf33ab657f0e6e6df (patch)
tree83a5aedb750eed64fcff623742bebc63a2a07161 /bpmn/mso-infrastructure-bpmn/src
parent5f4c4f3f3215eb136f9c4f84f51dc8fcd5fe0353 (diff)
parent59eff996497691e0fc82b627dcda306e861655b3 (diff)
Merge remote-tracking branch 'origin/dublin' into 'origin/master'
Change-Id: I551ea3f29a76dc99532455ea4d7e84a316f9bf38 Issue-ID: SO-1980 Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'bpmn/mso-infrastructure-bpmn/src')
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java58
-rw-r--r--bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml4
2 files changed, 34 insertions, 28 deletions
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
index 599dce5339..2aa433ba5a 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
+++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java
@@ -25,14 +25,14 @@ package org.onap.so.bpmn.infrastructure;
import java.util.List;
import java.util.concurrent.Executor;
import com.google.common.base.Strings;
-import org.camunda.bpm.application.PostDeploy;
+import javax.annotation.PostConstruct;
import org.camunda.bpm.application.PreUndeploy;
import org.camunda.bpm.application.ProcessApplicationInfo;
import org.camunda.bpm.engine.ProcessEngine;
import org.camunda.bpm.engine.repository.DeploymentBuilder;
import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator;
import org.onap.so.db.catalog.beans.Workflow;
-import org.onap.so.db.catalog.data.repository.WorkflowRepository;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,13 +40,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Primary;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -57,17 +55,17 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@SpringBootApplication
@EnableAsync
-@EnableJpaRepositories("org.onap.so.db.catalog.data.repository")
-@EntityScan({"org.onap.so.db.catalog.beans"})
@ComponentScan(basePackages = {"org.onap"}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class,
excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class)})
public class MSOInfrastructureApplication {
private static final Logger logger = LoggerFactory.getLogger(MSOInfrastructureApplication.class);
+ @Autowired
+ private ProcessEngine processEngine;
@Autowired
- private WorkflowRepository workflowRepository;
+ private CatalogDbClient catalogDbClient;
@Value("${mso.async.core-pool-size}")
private int corePoolSize;
@@ -80,6 +78,7 @@ public class MSOInfrastructureApplication {
private static final String LOGS_DIR = "logs_dir";
private static final String BPMN_SUFFIX = ".bpmn";
+ private static final String SDC_SOURCE = "sdc";
private static void setLogsDir() {
@@ -94,10 +93,14 @@ public class MSOInfrastructureApplication {
setLogsDir();
}
- @PostDeploy
- public void postDeploy(ProcessEngine processEngineInstance) {
- DeploymentBuilder deploymentBuilder = processEngineInstance.getRepositoryService().createDeployment();
- deployCustomWorkflows(deploymentBuilder);
+ @PostConstruct
+ public void postConstruct() {
+ try {
+ DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
+ deployCustomWorkflows(deploymentBuilder);
+ } catch (Exception e) {
+ logger.warn("Unable to invoke deploymentBuilder: " + e.getMessage());
+ }
}
@PreUndeploy
@@ -118,23 +121,26 @@ public class MSOInfrastructureApplication {
}
public void deployCustomWorkflows(DeploymentBuilder deploymentBuilder) {
- if (workflowRepository == null) {
- return;
- }
- List<Workflow> workflows = workflowRepository.findAll();
- if (workflows != null && workflows.size() != 0) {
- for (Workflow workflow : workflows) {
- String workflowName = workflow.getName();
- String workflowBody = workflow.getBody();
- if (!workflowName.endsWith(BPMN_SUFFIX)) {
- workflowName += BPMN_SUFFIX;
- }
- if (workflowBody != null) {
- logger.info(Strings.repeat("{} ", 2), "Deploying custom workflow", workflowName);
- deploymentBuilder.addString(workflowName, workflowBody);
+ logger.debug("Attempting to deploy custom workflows");
+ try {
+ List<Workflow> workflows = catalogDbClient.findWorkflowBySource(SDC_SOURCE);
+ if (workflows != null && workflows.size() != 0) {
+ for (Workflow workflow : workflows) {
+ String workflowName = workflow.getName();
+ String workflowBody = workflow.getBody();
+ if (!workflowName.endsWith(BPMN_SUFFIX)) {
+ workflowName += BPMN_SUFFIX;
+ }
+ if (workflowBody != null) {
+ logger.info(Strings.repeat("{} ", 2), "Deploying custom workflow", workflowName);
+ deploymentBuilder.addString(workflowName, workflowBody);
+ }
+ deploymentBuilder.enableDuplicateFiltering(true);
+ deploymentBuilder.deploy();
}
}
- deploymentBuilder.deploy();
+ } catch (Exception e) {
+ logger.warn("Unable to deploy custom workflows, " + e.getMessage());
}
}
}
diff --git a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml
index a91cb9d88d..e364981a66 100644
--- a/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml
+++ b/bpmn/mso-infrastructure-bpmn/src/main/resources/application.yaml
@@ -4,7 +4,7 @@ server:
max-threads: 50
mso:
infra:
- auditInventory: true
+ auditInventory: false
spring:
datasource:
driver-class-name: org.mariadb.jdbc.Driver
@@ -36,4 +36,4 @@ management:
export:
prometheus:
enabled: true # Whether exporting of metrics to Prometheus is enabled.
- step: 1m # Step size (i.e. reporting frequency) to use. \ No newline at end of file
+ step: 1m # Step size (i.e. reporting frequency) to use.