Ejemplo n.º 1
0
  /** Add step result failure information to the data context */
  private StepExecutionContext addStepFailureContextData(
      StepExecutionResult stepResult, StepExecutionContext handlerExecContext) {
    HashMap<String, String> resultData = new HashMap<String, String>();
    if (null != stepResult.getFailureData()) {
      // convert values to string
      for (final Map.Entry<String, Object> entry : stepResult.getFailureData().entrySet()) {
        resultData.put(entry.getKey(), entry.getValue().toString());
      }
    }
    FailureReason reason = stepResult.getFailureReason();
    if (null == reason) {
      reason = StepFailureReason.Unknown;
    }
    resultData.put("reason", reason.toString());
    String message = stepResult.getFailureMessage();
    if (null == message) {
      message = "No message";
    }
    resultData.put("message", message);
    // add to data context

    handlerExecContext =
        ExecutionContextImpl.builder(handlerExecContext).setContext("result", resultData).build();
    return handlerExecContext;
  }
Ejemplo n.º 2
0
 /** Add any node-specific step failure information to the node-specific data contexts */
 private StepExecutionContext addNodeStepFailureContextData(
     StepExecutionResult dispatcherStepResult, StepExecutionContext handlerExecContext) {
   final Map<String, ? extends NodeStepResult> resultMap;
   if (NodeDispatchStepExecutor.isWrappedDispatcherResult(dispatcherStepResult)) {
     DispatcherResult dispatcherResult =
         NodeDispatchStepExecutor.extractDispatcherResult(dispatcherStepResult);
     resultMap = dispatcherResult.getResults();
   } else if (NodeDispatchStepExecutor.isWrappedDispatcherException(dispatcherStepResult)) {
     DispatcherException exception =
         NodeDispatchStepExecutor.extractDispatcherException(dispatcherStepResult);
     resultMap = exception.getResultMap();
   } else {
     return handlerExecContext;
   }
   ExecutionContextImpl.Builder builder = ExecutionContextImpl.builder(handlerExecContext);
   for (final Map.Entry<String, ? extends NodeStepResult> dentry : resultMap.entrySet()) {
     String nodename = dentry.getKey();
     NodeStepResult stepResult = dentry.getValue();
     HashMap<String, String> resultData = new HashMap<String, String>();
     if (null != stepResult.getFailureData()) {
       // convert values to string
       for (final Map.Entry<String, Object> entry : stepResult.getFailureData().entrySet()) {
         resultData.put(entry.getKey(), entry.getValue().toString());
       }
     }
     FailureReason reason = stepResult.getFailureReason();
     if (null == reason) {
       reason = StepFailureReason.Unknown;
     }
     resultData.put("reason", reason.toString());
     String message = stepResult.getFailureMessage();
     if (null == message) {
       message = "No message";
     }
     resultData.put("message", message);
     // add to data context
     HashMap<String, Map<String, String>> ndata = new HashMap<String, Map<String, String>>();
     ndata.put("result", resultData);
     builder.nodeDataContext(nodename, ndata);
   }
   return builder.build();
 }