From 3b230cd5af114fd8800f2aa56b7dc06db6cb0db6 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 02 Feb 2016 16:00:11 +0000
Subject: [PATCH] Simplified widespread use of OperatingSystem.isWindows() and duplication by using methods dedicated to a task

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java |    8 
 opendj-server-legacy/src/main/java/org/opends/quicksetup/CurrentInstallStatus.java               |   16 
 opendj-server-legacy/src/main/java/org/opends/server/util/cli/PointAdder.java                    |   35 -
 opendj-server-legacy/src/main/java/org/opends/quicksetup/util/FileManager.java                   |  102 +-----
 opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SetupLauncher.java            |   40 +-
 opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ZipExtractor.java                  |   61 ++--
 opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java                         |  263 +++++++-----------
 opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java          |  113 +++----
 opendj-server-legacy/src/main/java/org/opends/quicksetup/Installation.java                       |  133 +--------
 opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java          |   12 
 10 files changed, 261 insertions(+), 522 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/CurrentInstallStatus.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/CurrentInstallStatus.java
index a981228..ea02c21 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/CurrentInstallStatus.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/CurrentInstallStatus.java
@@ -22,22 +22,20 @@
  *
  *
  *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2015 ForgeRock AS.
+ *      Portions Copyright 2012-2016 ForgeRock AS.
  */
 package org.opends.quicksetup;
 
-import org.forgerock.i18n.LocalizableMessage;
-import org.forgerock.i18n.LocalizableMessageBuilder;
 import static org.opends.messages.QuickSetupMessages.*;
-import static com.forgerock.opendj.util.OperatingSystem.isWindows;
 
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.i18n.LocalizableMessageBuilder;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
-
 import org.opends.quicksetup.util.Utils;
 
 /**
@@ -98,9 +96,7 @@
           buf.append(Constants.LINE_SEPARATOR);
           buf.append("- ").append(msg);
         }
-        String cmd = isWindows() ?
-            Installation.WINDOWS_SETUP_FILE_NAME :
-              Installation.UNIX_SETUP_FILE_NAME;
+        String cmd = Installation.getSetupFileName();
         installationMsg = INFO_INSTALLSTATUS_INSTALLED_CLI.get(cmd, buf);
       }
       else
@@ -166,8 +162,6 @@
     }
   }
 
-
-
   /**
    * Indicates whether there are database files under this installation.
    *
@@ -181,8 +175,6 @@
     return children != null && children.length > 0;
   }
 
-
-
   /**
    * Indicates whether there are config files under this installation.
    *
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/Installation.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/Installation.java
index d87e7a4..5b8f089 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/Installation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/Installation.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS
+ *      Portions Copyright 2011-2016 ForgeRock AS
  */
 package org.opends.quicksetup;
 
@@ -52,7 +52,6 @@
  */
 public final class Installation
 {
-
   /** Relative path to bootstrap OpenDJ jar file. */
   public static final String OPENDJ_BOOTSTRAP_JAR_RELATIVE_PATH = "lib/bootstrap.jar";
   /** Relative path to bootstrap-client OpenDJ jar file. */
@@ -136,10 +135,7 @@
   /** The Windows import LDIF batch file name. */
   public static final String WINDOWS_IMPORT_LDIF = "import-ldif.bat";
 
-  /**
-   * Name of the file kept in the history directory containing logs of upgrade
-   * and reversions.
-   */
+  /** Name of the file kept in the history directory containing logs of upgrade and reversions. */
   public static final String HISTORY_LOG_FILE_NAME = "log";
   /** The default java properties file. */
   public static final String DEFAULT_JAVA_PROPERTIES_FILE = "java.properties";
@@ -219,12 +215,8 @@
     }
   }
 
-
-
   private static Installation local;
 
-
-
   /**
    * Obtains the installation by reading the classpath of the running JVM to
    * determine the location of the jars and determine the installation root.
@@ -235,7 +227,6 @@
   {
     if (local == null)
     {
-
       // This allows testing of configuration components when the OpenDJ.jar
       // in the classpath does not necessarily point to the server's
       String installRoot = System.getProperty("org.opends.quicksetup.Root");
@@ -255,8 +246,6 @@
     return local;
   }
 
-
-
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
   private File rootDirectory;
@@ -270,7 +259,6 @@
   private BuildInformation buildInformation;
   private BuildInformation instanceInformation;
 
-
   /**
    * Creates a new instance from a root directory specified as a string.
    *
@@ -284,8 +272,6 @@
     this(new File(rootDirectory), new File(instanceRootDirectory));
   }
 
-
-
   /**
    * Creates a new instance from a root directory specified as a File.
    *
@@ -300,8 +286,6 @@
     setInstanceDirectory(instanceDirectory);
   }
 
-
-
   /**
    * Gets the top level directory of an OpenDJ installation.
    *
@@ -313,8 +297,6 @@
     return this.rootDirectory;
   }
 
-
-
   /**
    * Gets the top level directory of an OpenDJ instance.
    *
@@ -326,8 +308,6 @@
     return this.instanceDirectory;
   }
 
-
-
   /**
    * Sets the root directory of this installation.
    *
@@ -336,7 +316,6 @@
    */
   public void setRootDirectory(File rootDirectory)
   {
-
     // Hold off on doing validation of rootDirectory since
     // some applications (like the Installer) create an Installation
     // before the actual bits have been laid down on the file system.
@@ -359,8 +338,6 @@
     }
   }
 
