Package org.forgerock.opendj.setup.model
Class SetupUtils
java.lang.Object
org.forgerock.opendj.setup.model.SetupUtils
Utility methods used by the
Setup class.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetNewServerId(Path installPath) Returns a newly generated random server ID.static StringgetToolName(String toolName) Returns the provided tool name according to the running operating system.static PathgetToolPath(Path archivePath, String toolName) Returns the provided tool path according to the running operating system and the provided archive path.static com.forgerock.opendj.util.HostPortValidates provided host and port and returns a newHostPortobject.static voidpatchLdifFile(Path ldifFile, String... ldifPatchLines) Patches the LDIF file with the provided change record reader.static booleanserverAlreadyInstalled(Path instancePath) Returnstrueif there is already an OpenDJ instance set up in the providedPath.static voidvalidateInstanceLocFileNotPresent(Path installPath) Ensures that there is no existing instance.loc file.static voidwriteVersionsInConfigFile(Path configFile) Writes server binary and upgrade version in the provided LDIF config file.static voidwriteVersionsInConfigFile(Path configFile, com.forgerock.opendj.util.Version version, int upgradeVersionNumber) Writes server binary and upgrade version in the provided LDIF config file.
-
Method Details
-
getToolName
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
Returns the provided tool path according to the running operating system and the provided archive path.- Parameters:
archivePath- The OpenDJ exploded archive root pathtoolName- The name of the tool to run (without any extension)- Returns:
- The absolute path to the tool script
-
validateInstanceLocFileNotPresent
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
Returnstrueif there is already an OpenDJ instance set up in the providedPath.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:
trueif there is already an OpenDJ instance set up in the providedPath
-
getNewServerId
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 newHostPortobject.- Parameters:
host- Hostname, must be a non blank stringport- Port number, must be in the port range- Returns:
- A new
HostPortobject - Throws:
com.forgerock.opendj.cli.ArgumentException- If either provided hostname or port is invalid
-
writeVersionsInConfigFile
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 writtenversion- the version to write in the fileupgradeVersionNumber- the upgrade version number to write in the file- Throws:
IOException- If an I/O exception occurs during the operation
-
patchLdifFile
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.
-