mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
07.33.2015 e053b9e30a44e9a116b42938107aadec60c762bc
PENDJ-1714 Code cleanup

* InstallReviewPanel
** Use Constants.LINE_SEPARATOR instead of redefined it

* Utils.java
** Refactor getDataDisplayString() method:
*** Reformat
*** Add final keyword
*** ** Use Constants.LINE_SEPARATOR instead of hardcoded "\n"
3 files modified
56 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/quicksetup/Constants.java 3 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/InstallReviewPanel.java 8 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java 45 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/quicksetup/Constants.java
@@ -34,8 +34,7 @@
public class Constants {
  /** Platform appropriate line separator. */
  public static final String LINE_SEPARATOR =
          System.getProperty("line.separator");
  public static final String LINE_SEPARATOR = System.getProperty("line.separator");
  /** HTML line break tag. */
  public static final String HTML_LINE_BREAK = "<br>";
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/InstallReviewPanel.java
@@ -82,8 +82,6 @@
  private static final long serialVersionUID = -7356174829193265699L;
  private static final String EOL = System.getProperty("line.separator");
  private final boolean displayServerLocation;
  private final HashMap<FieldName, JLabel> hmLabels = new HashMap<FieldName, JLabel>();
@@ -419,7 +417,7 @@
      for (final LocalizableMessage line : remoteServerLines)
      {
        buf.append(EOL).append(line);
        buf.append(Constants.LINE_SEPARATOR).append(line);
      }
    }
    else
@@ -450,7 +448,7 @@
     return INFO_USE_CUSTOM_SERVER_RUNTIME.get(serverArguments.getStringArguments()).toString();
   }
   return INFO_USE_CUSTOM_SERVER_RUNTIME.get(serverArguments.getStringArguments()) + EOL
   return INFO_USE_CUSTOM_SERVER_RUNTIME.get(serverArguments.getStringArguments()) + Constants.LINE_SEPARATOR
        + INFO_USE_CUSTOM_IMPORT_RUNTIME.get(importArguments.getStringArguments());
 }
@@ -809,7 +807,7 @@
    else if (linesToAdd.size() > 1)
    {
      final String arg0 = getJavaPropertiesFilePath(userData);
      final String arg1 = joinAsString(EOL, linesToAdd);
      final String arg1 = joinAsString(Constants.LINE_SEPARATOR, linesToAdd);
      sb.append(formatter.getFormattedProgress(INFO_EDIT_JAVA_PROPERTIES_LINES.get(arg0, arg1)));
    }
opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
@@ -1377,36 +1377,31 @@
  /**
   * Returns the localized string describing the DataOptions chosen by the user.
   * @param userInstallData the DataOptions of the user.
   *
   * @param userInstallData
   *          the DataOptions of the user.
   * @return the localized string describing the DataOptions chosen by the user.
   */
  public static String getDataDisplayString(UserData userInstallData)
  public static String getDataDisplayString(final UserData userInstallData)
  {
    LocalizableMessage msg;
    DataReplicationOptions repl =
      userInstallData.getReplicationOptions();
    final DataReplicationOptions repl = userInstallData.getReplicationOptions();
    final SuffixesToReplicateOptions suf = userInstallData.getSuffixesToReplicateOptions();
    SuffixesToReplicateOptions suf =
      userInstallData.getSuffixesToReplicateOptions();
    boolean createSuffix =
      repl.getType() == DataReplicationOptions.Type.FIRST_IN_TOPOLOGY ||
      repl.getType() == DataReplicationOptions.Type.STANDALONE ||
      suf.getType() == SuffixesToReplicateOptions.Type.NEW_SUFFIX_IN_TOPOLOGY;
    boolean createSuffix = repl.getType() == DataReplicationOptions.Type.FIRST_IN_TOPOLOGY
        || repl.getType() == DataReplicationOptions.Type.STANDALONE
        || suf.getType() == SuffixesToReplicateOptions.Type.NEW_SUFFIX_IN_TOPOLOGY;
    if (createSuffix)
    {
      LocalizableMessage arg2;
      NewSuffixOptions options = userInstallData.getNewSuffixOptions();
      switch (options.getType())
      {
      case CREATE_BASE_ENTRY:
        arg2 = INFO_REVIEW_CREATE_BASE_ENTRY_LABEL.get(
            options.getBaseDns().getFirst());
        arg2 = INFO_REVIEW_CREATE_BASE_ENTRY_LABEL.get(options.getBaseDns().getFirst());
        break;
      case LEAVE_DATABASE_EMPTY:
@@ -1418,12 +1413,11 @@
        break;
      case IMPORT_AUTOMATICALLY_GENERATED_DATA:
        arg2 = INFO_REVIEW_IMPORT_AUTOMATICALLY_GENERATED.get(
                options.getNumberEntries());
        arg2 = INFO_REVIEW_IMPORT_AUTOMATICALLY_GENERATED.get(options.getNumberEntries());
        break;
      default:
        throw new IllegalArgumentException("Unknown type: "+options.getType());
        throw new IllegalArgumentException("Unknown type: " + options.getType());
      }
      if (options.getBaseDns().isEmpty())
@@ -1432,30 +1426,27 @@
      }
      else if (options.getBaseDns().size() > 1)
      {
        msg = INFO_REVIEW_CREATE_SUFFIX.get(
            joinAsString(Constants.LINE_SEPARATOR, options.getBaseDns()),
            arg2);
        msg = INFO_REVIEW_CREATE_SUFFIX.get(joinAsString(Constants.LINE_SEPARATOR, options.getBaseDns()), arg2);
      }
      else
      {
        msg = INFO_REVIEW_CREATE_SUFFIX.get(options.getBaseDns().getFirst(),
          arg2);
        msg = INFO_REVIEW_CREATE_SUFFIX.get(options.getBaseDns().getFirst(), arg2);
      }
    }
    else
    {
      StringBuilder buf = new StringBuilder();
      Set<SuffixDescriptor> suffixes = suf.getSuffixes();
      for (SuffixDescriptor suffix : suffixes)
      final StringBuilder buf = new StringBuilder();
      for (final SuffixDescriptor suffix : suf.getSuffixes())
      {
        if (buf.length() > 0)
        {
          buf.append("\n");
          buf.append(Constants.LINE_SEPARATOR);
        }
        buf.append(suffix.getDN());
      }
      msg = INFO_REVIEW_REPLICATE_SUFFIX.get(buf);
    }
    return msg.toString();
  }