-
-
   /**
    * Sets the root directory of this instance.
    *
@@ -391,8 +368,6 @@
     }
   }
 
-
-
   /**
    * Indicates whether or not this installation appears to be an actual OpenDJ
    * installation.
@@ -415,8 +390,6 @@
     }
   }
 
-
-
   /**
    * Creates a string explaining why this is not a legitimate OpenDJ
    * installation. Null if this is in fact a valid installation.
@@ -437,8 +410,6 @@
     }
   }
 
-
-
   /**
    * Gets the Configuration object representing this file. The current
    * configuration is stored in config/config.ldif.
@@ -454,8 +425,6 @@
     return configuration;
   }
 
-
-
   /**
    * Gets the Configuration object representing this file. The base
    * configuration is stored in config/upgrade/config.ldif.[svn rev].
@@ -473,8 +442,6 @@
     return baseConfiguration;
   }
 
-
-
   /**
    * Gets the current status of this installation.
    *
@@ -489,8 +456,6 @@
     return status;
   }
 
-
-
   /**
    * Returns the path to the libraries.
    *
@@ -501,8 +466,6 @@
     return new File(getRootDirectory(), LIBRARIES_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the path to the resources directory.
    *
@@ -513,8 +476,6 @@
     return new File(getRootDirectory(), RESOURCES_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the path to the classes directory.
    *
@@ -525,8 +486,6 @@
     return new File(getRootDirectory(), CLASSES_PATH_RELATIVE);
   }
 
-
-
   /**
    * Creates a File object representing config/upgrade/schema.ldif.current which
    * the server creates the first time it starts if there are schema
@@ -539,8 +498,6 @@
     return new File(getConfigurationUpgradeDirectory(), "schema.ldif.current");
   }
 
-
-
   /**
    * Creates a File object representing config/upgrade/schema.ldif.current which
    * the server creates the first time it starts if there are schema
@@ -555,8 +512,6 @@
     return new File(getConfigurationUpgradeDirectory(), "schema.ldif." + getInstanceVCSRevision());
   }
 
-
-
   /**
    * Creates a File object representing config/upgrade/schema.ldif.current which
    * the server creates the first time it starts if there are schema
@@ -571,8 +526,6 @@
     return new File(getConfigurationUpgradeDirectory(), BASE_CONFIG_FILE_PREFIX + getInstanceVCSRevision());
   }
 
-
-
   /**
    * Gets the VCS revision of the build.
    *
@@ -585,8 +538,6 @@
     return getBuildInformation().getRevision();
   }
 
-
-
   /**
    * Gets the VCS revision of the instance.
    *
@@ -599,8 +550,6 @@
     return getInstanceBuildInformation().getRevision();
   }
 
-
-
   /**
    * Returns the path to the configuration file of the directory server. Note
    * that this method assumes that this code is being run locally.
@@ -612,8 +561,6 @@
     return new File(getConfigurationDirectory(), CURRENT_CONFIG_FILE_NAME);
   }
 
-
-
   /**
    * Returns the relative path of the directory containing the binaries/scripts
    * of the Open DS installation. The path is relative to the installation path.
@@ -627,8 +574,6 @@
     return new File(getRootDirectory(), binDir);
   }
 
-
-
   /**
    * Returns the path to the database files under the install path.
    *
@@ -639,8 +584,6 @@
     return new File(getInstanceDirectory(), DATABASES_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the path to the backup files under the install path.
    *
@@ -651,8 +594,6 @@
     return new File(getInstanceDirectory(), BACKUPS_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the path to the config files under the install path.
    *
@@ -663,8 +604,6 @@
     return new File(getInstanceDirectory(), CONFIG_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the path to the log files under the install path.
    *
@@ -675,8 +614,6 @@
     return new File(getInstanceDirectory(), LOGS_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the directory where the lock files are stored.
    *
@@ -687,8 +624,6 @@
     return new File(getInstanceDirectory(), LOCKS_PATH_RELATIVE);
   }
 
-
-
   /**
    * Gets the directory used to store the template configuration.
    *
@@ -699,8 +634,6 @@
     return new File(getRootDirectory(), TEMPLATE_RELATIVE_PATH);
   }
 
-
-
   /**
    * Gets the directory used to store files temporarily.
    *
@@ -711,8 +644,6 @@
     return new File(getInstanceDirectory(), TMP_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the directory where the lock files are stored.
    *
@@ -723,8 +654,6 @@
     return new File(getInstanceDirectory(), HISTORY_PATH_RELATIVE);
   }
 
-
-
   /**
    * Creates a new directory in the history directory appropriate for backing up
    * an installation during an upgrade.
@@ -749,8 +678,6 @@
     return backupDirectory;
   }
 
-
-
   /**
    * Gets the log file where the history of upgrades and reversions is kept.
    *
@@ -761,8 +688,6 @@
     return new File(getHistoryDirectory(), HISTORY_LOG_FILE_NAME);
   }
 
-
-
   /**
    * Gets the directory config/upgrade.
    *
@@ -773,8 +698,6 @@
     return new File(getConfigurationDirectory(), UPGRADE_PATH);
   }
 
-
-
   /**
    * Gets the directory where the upgrader stores files temporarily.
    *
@@ -785,8 +708,6 @@
     return new File(getTemporaryDirectory(), UPGRADE_PATH);
   }
 
-
-
   /**
    * Gets the file for invoking a particular command appropriate for the current
    * operating system.
@@ -801,8 +722,6 @@
     return new File(getBinariesDirectory(), filename);
   }
 
-
-
   /**
    * Gets the file responsible for stopping the server appropriate for the
    * current operating system.
@@ -811,12 +730,9 @@
    */
   public File getServerStartCommandFile()
   {
-    String startFileName = isWindows() ? WINDOWS_START_FILE_NAME : UNIX_START_FILE_NAME;
-    return new File(getBinariesDirectory(), startFileName);
+    return getCommandFile(UNIX_START_FILE_NAME);
   }
 
-
-
   /**
    * Gets the file responsible for stopping the server appropriate for the
    * current operating system.
@@ -825,11 +741,18 @@
    */
   public File getServerStopCommandFile()
   {
-    String stopFileName = isWindows() ? WINDOWS_STOP_FILE_NAME : UNIX_STOP_FILE_NAME;
-    return new File(getBinariesDirectory(), stopFileName);
+    return getCommandFile(UNIX_STOP_FILE_NAME);
   }
 
-
+  /**
+   * Returns the setup file name to use with the current operating system.
+   *
+   * @return the setup file name to use with the current operating system.
+   */
+  public static String getSetupFileName()
+  {
+    return isWindows() ? WINDOWS_SETUP_FILE_NAME : UNIX_SETUP_FILE_NAME;
+  }
 
   /**
    * Returns the 'ldif' directory.
@@ -841,8 +764,6 @@
     return new File(getRootDirectory(), LDIFS_PATH_RELATIVE);
   }
 
-
-
   /**
    * Returns the path to the quicksetup jar file.
    *
@@ -853,8 +774,6 @@
     return new File(getLibrariesDirectory(), "quicksetup.jar");
   }
 
-
-
   /**
    * Returns the path to the opends jar file.
    *
@@ -865,8 +784,6 @@
     return new File(getLibrariesDirectory(), "OpenDJ.jar");
   }
 
-
-
   /**
    * Returns the path to the uninstall.bat file.
    *
@@ -877,8 +794,6 @@
     return new File(getRootDirectory(), "uninstall.bat");
   }
 
-
-
   /**
    * Gets the control panel command file appropriate for the current operating
    * system.
@@ -887,23 +802,14 @@
    */
   public File getControlPanelCommandFile()
   {
-    if (isWindows())
-    {
-      return new File(getBinariesDirectory(), WINDOWS_CONTROLPANEL_FILE_NAME);
-    }
-    else if (isMacOS())
+    if (isMacOS())
     {
       String binDir = getRootDirectory() + File.separator + MAC_APPLICATIONS_PATH_RELATIVE;
       return new File(binDir, MAC_CONTROLPANEL_FILE_NAME);
     }
-    else
-    {
-      return new File(getBinariesDirectory(), UNIX_CONTROLPANEL_FILE_NAME);
-    }
+    return getCommandFile(UNIX_CONTROLPANEL_FILE_NAME);
   }
 
-
-
    /**
    * Gets information about the build that was used to produce the bits for this
    * installation.
@@ -917,8 +823,6 @@
     return getBuildInformation(true);
   }
 
-
-
   /**
    * Gets information about the build that was used to produce the bits for this
    * installation.
@@ -963,8 +867,6 @@
     return buildInformation;
   }
 
-
-
   /**
    * Gets information about the build that was used to produce the instance.
    *
@@ -975,8 +877,6 @@
     return getInstanceBuildInformation(true);
   }
 
-
-
   /**
    * Gets information about the build that was used to produce the instance.
    *
@@ -999,8 +899,7 @@
           // Read the first line and close the file.
           try (BufferedReader reader = new BufferedReader(new FileReader(bif)))
           {
-            String line = reader.readLine();
-            instanceInformation = BuildInformation.fromBuildString(line);
+            instanceInformation = BuildInformation.fromBuildString(reader.readLine());
           }
         }
         else
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
index 2b607b0..52b422d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/InstallerHelper.java
@@ -22,17 +22,18 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS
+ *      Portions Copyright 2011-2016 ForgeRock AS
  */
-
 package org.opends.quicksetup.installer;
 
-import static org.opends.messages.QuickSetupMessages.*;
-import static org.opends.quicksetup.util.Utils.*;
-
 import static com.forgerock.opendj.cli.Utils.*;
 import static com.forgerock.opendj.util.OperatingSystem.*;
 
