aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2017-09-19 18:08:26 -0400
committerRob Daugherty <rd472p@att.com>2017-09-19 18:15:31 -0400
commitbb5668fdd40f923694a4aa3a3b5bf5f7009b6cd7 (patch)
tree63ea237a59cf48ceae67e9e6d9214a5df28c796b /bpmn/MSOCommonBPMN/src
parent3c6e2c520783eaf4a703ff2adfd94324d2fd3fae (diff)
BPMN applications not deployed properly
Since the 1710 MSO merge the following problems exist: The workflow applications are not deployed properly. I've also fixed a few small issues with the CreateCustomE2EServiceInstance flows that prevented them from being deployed. Change-Id: Ia4f7a6de87abbc99e80c0e9083e2175cdf9b4fe5 Issue-id: SO-148 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java32
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java68
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java3
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java5
6 files changed, 70 insertions, 44 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java
new file mode 100644
index 0000000000..249283923a
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncCommonResource.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.bpmn.common.workflow.service;
+
+import org.camunda.bpm.engine.ProcessEngineServices;
+import org.camunda.bpm.engine.ProcessEngines;
+
+
+public class WorkflowAsyncCommonResource extends WorkflowAsyncResource {
+
+ protected ProcessEngineServices getProcessEngineServices() {
+ return pes4junit.orElse(ProcessEngines.getProcessEngine("common"));
+ }
+}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
index 9787ec07b5..4f621128f2 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java
@@ -21,6 +21,8 @@ package org.openecomp.mso.bpmn.common.workflow.service;
import java.util.HashMap;
import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
import java.util.UUID;
import javax.ws.rs.Consumes;
@@ -31,7 +33,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.ProcessEngines;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.runtime.ProcessInstance;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
@@ -52,15 +53,15 @@ import org.slf4j.MDC;
* For asynchronous process - the activity may send a acknowledgement response and then proceed further on executing the process
*/
@Path("/async")
-public class WorkflowAsyncResource {
+public abstract class WorkflowAsyncResource {
- private WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
- protected ProcessEngineServices pes4junit = null;
+ private static final WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance();
+ protected Optional<ProcessEngineServices> pes4junit = Optional.empty();
- private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
+ private final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL);
private static final String logMarker = "[WRKFLOW-RESOURCE]";
- private static final int DEFAULT_WAIT_TIME = 30000; //default wait time
+ private static final long DEFAULT_WAIT_TIME = 30000; //default wait time
/**
* Asynchronous JAX-RS method that starts a process instance.
@@ -75,7 +76,6 @@ public class WorkflowAsyncResource {
public void startProcessInstanceByKey(final @Suspend(180000) AsynchronousResponse asyncResponse,
@PathParam("processKey") String processKey, VariableMapImpl variableMap) {
- WorkflowResponse response = new WorkflowResponse();
long startTime = System.currentTimeMillis();
Map<String, Object> inputVariables = null;
WorkflowContext workflowContext = null;
@@ -107,6 +107,7 @@ public class WorkflowAsyncResource {
}
msoLogger.debug(logMarker + "Exception in startProcessInstance by key");
+ WorkflowResponse response = new WorkflowResponse();
response.setMessage("Fail" );
response.setResponse("Error occurred while executing the process: " + e);
response.setMessageCode(500);
@@ -205,29 +206,28 @@ public class WorkflowAsyncResource {
return contextHolder.processCallback(processKey, processInstanceId, requestId, callbackResponse);
}
+ private static String getOrCreate(Map<String, Object> inputVariables, String key) {
+ String value = Objects.toString(inputVariables.get(key), null);
+ if (value == null) {
+ value = UUID.randomUUID().toString();
+ inputVariables.put(key, value);
+ }
+ return value;
+ }
+
// Note: the business key is used to identify the process in unit tests
- private String getBusinessKey(Map<String, Object> inputVariables) {
- Object businessKey = inputVariables.get("mso-business-key");
- if (businessKey == null ) {
- businessKey = UUID.randomUUID().toString();
- inputVariables.put("mso-business-key", businessKey);
- }
- return businessKey.toString();
+ private static String getBusinessKey(Map<String, Object> inputVariables) {
+ return getOrCreate(inputVariables, "mso-business-key");
}
- private String getRequestId(Map<String, Object> inputVariables) {
- Object requestId = inputVariables.get("mso-request-id");
- if (requestId == null ) {
- requestId = UUID.randomUUID().toString();
- inputVariables.put("mso-request-id", requestId);
- }
- return requestId.toString();
+ private static String getRequestId(Map<String, Object> inputVariables) {
+ return getOrCreate(inputVariables, "mso-request-id");
}
private long getWaitTime(Map<String, Object> inputVariables)
{
- String timeout = inputVariables.get("mso-service-request-timeout") == null
- ? null : inputVariables.get("mso-service-request-timeout").toString();
+
+ String timeout = Objects.toString(inputVariables.get("mso-service-request-timeout"), null);
if (timeout != null) {
try {
@@ -252,7 +252,7 @@ public class WorkflowAsyncResource {
}
- private void setLogContext(String processKey,
+ private static void setLogContext(String processKey,
Map<String, Object> inputVariables) {
MsoLogger.setServiceName("MSO." + processKey);
if (inputVariables != null) {
@@ -260,32 +260,24 @@ public class WorkflowAsyncResource {
}
}
- private String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) {
+ private static String getKeyValueFromInputVariables(Map<String,Object> inputVariables, String key) {
if (inputVariables == null) return "";
- Object requestId = inputVariables.get(key);
- if (requestId != null) return requestId.toString();
- return "N/A";
+ return Objects.toString(inputVariables.get(key), "N/A");
}
private boolean isProcessEnded(String processInstanceId) {
ProcessEngineServices pes = getProcessEngineServices();
- return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ;
+ return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null;
}
- protected ProcessEngineServices getProcessEngineServices() {
- if (pes4junit == null) {
- return ProcessEngines.getDefaultProcessEngine();
- } else {
- return pes4junit;
- }
- }
+ protected abstract ProcessEngineServices getProcessEngineServices();
public void setProcessEngineServices4junit(ProcessEngineServices pes) {
- pes4junit = pes;
+ pes4junit = Optional.ofNullable(pes);
}
- private Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
+ private static Map<String, Object> getInputVariables(VariableMapImpl variableMap) {
Map<String, Object> inputVariables = new HashMap<String,Object>();
@SuppressWarnings("unchecked")
Map<String, Object> vMap = (Map<String, Object>) variableMap.get("variables");
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
index b2b5755d17..4f99edd660 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResourceApplication.java
@@ -41,7 +41,7 @@ public class WorkflowResourceApplication extends Application {
public WorkflowResourceApplication() {
singletons.add(new WorkflowResource());
- singletons.add(new WorkflowAsyncResource());
+ singletons.add(new WorkflowAsyncCommonResource());
singletons.add(new WorkflowMessageResource());
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java
index c476c6577f..c99e6d615b 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java
@@ -19,6 +19,7 @@ import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
import org.jboss.resteasy.spi.AsynchronousResponse;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
@@ -166,7 +167,7 @@ public class BPMNUtil {
* @param variables
*/
private static void executeAsyncFlow(ProcessEngineServices processEngineServices, String processKey, AsynchronousResponse asyncResponse, Map<String,String> variables) {
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncCommonResource();
VariableMapImpl variableMap = new VariableMapImpl();
Map<String, Object> variableValueType = new HashMap<String, Object>();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java
index 426bceef4b..51a1484cf9 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java
@@ -31,7 +31,7 @@ import org.camunda.bpm.engine.test.Deployment;
import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
import org.jboss.resteasy.spi.AsynchronousResponse;
import org.junit.Test;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
public class WorkflowAsyncResourceTest extends WorkflowTest {
@@ -53,7 +53,7 @@ public class WorkflowAsyncResourceTest extends WorkflowTest {
}
private void executeWorkflow(String request, String requestId, AsynchronousResponse asyncResponse, String processKey) {
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
+ WorkflowAsyncCommonResource workflowResource = new WorkflowAsyncCommonResource();
VariableMapImpl variableMap = new VariableMapImpl();
Map<String, Object> variableValueType = new HashMap<String, Object>();
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
index 15dc4f4609..63403f40ce 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java
@@ -75,6 +75,7 @@ import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification;
import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback;
import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
import org.openecomp.mso.bpmn.common.workflow.service.VnfAdapterNotifyServiceImpl;
+import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncCommonResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
@@ -272,7 +273,7 @@ public class WorkflowTest {
VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
System.out.println("Sending " + request + " to " + processKey + " process");
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncCommonResource();
workflowResource.setProcessEngineServices4junit(processEngineRule);
TestAsyncResponse asyncResponse = new TestAsyncResponse();
@@ -305,7 +306,7 @@ public class WorkflowTest {
VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
System.out.println("Sending " + request + " to " + processKey + " process");
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
+ WorkflowAsyncResource workflowResource = new WorkflowAsyncCommonResource();
workflowResource.setProcessEngineServices4junit(processEngineRule);
TestAsyncResponse asyncResponse = new TestAsyncResponse();