@Override
  public void addScript(String exe, List<String> exeArgs) {
    super.addScript(exe, exeArgs);

    File scriptFile = new File(this.baseWorkingDirectory, exe);

    ensureExecutable(scriptFile);

    ProcessExecution pe = new ProcessExecution(scriptFile.getAbsolutePath());
    pe.setArguments(exeArgs);
    pe.setWaitForCompletion(30 * 60 * 1000L);
    pe.setWorkingDirectory(scriptFile.getParent());

    String msg;
    ProcessExecutionResults results = this.systemInfo.executeProcess(pe);
    if (results.getError() != null) {
      msg = "Could not execute script [" + pe + "]: " + results;
      audit("script", BundleResourceDeploymentHistory.Status.FAILURE, msg);
      throw new RuntimeException(msg, results.getError());
    } else {
      msg = "Executed script [" + pe + "]";
      audit("script", BundleResourceDeploymentHistory.Status.SUCCESS, msg);
    }

    return;
  }
  @Override
  public void addFile(String source, String destination) {
    super.addFile(source, destination);

    File sourceFile = new File(this.baseWorkingDirectory, source);
    File destinationFile = new File(destination);

    try {
      destinationFile.getParentFile().mkdirs();
      FileUtil.copyFile(sourceFile, destinationFile);
      audit(
          "file",
          BundleResourceDeploymentHistory.Status.SUCCESS,
          "copied file [" + sourceFile + "] to [" + destinationFile + "]");
    } catch (Exception e) {
      String msg = "Failed to copy file [" + sourceFile + "] to [" + destinationFile + "]";
      audit("file", BundleResourceDeploymentHistory.Status.FAILURE, msg);
      throw new RuntimeException(msg, e);
    }

    return;
  }
  @Override
  public void addCommand(String exe, List<String> exeArgs) {
    super.addCommand(exe, exeArgs);

    ProcessExecution pe = new ProcessExecution(exe);
    pe.setArguments(exeArgs);
    pe.setWaitForCompletion(30 * 60 * 1000L);
    pe.setCheckExecutableExists(false);
    pe.setWorkingDirectory(this.baseWorkingDirectory);

    String msg;
    ProcessExecutionResults results = this.systemInfo.executeProcess(pe);
    if (results.getError() != null) {
      msg = "Could not execute command [" + pe + "]: " + results;
      audit("command", BundleResourceDeploymentHistory.Status.FAILURE, msg);
      throw new RuntimeException(msg, results.getError());
    } else {
      msg = "Executed command [" + pe + "]";
      audit("command", BundleResourceDeploymentHistory.Status.SUCCESS, msg);
    }

    return;
  }
  @Override
  public void addDeployFile(String filename, String directory) {
    super.addDeployFile(filename, directory);

    String msg;
    File existingFile = new File(this.baseWorkingDirectory, filename);
    ProcessExecution pe = getUnzipExecution(existingFile, directory);

    if (pe != null) {
      ProcessExecutionResults results = this.systemInfo.executeProcess(pe);
      if (results.getError() != null) {
        msg = "Could not unbundle file [" + pe + "]: " + results;
        audit("deploy", BundleResourceDeploymentHistory.Status.FAILURE, msg);
        throw new RuntimeException(msg, results.getError());
      } else if (results.getExitCode() == null || results.getExitCode().intValue() > 0) {
        msg = "Failed to unbundle file [" + pe + "]: " + results;
        audit("deploy", BundleResourceDeploymentHistory.Status.FAILURE, msg);
        throw new RuntimeException(msg);
      } else {
        msg = "extracted files from [" + existingFile + "] to [" + directory + "]";
      }
      // existingFile.delete(); WOULD WE WANT TO REMOVE THE COMPRESSED FILE?
      audit("deploy", BundleResourceDeploymentHistory.Status.SUCCESS, msg);
    } else {
      // not a zipped format - just move the file to the directory as-is
      File newFile = new File(directory, filename);
      if (!existingFile.renameTo(newFile)) {
        msg = "Failed to move [" + existingFile + "] to [" + newFile + "]";
        audit("deploy", BundleResourceDeploymentHistory.Status.FAILURE, msg);
        throw new RuntimeException(msg);
      }
      audit(
          "deploy",
          BundleResourceDeploymentHistory.Status.SUCCESS,
          "renamed [" + existingFile + "] to [" + newFile + "]");
    }
  }
 @Override
 public void addReplacementVariables(Set<String> replacementVariables) {
   super.addReplacementVariables(replacementVariables);
 }
  @Override
  public void addRealizedFile(String file) {
    super.addRealizedFile(file);

    String msg;
    File trueFile = new File(file);
    RecipeParser parser = getParser();
    File realizedTmpFile = null;
    FileWriter realizedTmpFileWriter = null;
    BufferedReader reader = null;

    try {

      realizedTmpFile = File.createTempFile("rhq-realize-", ".tmp", trueFile.getParentFile());
      realizedTmpFileWriter = new FileWriter(realizedTmpFile);

      reader = new BufferedReader(new FileReader(trueFile));
      String line = reader.readLine();
      while (line != null) {
        line = parser.replaceReplacementVariables(this, line);
        realizedTmpFileWriter.write(line);
        realizedTmpFileWriter.write("\n");
        line = reader.readLine();
      }

      realizedTmpFileWriter.close();
      realizedTmpFileWriter = null;
      reader.close();
      reader = null;

      audit("realize", BundleResourceDeploymentHistory.Status.SUCCESS, "realized [" + file + "]");

      trueFile.delete(); // remove the one with the replacement variables in it
      if (!realizedTmpFile.renameTo(trueFile)) {
        msg = "Failed to rename realized tmp file [" + realizedTmpFile + "] to [" + trueFile + "]";
        audit("realize", BundleResourceDeploymentHistory.Status.FAILURE, msg);
        throw new RuntimeException(msg);
      }

      audit(
          "realize",
          BundleResourceDeploymentHistory.Status.SUCCESS,
          "renamed realized file [" + realizedTmpFile + "] to [" + trueFile + "]");
    } catch (Exception e) {
      msg = "Cannot realize file [" + file + "]";
      audit("realize", BundleResourceDeploymentHistory.Status.FAILURE, msg);
      throw new RuntimeException(msg, e);
    } finally {
      if (realizedTmpFileWriter != null) {
        try {
          realizedTmpFileWriter.close();
        } catch (Exception e) {
        }
      }
      if (reader != null) {
        try {
          reader.close();
        } catch (Exception e) {
        }
      }
      if (realizedTmpFile != null && realizedTmpFile.exists()) {
        realizedTmpFile.delete();
      }
    }
  }