+import static org.opends.messages.QuickSetupMessages.*;
+import static org.opends.quicksetup.Installation.*;
+import static org.opends.quicksetup.util.Utils.*;
+import static org.opends.server.types.ExistingFileBehavior.*;
+
 import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.Closeable;
@@ -65,7 +66,6 @@
 import org.opends.messages.ReplicationMessages;
 import org.opends.quicksetup.Application;
 import org.opends.quicksetup.ApplicationException;
-import org.opends.quicksetup.Installation;
 import org.opends.quicksetup.JavaArguments;
 import org.opends.quicksetup.ReturnCode;
 import org.opends.quicksetup.UserData;
@@ -95,8 +95,6 @@
 import org.opends.server.tools.JavaPropertiesTool;
 import org.opends.server.types.DN;
 import org.opends.server.types.DirectoryException;
-import org.opends.server.types.Entry;
-import org.opends.server.types.ExistingFileBehavior;
 import org.opends.server.types.LDIFExportConfig;
 import org.opends.server.types.OpenDsException;
 import org.opends.server.util.LDIFException;
@@ -120,6 +118,7 @@
 
   private static final int MAX_ID_VALUE = Short.MAX_VALUE;
   private static final long ONE_MEGABYTE = 1024L * 1024;
+
   /**
    * Invokes the method ConfigureDS.configMain with the provided parameters.
    * @param args the arguments to be passed to ConfigureDS.configMain.
@@ -148,10 +147,7 @@
   public int invokeImportLDIF(final Application application, String[] args) throws IOException, InterruptedException
   {
     final File installPath = new File(application.getInstallationPath());
-    final File binPath = new File(installPath, isWindows() ? Installation.WINDOWS_BINARIES_PATH_RELATIVE
-                                                           : Installation.UNIX_BINARIES_PATH_RELATIVE);
-    final File importLDIFPath = new File(binPath, isWindows() ? Installation.WINDOWS_IMPORT_LDIF
-                                                              : Installation.UNIX_IMPORT_LDIF);
+    final File importLDIFPath = getImportPath(installPath);
 
     final ArrayList<String> argList = new ArrayList<>();
     argList.add(Utils.getScriptPath(importLDIFPath.getAbsolutePath()));
@@ -205,6 +201,21 @@
     }
   }
 
+  private File getImportPath(final File installPath)
+  {
+    if (isWindows())
+    {
+      return buildImportPath(installPath, WINDOWS_BINARIES_PATH_RELATIVE, WINDOWS_IMPORT_LDIF);
+    }
+    return buildImportPath(installPath, UNIX_BINARIES_PATH_RELATIVE, UNIX_IMPORT_LDIF);
+  }
+
+  private File buildImportPath(final File installPath, String binDir, String importLdif)
+  {
+    final File binPath = new File(installPath, binDir);
+    return new File(binPath, importLdif);
+  }
+
   private void closeProcessStream(final Closeable stream, final String streamName)
   {
     try
@@ -287,18 +298,10 @@
           failedMsg, ioe);
     }
 
-    try
-    {
-      LDIFExportConfig exportConfig = new LDIFExportConfig(
-          ldifFile.getAbsolutePath(), ExistingFileBehavior.OVERWRITE);
-
-      LDIFWriter writer = new LDIFWriter(exportConfig);
-
+    LDIFExportConfig exportConfig = new LDIFExportConfig(ldifFile.getAbsolutePath(), OVERWRITE);
+    try (LDIFWriter writer = new LDIFWriter(exportConfig)) {
       DN dn = DN.valueOf(baseDn);
-      Entry entry = StaticUtils.createEntry(dn);
-
-      writer.writeEntry(entry);
-      writer.close();
+      writer.writeEntry(StaticUtils.createEntry(dn));
     } catch (DirectoryException | LDIFException | IOException de) {
       throw new ApplicationException(
           ReturnCode.CONFIGURATION_ERROR,
@@ -611,7 +614,7 @@
         {
           int domainId = getReplicationId(usedServerIds);
           usedServerIds.add(domainId);
-          domainName = getDomainName(domainNames, domainId, dn);
+          domainName = getDomainName(domainNames, dn);
           domain = sync.createReplicationDomain(
               ReplicationDomainCfgDefn.getInstance(), domainName,
               new ArrayList<PropertyException>());
@@ -857,12 +860,10 @@
   /**
    * Returns the name to be used for a new replication domain.
    * @param existingDomains the existing domains names.
-   * @param newDomainId the new domain replication id.
    * @param baseDN the base DN of the domain.
    * @return the name to be used for a new replication domain.
    */
-  public static String getDomainName(String[] existingDomains, int newDomainId,
-      String baseDN)
+  public static String getDomainName(String[] existingDomains, String baseDN)
   {
     String domainName = baseDN;
     boolean nameExists = true;
@@ -961,7 +962,7 @@
       otherProperties.put("default.java-home", javaHome);
     }
 
-    writeSetOpenDSJavaHome(installPath, javaHome, args, otherProperties);
+    writeSetOpenDSJavaHome(installPath, args, otherProperties);
   }
 
   private void putBooleanPropertyFrom(
@@ -1068,28 +1069,22 @@
 
   private Properties getJavaPropertiesFileContents(String propertiesFile) throws IOException
   {
-    FileInputStream fs = null;
     Properties fileProperties = new Properties();
-    try
+    try (FileInputStream fs = new FileInputStream(propertiesFile))
     {
-      fs = new FileInputStream(propertiesFile);
       fileProperties.load(fs);
     }
     catch (Throwable t)
     { /* do nothing */
     }
-    finally
-    {
-      StaticUtils.close(fs);
-    }
     return fileProperties;
   }
 
   private String getPropertiesFileName(String installPath)
   {
     String configDir = Utils.getPath(
-        Utils.getInstancePathFromInstallPath(installPath), Installation.CONFIG_PATH_RELATIVE);
-    return Utils.getPath(configDir, Installation.DEFAULT_JAVA_PROPERTIES_FILE);
+        Utils.getInstancePathFromInstallPath(installPath), CONFIG_PATH_RELATIVE);
+    return Utils.getPath(configDir, DEFAULT_JAVA_PROPERTIES_FILE);
   }
 
   /**
@@ -1099,8 +1094,6 @@
    *
    * @param installPath
    *          the install path of the server.
-   * @param javaHome
-   *          the java home to be used.
    * @param arguments
    *          a Map containing as key the name of the script and as value, the
    *          java arguments to be set for the script.
@@ -1109,43 +1102,43 @@
    * @throws IOException
    *           if an error occurred writing the file.
    */
