Пример #1
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();
 }
 @Override
 public String toString() {
   if (null != description) {
     return description;
   }
   if (success) {
     return "Dispatch successful (" + results.size() + " nodes)";
   } else {
     int i = 0;
     ArrayList<String> names = new ArrayList<String>();
     for (final String s : results.keySet()) {
       NodeStepResult stepResult = results.get(s);
       if (!stepResult.isSuccess()) {
         i++;
         names.add(s + ": " + stepResult.toString());
       }
     }
     return "Dispatch failed on " + i + " nodes: " + names;
   }
 }