Esempio n. 1
0
 @Override
 public Description getDescription() {
   if (plugin instanceof Describable) {
     final Describable desc = (Describable) plugin;
     return desc.getDescription();
   } else {
     return PluginAdapterUtility.buildDescription(plugin, DescriptionBuilder.builder());
   }
 }
Esempio 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();
  }