-  private void writeSetOpenDSJavaHome(String installPath, String javaHome, Map<String, JavaArguments> arguments,
+  private void writeSetOpenDSJavaHome(String installPath, Map<String, JavaArguments> arguments,
       Map<String, String> otherProperties) throws IOException
   {
     String propertiesFile = getPropertiesFileName(installPath);
     List<String> commentLines = getJavaPropertiesFileComments(propertiesFile);
-    BufferedWriter writer = new BufferedWriter(new FileWriter(propertiesFile, false));
-
-    for (String line: commentLines)
+    try (BufferedWriter writer = new BufferedWriter(new FileWriter(propertiesFile, false)))
     {
-      writer.write(line);
-      writer.newLine();
-    }
+      for (String line: commentLines)
+      {
+        writer.write(line);
+        writer.newLine();
+      }
 
-    for (String key : otherProperties.keySet())
-    {
-      writer.write(key + "=" + otherProperties.get(key));
-      writer.newLine();
-    }
+      for (String key : otherProperties.keySet())
+      {
+        writer.write(key + "=" + otherProperties.get(key));
+        writer.newLine();
+      }
 
-    for (String scriptName : arguments.keySet())
-    {
-      String argument = arguments.get(scriptName).getStringArguments();
-      writer.newLine();
-      writer.write(getJavaArgPropertyForScript(scriptName) + "=" + argument);
+      for (String scriptName : arguments.keySet())
+      {
+        String argument = arguments.get(scriptName).getStringArguments();
+        writer.newLine();
+        writer.write(getJavaArgPropertyForScript(scriptName) + "=" + argument);
+      }
     }
-    writer.close();
 
     String libDir = Utils.getPath(
-        Utils.getInstancePathFromInstallPath(installPath), Installation.LIBRARIES_PATH_RELATIVE);
+        Utils.getInstancePathFromInstallPath(installPath), LIBRARIES_PATH_RELATIVE);
     // Create directory if it doesn't exist yet
     File fLib = new File(libDir);
     if (!fLib.exists())
     {
       fLib.mkdir();
     }
-    final String destinationFile = Utils.getPath(libDir, isWindows() ? Installation.SET_JAVA_PROPERTIES_FILE_WINDOWS
-                                                                     : Installation.SET_JAVA_PROPERTIES_FILE_UNIX);
+    final String destinationFile = Utils.getPath(libDir, isWindows() ? SET_JAVA_PROPERTIES_FILE_WINDOWS
+                                                                     : SET_JAVA_PROPERTIES_FILE_UNIX);
     // Launch the script
     int returnValue = JavaPropertiesTool.mainCLI(
         "--propertiesFile", propertiesFile, "--destinationFile", destinationFile, "--quiet");
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SetupLauncher.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SetupLauncher.java
index fef5ae4..c5cea98 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SetupLauncher.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/SetupLauncher.java
@@ -22,30 +22,30 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2014-2015 ForgeRock AS
+ *      Portions Copyright 2014-2016 ForgeRock AS
  */
 package org.opends.quicksetup.installer;
 
 import static org.opends.messages.QuickSetupMessages.*;
 import static org.opends.messages.ToolMessages.*;
-import static com.forgerock.opendj.util.OperatingSystem.isWindows;
+import static org.opends.server.util.ServerConstants.*;
 
 import java.io.File;
 
-import org.opends.quicksetup.Constants;
-import org.opends.quicksetup.ReturnCode;
+import org.forgerock.i18n.LocalizableMessage;
 import org.opends.quicksetup.CliApplication;
+import org.opends.quicksetup.Constants;
 import org.opends.quicksetup.Installation;
 import org.opends.quicksetup.Launcher;
 import org.opends.quicksetup.QuickSetupLog;
+import org.opends.quicksetup.ReturnCode;
 import org.opends.quicksetup.installer.offline.OfflineInstaller;
 import org.opends.quicksetup.util.IncompatibleVersionException;
 import org.opends.quicksetup.util.Utils;
-import org.forgerock.i18n.LocalizableMessage;
 import org.opends.server.tools.InstallDS;
 import org.opends.server.tools.InstallDSArgumentParser;
 import org.opends.server.util.DynamicConstants;
-import org.opends.server.util.ServerConstants;
+
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.ArgumentParser;
 
@@ -84,22 +84,14 @@
    */
   public SetupLauncher(String[] args) {
     super(args);
-    String scriptName;
-    if (isWindows()) {
-      scriptName = Installation.WINDOWS_SETUP_FILE_NAME;
-    } else {
-      scriptName = Installation.UNIX_SETUP_FILE_NAME;
-    }
-    if (System.getProperty(ServerConstants.PROPERTY_SCRIPT_NAME) == null)
+    if (System.getProperty(PROPERTY_SCRIPT_NAME) == null)
     {
-      System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
+      System.setProperty(PROPERTY_SCRIPT_NAME, Installation.getSetupFileName());
     }
     initializeParser();
   }
 
-  /**
-   * Initialize the contents of the argument parser.
-   */
+  /** Initialize the contents of the argument parser. */
   protected void initializeParser()
   {
     argParser = new InstallDSArgumentParser(InstallDS.class.getName());
@@ -114,7 +106,7 @@
     }
   }
 
-  /** {@inheritDoc} */
+  @Override
   public void launch() {
     try
     {
@@ -169,12 +161,12 @@
     }
   }
 
-  /** {@inheritDoc} */
+  @Override
   public ArgumentParser getArgumentParser() {
     return this.argParser;
   }
 
-  /** {@inheritDoc} */
+  @Override
   protected void guiLaunchFailed(String logFileName) {
     if (logFileName != null)
     {
@@ -187,26 +179,26 @@
     }
   }
 
-  /** {@inheritDoc} */
+  @Override
   protected void willLaunchGui() {
     System.out.println(INFO_SETUP_LAUNCHER_LAUNCHING_GUI.get());
     System.setProperty("org.opends.quicksetup.Application.class",
             OfflineInstaller.class.getName());
   }
 
-  /** {@inheritDoc} */
+  @Override
   protected LocalizableMessage getFrameTitle() {
     return Utils.getCustomizedObject("INFO_FRAME_INSTALL_TITLE",
         INFO_FRAME_INSTALL_TITLE.get(DynamicConstants.PRODUCT_NAME),
         LocalizableMessage.class);
   }
 
-  /** {@inheritDoc} */
+  @Override
   protected CliApplication createCliApplication() {
     return null;
   }
 
-  /** {@inheritDoc} */
+  @Override
   protected boolean isCli() {
     return argParser.isCli();
   }
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/FileManager.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/FileManager.java
index bb88f94..6ac35b9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/FileManager.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/FileManager.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2015 ForgeRock AS.
+ *      Portions Copyright 2012-2016 ForgeRock AS.
  */
 package org.opends.quicksetup.util;
 
@@ -31,7 +31,6 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.opends.quicksetup.*;
-import org.opends.server.util.StaticUtils;
 
 import static org.opends.messages.QuickSetupMessages.*;
 import static com.forgerock.opendj.util.OperatingSystem.isUnix;
