private List<String> getNodeNames(StepExecutionContext executionContext) {
   List<INodeEntry> orderedNodes =
       INodeEntryComparator.rankOrderedNodes(
           executionContext.getNodes(),
           executionContext.getNodeRankAttribute(),
           executionContext.isNodeRankOrderAscending());
   List<String> names = new ArrayList<String>();
   for (INodeEntry orderedNode : orderedNodes) {
     names.add(orderedNode.getNodename());
   }
   return names;
 }
Ejemplo n.º 2
0
  @Override
  public StepExecutionResult executeWorkflowStep(
      final StepExecutionContext executionContext, final StepExecutionItem item)
      throws StepException {
    Map<String, Object> instanceConfiguration = getStepConfiguration(item);
    if (null != instanceConfiguration) {
      instanceConfiguration =
          DataContextUtils.replaceDataReferences(
              instanceConfiguration, executionContext.getDataContext());
    }
    final String providerName = item.getType();
    final PropertyResolver resolver =
        PropertyResolverFactory.createStepPluginRuntimeResolver(
            executionContext,
            instanceConfiguration,
            ServiceNameConstants.WorkflowStep,
            providerName);
    final PluginStepContext stepContext = PluginStepContextImpl.from(executionContext);
    final Map<String, Object> config =
        PluginAdapterUtility.configureProperties(
            resolver, getDescription(), plugin, PropertyScope.InstanceOnly);
    try {
      plugin.executeStep(stepContext, config);
    } catch (StepException e) {
      executionContext.getExecutionListener().log(Constants.ERR_LEVEL, e.getMessage());
      final StringWriter stringWriter = new StringWriter();
      e.printStackTrace(new PrintWriter(stringWriter));
      executionContext
          .getExecutionListener()
          .log(
              Constants.DEBUG_LEVEL,
              "Failed executing step plugin [" + providerName + "]: " + stringWriter.toString());

      return new StepExecutionResultImpl(e, e.getFailureReason(), e.getMessage());
    } catch (Throwable e) {
      final StringWriter stringWriter = new StringWriter();
      e.printStackTrace(new PrintWriter(stringWriter));
      executionContext
          .getExecutionListener()
          .log(
              Constants.DEBUG_LEVEL,
              "Failed executing step plugin [" + providerName + "]: " + stringWriter.toString());
      return new StepExecutionResultImpl(e, StepFailureReason.PluginFailed, e.getMessage());
    }
    return new StepExecutionResultImpl();
  }