summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN/src/main
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-05-15 13:23:01 -0400
committerRob Daugherty <rd472p@att.com>2018-05-15 13:58:10 -0400
commitd2e69c0d689596033a9c35aa98d37a44e2cc88cb (patch)
treebe29159a319f63c9e5c242da6354c1ef0133363a /bpmn/MSOCommonBPMN/src/main
parentb4d4cb8703842aee6df6c9a5d2a0fd6617539233 (diff)
WorkflowResponse json issues
This commit adds some robustness to the interface between the API-H and BPMN, specifically, in how the response is handled. I don't have proof, but there appears to be some randomness to the json provider behavior when used with the jax-rs. Sometimes, the serializer is adding the root element, and sometimes it is not. Maybe there's something wrong with the configuration. Maybe we have competing json providers. I couldn't pin this down. I'm almost certain it is the presence of the root element in the content that causes the API-H code to fail parsing of the BPMN response. This doesn't kill the request, as you might expect, but rather, the API-H passes the BPMN response through to the client (VID, or policy, or whatever). The original problem (SO-586) was "fixed" by "removing the wrapper". This "wrapper" is a needed feature of the interface between BPMN and the API-H. We shouldn't have removed it. The fact that the "fix" appeared to work is due to the behavior I described in the previous paragraph. The API-H chokes on the message, and it passes it through unchanged. Not really what we want. So, I don't know why the jackson/json behavior is flaky and different now, but I can (and did) modify the API-H so it can parse a json message whether or not it has a root element. Note that WorkflowResponse.java (in BPMN) and CamundaResponse.java (in the API-H) are basically the same bean representing the message format. Seems less than ideal to have two different classes. Also note that I changed the name of the "response" attribute of the WorkflowResponse and CamundaResponse classes to "content". Got tired of seeing this nonsense everywhere in the code: response.getResponse() Change-Id: Icaf70f8457de99e493cf882170fe778c620308c9 Issue-ID: SO-586 Issue-ID: SO-618 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowAsyncResource.java8
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java16
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java44
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java78
4 files changed, 87 insertions, 59 deletions
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 db11db59f7..b4543b1445 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
@@ -109,13 +109,13 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
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.setContent("Error occurred while executing the process: " + e);
response.setMessageCode(500);
recordEvents(processKey, response, startTime);
msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, logMarker
+ response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse());
+ + processKey + " with content: " + response.getContent());
Response errorResponse = Response.serverError().entity(response).build();
asyncResponse.setResponse(errorResponse);
@@ -245,10 +245,10 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService {
msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
logMarker + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+ + processKey + " with content: " + response.getContent(), "BPMN", MDC.get(processKey), null);
msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- logMarker + response.getMessage() + "for processKey: " + processKey + " with response: " + response.getResponse());
+ logMarker + response.getMessage() + "for processKey: " + processKey + " with content: " + response.getContent());
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java
index aab4faf23b..4dfae8b2a3 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowContextHolder.java
@@ -108,19 +108,19 @@ public class WorkflowContextHolder {
+ ":process key:" + processKey);
workflowResponse.setMessage("Fail");
workflowResponse.setMessageCode(400);
- workflowResponse.setResponse("Unable to correlate workflow context, bad request. Request Id: " + requestId);
+ workflowResponse.setContent("Unable to correlate workflow context, bad request. Request Id: " + requestId);
return Response.serverError().entity(workflowResponse).build();
}
responseQueue.remove(workflowContext);
msoLogger.debug("Using callback response for request id: " + requestId);
- workflowResponse.setResponse(callbackResponse.getResponse());
- workflowResponse.setProcessInstanceID(processInstanceId);
+ workflowResponse.setContent(callbackResponse.getResponse());
+ workflowResponse.setProcessInstanceId(processInstanceId);
workflowResponse.setMessageCode(callbackResponse.getStatusCode());
workflowResponse.setMessage(callbackResponse.getMessage());
sendWorkflowResponseToClient(processKey, workflowContext, workflowResponse);
- return Response.ok().entity(workflowResponse.getResponse()).build();
+ return Response.ok().entity(workflowResponse).build();
}
/**
@@ -133,7 +133,7 @@ public class WorkflowContextHolder {
WorkflowResponse workflowResponse) {
msoLogger.debug(logMarker + "Sending the response for request id: " + workflowContext.getRequestId());
recordEvents(processKey, workflowResponse, workflowContext.getStartTime());
- Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse.getResponse()).build();
+ Response response = Response.status(workflowResponse.getMessageCode()).entity(workflowResponse).build();
AsynchronousResponse asyncResp = workflowContext.getAsynchronousResponse();
asyncResp.setResponse(response);
}
@@ -152,7 +152,7 @@ public class WorkflowContextHolder {
msoLogger.debug("Preparing timeout response for " + requestObject.getProcessKey() + ":" + ":" + requestObject.getRequestId());
WorkflowResponse response = new WorkflowResponse();
response.setMessage("Fail");
- response.setResponse("Request timedout, request id:" + requestObject.getRequestId());
+ response.setContent("Request timedout, request id:" + requestObject.getRequestId());
//response.setProcessInstanceID(requestObject.getProcessInstance().getProcessInstanceId());
recordEvents(requestObject.getProcessKey(), response, requestObject.getStartTime());
response.setMessageCode(500);
@@ -178,11 +178,11 @@ public class WorkflowContextHolder {
msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
logMarker + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+ + processKey + " with content: " + response.getContent(), "BPMN", MDC.get(processKey), null);
msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, logMarker
+ response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse());
+ + processKey + " with content: " + response.getContent());
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
index dd100a3824..25c67fed63 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResource.java
@@ -135,7 +135,7 @@ public class WorkflowResource extends ProcessEngineAwareService {
}
String processInstanceId = processInstance.getId();
- workflowResponse.setProcessInstanceID(processInstanceId);
+ workflowResponse.setProcessInstanceId(processInstanceId);
responseMap = getResponseMap(processInstance, processKey, timeProcessEnded);
@@ -172,23 +172,23 @@ public class WorkflowResource extends ProcessEngineAwareService {
workflowResponse.setMessage("Fail");
if (endedWithNoResponse) {
- workflowResponse.setResponse("Process ended without producing a response");
+ workflowResponse.setContent("Process ended without producing a response");
} else {
- workflowResponse.setResponse("Request timed out, process state: " + state);
+ workflowResponse.setContent("Request timed out, process state: " + state);
}
- workflowResponse.setProcessInstanceID(processInstanceId);
+ workflowResponse.setProcessInstanceId(processInstanceId);
recordEvents(processKey, workflowResponse, startTime);
workflowResponse.setMessageCode(500);
return Response.status(500).entity(workflowResponse).build();
} catch (Exception ex) {
msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key",ex);
workflowResponse.setMessage("Fail" );
- workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage());
- if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId());
+ workflowResponse.setContent("Error occurred while executing the process: " + ex.getMessage());
+ if (processInstance != null) workflowResponse.setProcessInstanceId(processInstance.getId());
msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey),
MsoLogger.ErrorCode.UnknownError, LOGMARKER + workflowResponse.getMessage()
- + " for processKey: " + processKey + " with response: " + workflowResponse.getResponse());
+ + " for processKey: " + processKey + " with content: " + workflowResponse.getContent());
workflowResponse.setMessageCode(500);
recordEvents(processKey, workflowResponse, startTime);
@@ -221,11 +221,11 @@ public class WorkflowResource extends ProcessEngineAwareService {
msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
LOGMARKER + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+ + processKey + " with content: " + response.getContent(), "BPMN", MDC.get(processKey), null);
msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
LOGMARKER + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse());
+ + processKey + " with content: " + response.getContent());
}
private void setLogContext(String processKey, Map<String, Object> inputVariables) {
@@ -262,13 +262,13 @@ public class WorkflowResource extends ProcessEngineAwareService {
private void processResponseMap(WorkflowResponse workflowResponse, Map<String, Object> responseMap) {
Object object = responseMap.get("Response");
- String response = object == null ? null : String.valueOf(object);
- if(response == null){
+ String content = object == null ? null : String.valueOf(object);
+ if (content == null){
object = responseMap.get("WorkflowResponse");
- response = object == null ? null : String.valueOf(object);
+ content = object == null ? null : String.valueOf(object);
}
- workflowResponse.setResponse(response);
+ workflowResponse.setContent(content);
object = responseMap.get("ResponseCode");
String responseCode = object == null ? null : String.valueOf(object);
@@ -584,31 +584,31 @@ public class WorkflowResource extends ProcessEngineAwareService {
response.setVariables(variablesMap);
response.setMessage("Success");
- response.setResponse("Successfully retrieved the variables");
- response.setProcessInstanceID(processInstanceId);
+ response.setContent("Successfully retrieved the variables");
+ response.setProcessInstanceId(processInstanceId);
- msoLogger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response.getResponse());
+ msoLogger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with content: " + response.getContent());
} catch (Exception ex) {
response.setMessage("Fail");
- response.setResponse("Failed to retrieve the variables," + ex.getMessage());
- response.setProcessInstanceID(processInstanceId);
+ response.setContent("Failed to retrieve the variables," + ex.getMessage());
+ response.setProcessInstanceId(processInstanceId);
msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), MsoLogger.ErrorCode.UnknownError, LOGMARKER
+ response.getMessage()
+ " for processKey: "
+ processKey
- + " with response: "
- + response.getResponse());
+ + " with content: "
+ + response.getContent());
msoLogger.debug("Exception :",ex);
}
msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
LOGMARKER + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null);
+ + processKey + " with content: " + response.getContent(), "BPMN", MDC.get(processKey), null);
msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
LOGMARKER + response.getMessage() + " for processKey: "
- + processKey + " with response: " + response.getResponse());
+ + processKey + " with content: " + response.getContent());
return response;
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java
index e0382d1bda..02702e3b3c 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/workflow/service/WorkflowResponse.java
@@ -22,48 +22,76 @@ package org.openecomp.mso.bpmn.common.workflow.service;
import java.util.Map;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
/**
- * @version 1.0
- * Synchronous workflow response bean
- *
+ * A synchronous response from a workflow.
*/
public class WorkflowResponse {
- private String response;
- private String message;
- private String processInstanceID;
- private Map<String,String> variables;
+ @JsonProperty("processInstanceId")
+ private String processInstanceId;
+
+ @JsonProperty("messageCode")
private int messageCode;
+
+ @JsonProperty("message")
+ private String message;
- public String getResponse() {
- return response;
+ @JsonProperty("variables")
+ private Map<String,String> variables;
+
+ @JsonProperty("content")
+ private String content;
+
+ public String getProcessInstanceId() {
+ return processInstanceId;
}
- public void setResponse(String response) {
- this.response = response;
+
+ public void setProcessInstanceId(String processInstanceId) {
+ this.processInstanceId = processInstanceId;
+ }
+
+ public int getMessageCode() {
+ return messageCode;
}
+
+ public void setMessageCode(int messageCode) {
+ this.messageCode = messageCode;
+ }
+
public String getMessage() {
return message;
}
+
public void setMessage(String message) {
this.message = message;
}
- public String getProcessInstanceID() {
- return processInstanceID;
- }
- public void setProcessInstanceID(String pID) {
- this.processInstanceID = pID;
- }
- public Map<String, String> getVariables() {
+
+ public Map<String,String> getVariables() {
return variables;
}
- public void setVariables(Map<String, String> variables) {
+
+ public void setVariables(Map<String,String> variables) {
this.variables = variables;
}
- public void setMessageCode(int messageCode) {
- this.messageCode = messageCode;
+
+ public String getContent() {
+ return content;
}
-
- public int getMessageCode() {
- return messageCode;
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() + "["
+ + "processInstanceId=" + processInstanceId
+ + ",messageCode=" + messageCode
+ + ",message=" + message
+ + ",variables=" + variables
+ + ",content=" + content
+ + "]";
}
-}
+} \ No newline at end of file