@@ -42,38 +41,24 @@
  * interesting events.
  */
 public class FileManager {
-
-  /**
-   * Describes the approach taken to deleting a file or directory.
-   */
+  /** Describes the approach taken to deleting a file or directory. */
   public enum DeletionPolicy {
-
-    /**
-     * Delete the file or directory immediately.
-     */
+    /** Delete the file or directory immediately. */
     DELETE_IMMEDIATELY,
-
-    /**
-     * Mark the file or directory for deletion after the JVM has exited.
-     */
+    /** Mark the file or directory for deletion after the JVM has exited. */
     DELETE_ON_EXIT,
-
     /**
      * First try to delete the file immediately.  If the deletion was
-     * unsuccessful mark the file for deleteion when the JVM has
-     * existed.
+     * unsuccessful mark the file for deletion when the JVM has existed.
      */
     DELETE_ON_EXIT_IF_UNSUCCESSFUL
-
   }
 
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
   private Application application;
 
-  /**
-   * Creates a new file manager.
-   */
+  /** Creates a new file manager. */
   public FileManager() {
     // do nothing;
   }
@@ -115,12 +100,10 @@
   /**
    * Renames the source file to the target file.  If the target file exists
    * it is first deleted.  The rename and delete operation return values
-   * are checked for success and if unsuccessful, this method throws an
-   * exception.
+   * are checked for success and if unsuccessful, this method throws an exception.
    *
    * @param fileToRename The file to rename.
-   * @param target       The file to which <code>fileToRename</code> will be
-   *                     moved.
+   * @param target       The file to which <code>fileToRename</code> will be moved.
    * @throws ApplicationException If a problem occurs while attempting to rename
    *                     the file.  On the Windows platform, this typically
    *                     indicates that the file is in use by this or another
@@ -146,15 +129,13 @@
     }
   }
 
-
   /**
    * Move a file.
    * @param object File to move
    * @param newParent File representing new parent directory
    * @throws ApplicationException if something goes wrong
    */
-  public void move(File object, File newParent)
-          throws ApplicationException
+  public void move(File object, File newParent) throws ApplicationException
   {
     move(object, newParent, null);
   }
@@ -163,8 +144,7 @@
    * Move a file.
    * @param object File to move
    * @param newParent File representing new parent directory
-   * @param filter that will be asked whether or not the operation should be
-   *        performed
+   * @param filter that will be asked whether or not the operation should be performed
    * @throws ApplicationException if something goes wrong
    */
   public void move(File object, File newParent, FileFilter filter)
@@ -190,8 +170,7 @@
   /**
    * Deletes a single file or directory.
    * @param object File to delete
-   * @param filter that will be asked whether or not the operation should be
-   *        performed
+   * @param filter that will be asked whether or not the operation should be performed
    * @throws ApplicationException if something goes wrong
    */
   public void delete(File object, FileFilter filter)
@@ -319,8 +298,7 @@
   public void copyRecursively(File objectFile, File destDir,
                               FileFilter filter, boolean overwrite)
           throws ApplicationException {
-    operateRecursively(new CopyOperation(objectFile, destDir, overwrite),
-            filter);
+    operateRecursively(new CopyOperation(objectFile, destDir, overwrite), filter);
   }
 
  /**
@@ -329,13 +307,13 @@
   * @param f1 file to compare
   * @param f2 file to compare
   * @return boolean where true indicates that two files differ
-  * @throws IOException if there is a problem reading the files' conents
+  * @throws IOException if there is a problem reading the files' contents
   */
  public boolean filesDiffer(File f1, File f2) throws IOException {
    boolean differ = false;
-   FileReader fr1 = new FileReader(f1);
-   FileReader fr2 = new FileReader(f2);
-   try {
+    try (FileReader fr1 = new FileReader(f1);
+        FileReader fr2 = new FileReader(f2))
+    {
      boolean done = false;
      while (!differ && !done) {
        int c1 = fr1.read();
@@ -343,9 +321,6 @@
        differ = c1 != c2;
        done = c1 == -1 || c2 == -1;
      }
-   } finally {
-     fr1.close();
-     fr2.close();
    }
    return differ;
  }
@@ -388,11 +363,8 @@
     }
   }
 
-  /**
-   * A file operation.
-   */
+  /** A file operation. */
   private abstract class FileOperation {
-
     private File objectFile;
 
     /**
@@ -423,14 +395,10 @@
      * @throws ApplicationException if there is a problem.
      */
     public abstract void apply() throws ApplicationException;
-
   }
 
-  /**
-   * A copy operation.
-   */
+  /** A copy operation. */
   private class CopyOperation extends FileOperation {
-
     private File destination;
 
     private boolean overwrite;
@@ -447,7 +415,6 @@
       this.overwrite = overwrite;
     }
 
-    /** {@inheritDoc} */
     @Override
     public FileOperation copyForChild(File child) {
       return new CopyOperation(child, destination, overwrite);
@@ -462,7 +429,6 @@
       return this.destination;
     }
 
