Esempio n. 1
0
 /**
  * @return Join a list of strings and then quote the entire string, if specified
  * @param commandList1 list of commands
  * @param quote quote converter
  */
 public static String joinAndQuote(List<String> commandList1, Converter<String, String> quote) {
   String join = DataContextUtils.join(commandList1, " ");
   if (null != quote) {
     join = quote.convert(join);
   }
   return join;
 }
Esempio n. 2
0
  private static ArrayList<String> buildCommandForNode(
      ExecArgList command, Map<String, Map<String, String>> dataContext, String osFamily) {
    final Converter<String, String> quote = CLIUtils.argumentQuoteForOperatingSystem(osFamily);
    final Converter<String, String> expand =
        DataContextUtils.replaceDataReferencesConverter(
            dataContext, DataContextUtils.replaceMissingOptionsWithBlank, false);

    final ArrayList<String> commandList = new ArrayList<String>();
    CommandVisitor visiter = new CommandVisitor(commandList, quote, expand);
    command.visitWith(visiter);
    return commandList;
  }
Esempio n. 3
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();
  }