class OozieConfigCalculation extends AbstractUpgradeServerAction {

  public static String processPropertyValue(String oldContent) {
    // For regex simplicity, will not work with multiline export definitions that are
    // split on few strings using \ character
    // False negative should be a less bit of trouble (just duplicate exports/option definitions)
    // than false positive (broken Oozie after upgrade)
    Pattern regex = Pattern.compile("^export HADOOP_OPTS=.*-Dhdp.version=.*$", Pattern.MULTILINE);
    Matcher regexMatcher = regex.matcher(oldContent);
    if (regexMatcher.find()) {
      return oldContent;
    } else {
      StringBuilder newContent = new StringBuilder(oldContent);
      newContent.append("\n").append(
        "export HADOOP_OPTS=\"-Dhdp.version=$HDP_VERSION $HADOOP_OPTS\" "
      );
      return newContent.toString();
    }
  }

}