Class SetupUtils

java.lang.Object
org.forgerock.opendj.setup.model.SetupUtils

public final class SetupUtils extends Object
Utility methods used by the Setup class.
  • Method Details

    • getToolName

      public static String getToolName(String toolName)
      Returns the provided tool name according to the running operating system.
      Parameters:
      toolName - The name of the tool to run (without any extension)
      Returns:
      The filename to use to access the tool
    • getToolPath

      public static Path getToolPath(Path archivePath, String toolName)
      Returns the provided tool path according to the running operating system and the provided archive path.
      Parameters:
      archivePath - The OpenDJ exploded archive root path
      toolName - The name of the tool to run (without any extension)
      Returns:
      The absolute path to the tool script
    • validateInstanceLocFileNotPresent

      public static void validateInstanceLocFileNotPresent(Path installPath) throws SetupException
      Ensures that there is no existing instance.loc file.

      Creation of the instance.loc file is the setup tool responsibility, if an instance.loc file exists it means that either the setup has already been ran or that the user wants to use old setup tool behavior (see OPENDJ-3588).

      Parameters:
      installPath - The install path of the server to setup
      Throws:
      SetupException - If an existing instance.loc has been found
    • serverAlreadyInstalled

      public static boolean serverAlreadyInstalled(Path instancePath)
      Returns true if there is already an OpenDJ instance set up in the provided Path.

      A path is considered as OpenDJ instance if either a config or a db directory (or both) is present.

      Parameters:
      instancePath - The instance path to test
      Returns:
      true if there is already an OpenDJ instance set up in the provided Path
    • getNewServerId

      public static String getNewServerId(Path installPath)
      Returns a newly generated random server ID.
      Parameters:
      installPath - the install path
      Returns:
      a newly generated random server ID
    • hostPort

      public static com.forgerock.opendj.util.HostPort hostPort(String host, int port) throws com.forgerock.opendj.cli.ArgumentException
      Validates provided host and port and returns a new HostPort object.
      Parameters:
      host - Hostname, must be a non blank string
      port - Port number, must be in the port range
      Returns:
      A new HostPort object
      Throws:
      com.forgerock.opendj.cli.ArgumentException - If either provided hostname or port is invalid
    • writeVersionsInConfigFile

      public static void writeVersionsInConfigFile(Path configFile) throws IOException
      Writes server binary and upgrade version in the provided LDIF config file.
      Parameters:
      configFile - Path to the configuration file to be written
      Throws:
      IOException - If an I/O exception occurs during the operation
    • writeVersionsInConfigFile

      public static void writeVersionsInConfigFile(Path configFile, com.forgerock.opendj.util.Version version, int upgradeVersionNumber) throws IOException
      Writes server binary and upgrade version in the provided LDIF config file.
      Parameters:
      configFile - Path to the configuration file to be written
      version - the version to write in the file
      upgradeVersionNumber - the upgrade version number to write in the file
      Throws:
      IOException - If an I/O exception occurs during the operation
    • patchLdifFile

      public static void patchLdifFile(Path ldifFile, String... ldifPatchLines) throws IOException
      Patches the LDIF file with the provided change record reader.
      Parameters:
      ldifFile - Path to the LDIF file to be patched.
      ldifPatchLines - Change record reader to apply on the LDIF file.
      Throws:
      IOException - If an I/O exception occurs during the operation.