-    /** {@inheritDoc} */
     @Override
     public void apply() throws ApplicationException {
       File objectFile = getObjectFile();
@@ -471,14 +437,13 @@
           destination.mkdirs();
         }
       } else {
-
         // If overwriting and the destination exists then kill it
         if (destination.exists() && overwrite) {
           deleteRecursively(destination);
         }
 
         if (!destination.exists()) {
-          if (Utils.insureParentsExist(destination)) {
+          if (Utils.ensureParentsExist(destination)) {
             if (application != null && application.isVerbose()) {
               application.notifyListeners(application.getFormattedWithPoints(
                       INFO_PROGRESS_COPYING_FILE.get(
@@ -488,11 +453,9 @@
             logger.info(LocalizableMessage.raw("copying file '" +
                     objectFile.getAbsolutePath() + "' to '" +
                     destination.getAbsolutePath() + "'"));
-            FileInputStream fis = null;
-            FileOutputStream fos = null;
-            try {
-              fis = new FileInputStream(objectFile);
-              fos = new FileOutputStream(destination);
+            try (FileInputStream fis = new FileInputStream(objectFile);
+                FileOutputStream fos = new FileOutputStream(destination))
+            {
               byte[] buf = new byte[1024];
               int i;
               while ((i = fis.read(buf)) != -1) {
@@ -509,7 +472,6 @@
                 application.notifyListeners(
                         application.getFormattedDoneWithLineBreak());
               }
-
             } catch (Exception e) {
               LocalizableMessage errMsg = INFO_ERROR_COPYING_FILE.get(
                       objectFile.getAbsolutePath(),
@@ -517,8 +479,6 @@
               throw new ApplicationException(
                       ReturnCode.FILE_SYSTEM_ACCESS_ERROR,
                       errMsg, null);
-            } finally {
-              StaticUtils.close(fis, fos);
             }
           } else {
             LocalizableMessage errMsg = INFO_ERROR_COPYING_FILE.get(
@@ -542,14 +502,10 @@
         }
       }
     }
-
   }
 
-  /**
-   * A delete operation.
-   */
+  /** A delete operation. */
   private class DeleteOperation extends FileOperation {
-
     private DeletionPolicy deletionPolicy;
 
     /**
@@ -564,13 +520,11 @@
       this.deletionPolicy = deletionPolicy;
     }
 
-    /** {@inheritDoc} */
     @Override
     public FileOperation copyForChild(File child) {
       return new DeleteOperation(child, deletionPolicy);
     }
 
-    /** {@inheritDoc} */
     @Override
     public void apply() throws ApplicationException {
       File file = getObjectFile();
@@ -638,30 +592,25 @@
     }
   }
 
-  /**
-   * A delete operation.
-   */
+  /** A delete operation. */
   private class MoveOperation extends FileOperation {
-
     File destination;
 
     /**
      * Creates a delete operation.
      * @param objectFile to delete
-     * @param newParent Filr where <code>objectFile</code> will be copied.
+     * @param newParent File where <code>objectFile</code> will be copied.
      */
     public MoveOperation(File objectFile, File newParent) {
       super(objectFile);
       this.destination = new File(newParent, objectFile.getName());
     }
 
-    /** {@inheritDoc} */
     @Override
     public FileOperation copyForChild(File child) {
       return new MoveOperation(child, destination);
     }
 
-    /** {@inheritDoc} */
     @Override
     public void apply() throws ApplicationException {
       File objectFile = getObjectFile();
@@ -676,5 +625,4 @@
       }
     }
   }
-
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
index 10816c9..1f2bb49 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/Utils.java
@@ -22,19 +22,19 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS
+ *      Portions Copyright 2011-2016 ForgeRock AS
  */
 package org.opends.quicksetup.util;
 
+import static com.forgerock.opendj.cli.Utils.*;
+import static com.forgerock.opendj.util.OperatingSystem.*;
+
 import static org.forgerock.util.Utils.*;
 import static org.opends.admin.ads.util.ConnectionUtils.*;
 import static org.opends.messages.QuickSetupMessages.*;
 import static org.opends.quicksetup.Installation.*;
 import static org.opends.server.util.DynamicConstants.*;
 
-import static com.forgerock.opendj.cli.Utils.*;
-import static com.forgerock.opendj.util.OperatingSystem.*;
-
 import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
@@ -102,9 +102,7 @@
 import com.forgerock.opendj.cli.ArgumentConstants;
 import com.forgerock.opendj.cli.ClientException;
 
-/**
- * This class provides some static convenience methods of different nature.
- */
+/** This class provides some static convenience methods of different nature. */
 public class Utils
 {
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
@@ -169,17 +167,8 @@
     try
     {
       List<String> args = new ArrayList<>();
-      String script;
-      String libPath = Utils.getPath(installPath, Installation.LIBRARIES_PATH_RELATIVE);
-      if (isWindows())
-      {
-        script = Utils.getScriptPath(Utils.getPath(libPath, Installation.SCRIPT_UTIL_FILE_WINDOWS));
-      }
-      else
-      {
-        script = Utils.getScriptPath(Utils.getPath(libPath, Installation.SCRIPT_UTIL_FILE_UNIX));
-      }
-      args.add(script);
+      args.add(getScript(installPath));
+
       ProcessBuilder pb = new ProcessBuilder(args);
       Map<String, String> env = pb.environment();
       env.put(SetupUtils.OPENDJ_JAVA_HOME, javaHome);
@@ -244,9 +233,15 @@
     return supported;
   }
 
+  private static String getScript(String installPath)
+  {
+    String libPath = Utils.getPath(installPath, Installation.LIBRARIES_PATH_RELATIVE);
+    String scriptUtilFileUnix = isWindows() ? SCRIPT_UTIL_FILE_WINDOWS : SCRIPT_UTIL_FILE_UNIX;
+    return Utils.getScriptPath(Utils.getPath(libPath, scriptUtilFileUnix));
+  }
+
   /**
-   * Creates a new file attempting to create the parent directories if
-   * necessary.
+   * Creates a new file attempting to create the parent directories if necessary.
    *
    * @param f
    *          File to create
@@ -256,7 +251,6 @@
    */
   public static boolean createFile(File f) throws IOException
   {
-    boolean success = false;
     if (f != null)
     {
       File parent = f.getParentFile();
@@ -264,9 +258,9 @@
       {
         parent.mkdirs();
       }
-      success = f.createNewFile();
+      return f.createNewFile();
     }
-    return success;
+    return false;
   }
 
   /**
@@ -307,7 +301,6 @@
    */
   public static String getPath(File f)
   {
-    String path = null;
     if (f != null)
     {
       try
@@ -325,9 +318,9 @@
          * file: reporting the error is not necessary.
          */
       }
-      path = f.toString();
+      return f.toString();
     }
-    return path;
+    return null;
   }
 
   /**
@@ -371,14 +364,9 @@
    */
   public static boolean parentDirectoryExists(String path)
   {
-    boolean parentExists = false;
     File f = new File(path);
     File parentFile = f.getParentFile();
-    if (parentFile != null)
-    {
-      parentExists = parentFile.isDirectory();
-    }
-    return parentExists;
+    return parentFile != null && parentFile.isDirectory();
   }
 
   /**
@@ -392,8 +380,7 @@
    */
   public static boolean fileExists(String path)
   {
-    File f = new File(path);
-    return f.isFile();
+    return new File(path).isFile();
   }
 
   /**
@@ -449,19 +436,16 @@
    */
   public static boolean areDnsEqual(String dn1, String dn2)
   {
-    boolean areDnsEqual = false;
     try
     {
       LdapName name1 = new LdapName(dn1);
       LdapName name2 = new LdapName(dn2);
-      areDnsEqual = name1.equals(name2);
+      return name1.equals(name2);
     }
     catch (Exception ex)
     {
-      // do nothing
+      return false;
     }
-
-    return areDnsEqual;
   }
 
   /**
@@ -472,15 +456,10 @@
    * @return boolean indicating whether or not the input <code>f</code> has a
    *         parent after this method is invoked.
    */
-  public static boolean insureParentsExist(File f)
+  public static boolean ensureParentsExist(File f)
   {
     final File parent = f.getParentFile();
-    final boolean b = parent.exists();
-    if (!b)
-    {
-      return parent.mkdirs();
-    }
-    return b;
+    return parent.exists() || parent.mkdirs();
   }
 
   /**
@@ -510,16 +489,11 @@
    */
   public static boolean createDirectory(File f) throws IOException
   {
-    boolean directoryCreated;
-    if (!f.exists())
+    if (f.exists())
     {
-      directoryCreated = f.mkdirs();
+      return f.isDirectory();
     }
-    else
-    {
-      directoryCreated = f.isDirectory();
-    }
-    return directoryCreated;
+    return f.mkdirs();
   }
 
   /**
@@ -737,7 +711,7 @@
    * @throws InterruptedException
    *           if the Runtime.exec method is interrupted.
    */
-  public static int setPermissionsUnix(ArrayList<String> paths, String permissions) throws IOException,
+  public static int setPermissionsUnix(List<String> paths, String permissions) throws IOException,
       InterruptedException
   {
     String[] args = new String[paths.size() + 2];
@@ -768,10 +742,7 @@
    */
   public static int setPermissionsUnix(String path, String permissions) throws IOException, InterruptedException
   {
-    String[] args = new String[3];
-    args[0] = "chmod";
-    args[1] = permissions;
-    args[2] = path;
+    String[] args = new String[] { "chmod", permissions, path };
     Process p = Runtime.getRuntime().exec(args);
     return p.waitFor();
   }
@@ -1096,7 +1067,6 @@
       }
       if (len > maxll)
       {
-
         // First see if there are any tags that would cause a
         // natural break in the line.  If so start line break
         // point evaluation from that point.
@@ -1162,7 +1132,6 @@
   {
     if (s != null)
     {
-
       // This is not a comprehensive solution but addresses the few tags
       // that we have in Resources.properties at the moment.
       // Note that the following might strip out more than is intended for non-tags
@@ -1316,34 +1285,28 @@
     StringBuilder buffer = new StringBuilder();
     for (int i = 0; i < rawString.length(); i++)
     {
-      char c = rawString.charAt(i);
-      switch (c)
-      {
-      case '<':
-        buffer.append("&lt;");
-        break;
-
-      case '>':
-        buffer.append("&gt;");
-        break;
-
-      case '&':
-        buffer.append("&amp;");
-        break;
-
-      case '"':
-        buffer.append("&quot;");
-        break;
-
-      default:
-        buffer.append(c);
-        break;
-      }
+      escapeChar(buffer, rawString.charAt(i));
     }
-
     return buffer.toString();
   }
 
+  private static StringBuilder escapeChar(StringBuilder buffer, char c)
+  {
+    switch (c)
+    {
+    case '<':
+      return buffer.append("&lt;");
+    case '>':
+      return buffer.append("&gt;");
+    case '&':
+      return buffer.append("&amp;");
+    case '"':
+      return buffer.append("&quot;");
+    default:
+      return buffer.append(c);
+    }
+  }
+
   /**
    * Returns the HTML representation for a given text. without adding any kind
    * of font or style elements.  Just escapes the problematic characters
@@ -1355,19 +1318,22 @@
    */
   public static String getHtml(String text)
   {
-    StringBuilder buffer = new StringBuilder();
-    if (text != null)
+    if (text == null)
     {
-      text = text.replaceAll("\r\n", "\n");
-      String[] lines = text.split("[\n\r\u0085\u2028\u2029]");
-      for (int i = 0; i < lines.length; i++)
+      return "";
+    }
+
+    text = text.replaceAll("\r\n", "\n");
+
+    StringBuilder buffer = new StringBuilder();
+    String[] lines = text.split("[\n\r\u0085\u2028\u2029]");
+    for (int i = 0; i < lines.length; i++)
+    {
+      if (i != 0)
       {
-        if (i != 0)
-        {
-          buffer.append(Constants.HTML_LINE_BREAK);
-        }
-        buffer.append(escapeHtml(lines[i]));
+        buffer.append(Constants.HTML_LINE_BREAK);
       }
+      buffer.append(escapeHtml(lines[i]));
     }
     return buffer.toString();
   }
@@ -1385,7 +1351,7 @@
    * @param defaultValue
    *          the default value.
    * @param valueClass
-   *          the class of the parametrized value.
+   *          the class of the parameterized value.
    * @return the customized object.
    */
   public static <T> T getCustomizedObject(String fieldName, T defaultValue, Class<T> valueClass)
@@ -1467,30 +1433,8 @@
 
     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());
-        break;
-
-      case LEAVE_DATABASE_EMPTY:
-        arg2 = INFO_REVIEW_LEAVE_DATABASE_EMPTY_LABEL.get();
-        break;
-
-      case IMPORT_FROM_LDIF_FILE:
-        arg2 = INFO_REVIEW_IMPORT_LDIF.get(options.getLDIFPaths().getFirst());
-        break;
-
-      case IMPORT_AUTOMATICALLY_GENERATED_DATA:
-        arg2 = INFO_REVIEW_IMPORT_AUTOMATICALLY_GENERATED.get(options.getNumberEntries());
-        break;
-
-      default:
-        throw new IllegalArgumentException("Unknown type: " + options.getType());
-      }
+      LocalizableMessage arg2 = toArg2(options);
 
       if (options.getBaseDns().isEmpty())
       {
@@ -1527,6 +1471,23 @@
     return msg.toString();
   }
 
+  private static LocalizableMessage toArg2(NewSuffixOptions options)
+  {
+    switch (options.getType())
+    {
+    case CREATE_BASE_ENTRY:
+      return INFO_REVIEW_CREATE_BASE_ENTRY_LABEL.get(options.getBaseDns().getFirst());
+    case LEAVE_DATABASE_EMPTY:
+      return INFO_REVIEW_LEAVE_DATABASE_EMPTY_LABEL.get();
+    case IMPORT_FROM_LDIF_FILE:
+      return INFO_REVIEW_IMPORT_LDIF.get(options.getLDIFPaths().getFirst());
+    case IMPORT_AUTOMATICALLY_GENERATED_DATA:
+      return INFO_REVIEW_IMPORT_AUTOMATICALLY_GENERATED.get(options.getNumberEntries());
+    default:
+      throw new IllegalArgumentException("Unknown type: " + options.getType());
+    }
+  }
+
   /**
    * Returns a localized String representation of the provided SecurityOptions
    * object.
@@ -1576,33 +1537,7 @@
       {
         buf.append("\n");
       }
-      LocalizableMessage certMsg;
-      switch (ops.getCertificateType())
-      {
-      case SELF_SIGNED_CERTIFICATE:
-        certMsg = INFO_SELF_SIGNED_CERTIFICATE.get();
-        break;
-
-      case JKS:
-        certMsg = INFO_JKS_CERTIFICATE.get();
-        break;
-
-      case JCEKS:
-        certMsg = INFO_JCEKS_CERTIFICATE.get();
-        break;
-
-      case PKCS11:
-        certMsg = INFO_PKCS11_CERTIFICATE.get();
-        break;
-
-      case PKCS12:
-        certMsg = INFO_PKCS12_CERTIFICATE.get();
-        break;
-
-      default:
-        throw new IllegalStateException("Unknown certificate options type: " + ops.getCertificateType());
-      }
-      buf.append(certMsg);
+      buf.append(toCertMsg(ops));
     }
 
     if (html)
@@ -1615,6 +1550,25 @@
     }
   }
 
+  private static LocalizableMessage toCertMsg(SecurityOptions ops)
+  {
+    switch (ops.getCertificateType())
+    {
+    case SELF_SIGNED_CERTIFICATE:
+      return INFO_SELF_SIGNED_CERTIFICATE.get();
+    case JKS:
+      return INFO_JKS_CERTIFICATE.get();
+    case JCEKS:
+      return INFO_JCEKS_CERTIFICATE.get();
+    case PKCS11:
+      return INFO_PKCS11_CERTIFICATE.get();
+    case PKCS12:
+      return INFO_PKCS12_CERTIFICATE.get();
+    default:
+      throw new IllegalStateException("Unknown certificate options type: " + ops.getCertificateType());
+    }
+  }
+
   /**
    * Returns a String representation of the provided command-line.
    *
@@ -1706,7 +1660,7 @@
   public static List<String> getSetupEquivalentCommandLine(final UserData userData)
   {
     List<String> cmdLine = new ArrayList<>();
-    cmdLine.add(getInstallDir(userData) + getSetupFilename());
+    cmdLine.add(getInstallDir(userData) + getSetupFileName());
     cmdLine.add("--cli");
 
     final ManagedObjectDefinition<? extends BackendCfgClient, ? extends BackendCfg> backendType =
@@ -1807,11 +1761,6 @@
     return cmdLine;
   }
 
-  private static String getSetupFilename()
-  {
-    return isWindows() ? Installation.WINDOWS_SETUP_FILE_NAME : Installation.UNIX_SETUP_FILE_NAME;
-  }
-
   private static List<String> getSecurityOptionSetupEquivalentCmdLine(final UserData userData)
   {
     final List<String> cmdLine = new ArrayList<>();
@@ -1955,19 +1904,15 @@
    */
   private static String getCommandLinePath(UserData userData, String scriptBasicName)
   {
-    String cmdLineName;
+    String installDir = getInstallDir(userData);
     if (isWindows())
     {
-      cmdLineName =
-          getInstallDir(userData) + Installation.WINDOWS_BINARIES_PATH_RELATIVE + File.separatorChar + scriptBasicName
-              + ".bat";
+      return installDir + WINDOWS_BINARIES_PATH_RELATIVE + File.separatorChar + scriptBasicName + ".bat";
     }
     else
     {
-      cmdLineName =
-          getInstallDir(userData) + Installation.UNIX_BINARIES_PATH_RELATIVE + File.separatorChar + scriptBasicName;
+      return installDir + UNIX_BINARIES_PATH_RELATIVE + File.separatorChar + scriptBasicName;
     }
-    return cmdLineName;
   }
 
   private static String installDir;
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ZipExtractor.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ZipExtractor.java
index f6347fd..9e6de98 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ZipExtractor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ZipExtractor.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2007-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS
+ *      Portions Copyright 2011-2016 ForgeRock AS
  */
 package org.opends.quicksetup.util;
 
@@ -39,6 +39,7 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
@@ -179,7 +180,7 @@
      * these files.  This is done this way to group the number of calls to
      * Runtime.exec (which is required to update the file system permissions).
      */
-    Map<String, ArrayList<String>> permissions = new HashMap<>();
+    Map<String, List<String>> permissions = new HashMap<>();
     permissions.put(getProtectedDirectoryPermissionUnix(), newArrayList(destDir));
     try {
       if(application != null) {
@@ -226,7 +227,7 @@
       if (isUnix()) {
         // Change the permissions for UNIX systems
         for (String perm : permissions.keySet()) {
-          ArrayList<String> paths = permissions.get(perm);
+          List<String> paths = permissions.get(perm);
           try {
             int result = Utils.setPermissionsUnix(paths, perm);
             if (result != 0) {
@@ -259,7 +260,7 @@
     */
   private void copyZipEntry(ZipEntry entry, File destination,
       ZipInputStream is, int ratioBeforeCompleted,
-      int ratioWhenCompleted, Map<String, ArrayList<String>> permissions)
+      int ratioWhenCompleted, Map<String, List<String>> permissions)
       throws IOException
   {
     if (application != null) {
@@ -276,38 +277,25 @@
       }
     }
     logger.info(LocalizableMessage.raw("extracting " + Utils.getPath(destination)));
-    if (Utils.insureParentsExist(destination))
-    {
-      if (entry.isDirectory())
-      {
-        String perm = getDirectoryFileSystemPermissions(destination);
-        ArrayList<String> list = permissions.get(perm);
-        if (list == null)
-        {
-          list = new ArrayList<>();
-        }
-        list.add(Utils.getPath(destination));
-        permissions.put(perm, list);
 
-        if (!Utils.createDirectory(destination))
-        {
-          throw new IOException("Could not create path: " + destination);
-        }
-      } else
+    if (!Utils.ensureParentsExist(destination))
+    {
+      throw new IOException("Could not create parent path: " + destination);
+    }
+
+    if (entry.isDirectory())
+    {
+      String perm = getDirectoryFileSystemPermissions(destination);
+      addPermission(destination, permissions, perm);
+      if (!Utils.createDirectory(destination))
       {
-        String perm = Utils.getFileSystemPermissions(destination);
-        ArrayList<String> list = permissions.get(perm);
-        if (list == null)
-        {
-          list = new ArrayList<>();
-        }
-        list.add(Utils.getPath(destination));
-        permissions.put(perm, list);
-        Utils.createFile(destination, is);
+        throw new IOException("Could not create path: " + destination);
       }
     } else
     {
-      throw new IOException("Could not create parent path: " + destination);
+      String perm = Utils.getFileSystemPermissions(destination);
+      addPermission(destination, permissions, perm);
+      Utils.createFile(destination, is);
     }
     if (application != null && application.isVerbose())
     {
@@ -315,6 +303,17 @@
     }
   }
 
+  private void addPermission(File destination, Map<String, List<String>> permissions, String perm)
+  {
+    List<String> list = permissions.get(perm);
+    if (list == null)
+    {
+      list = new ArrayList<>();
+      permissions.put(perm, list);
+    }
+    list.add(Utils.getPath(destination));
+  }
+
   /**
    * Returns the UNIX permissions to be applied to a protected directory.
    * @return the UNIX permissions to be applied to a protected directory.
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
index 093fe51..433352b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2008-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS.
+ *      Portions Copyright 2011-2016 ForgeRock AS.
  */
 package org.opends.server.tools;
 
@@ -137,15 +137,7 @@
     cliArg = CommonArguments.getCLI();
     addArgument(cliArg);
 
-    String defaultProgName;
-    if (isWindows())
-    {
-      defaultProgName = Installation.WINDOWS_SETUP_FILE_NAME;
-    }
-    else
-    {
-      defaultProgName = Installation.UNIX_SETUP_FILE_NAME;
-    }
+    String defaultProgName = Installation.getSetupFileName();
     progNameArg = new StringArgument(
         "programName".toLowerCase(), 'P', "programName", false,
         false, true, INFO_PROGRAM_NAME_PLACEHOLDER.get(), defaultProgName,
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 8c310e4..c1fe092 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2007-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2015 ForgeRock AS
+ *      Portions Copyright 2011-2016 ForgeRock AS
  *      Portions Copyright 2012 profiq s.r.o.
  */
 package org.opends.server.tools.dsreplication;
@@ -6963,8 +6963,7 @@
     {
       int domainId = InstallerHelper.getReplicationId(usedReplicationDomainIds);
       usedReplicationDomainIds.add(domainId);
-      String domainName =
-          InstallerHelper.getDomainName(domainNames, domainId, baseDN);
+      String domainName = InstallerHelper.getDomainName(domainNames, baseDN);
       domain = sync.createReplicationDomain(
           ReplicationDomainCfgDefn.getInstance(), domainName,
           new ArrayList<PropertyException>());
@@ -6983,8 +6982,7 @@
       }
       else if (!areReplicationServersEqual(servers, replicationServers))
       {
-        domain.setReplicationServer(mergeReplicationServers(replicationServers,
-            servers));
+        domain.setReplicationServer(mergeReplicationServers(replicationServers, servers));
         mustCommit = true;
       }
     }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/cli/PointAdder.java b/opendj-server-legacy/src/main/java/org/opends/server/util/cli/PointAdder.java
index f1662c4..f1d4d0b 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/cli/PointAdder.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/cli/PointAdder.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions Copyright 2014 ForgeRock AS
+ *      Portions Copyright 2014-2016 ForgeRock AS
  */
 package org.opends.server.util.cli;
 
@@ -32,9 +32,7 @@
 
 import com.forgerock.opendj.cli.ConsoleApplication;
 
-/**
- * Class used to add points periodically to the end of the output.
- */
+/** Class used to add points periodically to the end of the output. */
 public class PointAdder implements Runnable
 {
   private final ConsoleApplication app;
@@ -42,13 +40,9 @@
   private boolean stopPointAdder;
   private boolean pointAdderStopped;
   private long periodTime = DEFAULT_PERIOD_TIME;
-  private final boolean isError;
   private final ProgressMessageFormatter formatter;
 
-
-  /**
-   * The default period time used to write points in the output.
-   */
+  /** The default period time used to write points in the output. */
   public static final long DEFAULT_PERIOD_TIME = 3000;
 
   /**
@@ -60,8 +54,7 @@
    */
   public PointAdder(ConsoleApplication app)
   {
-    this(app, DEFAULT_PERIOD_TIME, false,
-        new PlainTextProgressMessageFormatter());
+    this(app, DEFAULT_PERIOD_TIME, new PlainTextProgressMessageFormatter());
   }
 
   /**
@@ -71,26 +64,17 @@
    *          The console application to be used.
    * @param periodTime
    *          The time between printing two points.
-   * @param isError
-   *          Whether the points must be printed in error stream or output
-   *          stream.
    * @param formatter
    *          The text formatter.
    */
-  public PointAdder(ConsoleApplication app,
-      long periodTime, boolean isError,
-      ProgressMessageFormatter formatter)
+  public PointAdder(ConsoleApplication app, long periodTime, ProgressMessageFormatter formatter)
   {
     this.app = app;
     this.periodTime = periodTime;
-    this.isError = isError;
     this.formatter = formatter;
   }
 
-  /**
-   * Starts the PointAdder: points are added at the end of the logs
-   * periodically.
-   */
+  /** Starts the PointAdder: points are added at the end of the logs periodically. */
   public void start()
   {
     LocalizableMessageBuilder mb = new LocalizableMessageBuilder();
@@ -104,10 +88,7 @@
     t.start();
   }
 
-  /**
-   * Stops the PointAdder: points are no longer added at the end of the logs
-   * periodically.
-   */
+  /** Stops the PointAdder: points are no longer added at the end of the logs periodically. */
   public synchronized void stop()
   {
     stopPointAdder = true;
@@ -125,7 +106,7 @@
     }
   }
 
-  /** {@inheritDoc} */
+  @Override
   public void run()
   {
     while (!stopPointAdder)

--
Gitblit v1.10.0