Class Installation


  • public final class Installation
    extends Object
    This class represents the physical state of an OpenDJ installation. All the operations are dependent upon the root directory that is specified in the constructor.
    • Field Detail

      • OPENDJ_BOOTSTRAP_JAR_RELATIVE_PATH

        public static final String OPENDJ_BOOTSTRAP_JAR_RELATIVE_PATH
        Relative path to bootstrap OpenDJ jar file.
        See Also:
        Constant Field Values
      • OPENDJ_BOOTSTRAP_CLIENT_JAR_RELATIVE_PATH

        public static final String OPENDJ_BOOTSTRAP_CLIENT_JAR_RELATIVE_PATH
        Relative path to bootstrap-client OpenDJ jar file.
        See Also:
        Constant Field Values
      • WINDOWS_BINARIES_PATH_RELATIVE

        public static final String WINDOWS_BINARIES_PATH_RELATIVE
        The relative path where all the Windows binaries (batch files) are.
        See Also:
        Constant Field Values
      • UNIX_BINARIES_PATH_RELATIVE

        public static final String UNIX_BINARIES_PATH_RELATIVE
        The relative path where all the UNIX binaries (scripts) are.
        See Also:
        Constant Field Values
      • LIBRARIES_PATH_RELATIVE

        public static final String LIBRARIES_PATH_RELATIVE
        The relative path where all the libraries (jar files) are.
        See Also:
        Constant Field Values
      • LOGS_PATH_RELATIVE

        public static final String LOGS_PATH_RELATIVE
        The relative path where the log files are.
        See Also:
        Constant Field Values
      • BACKUPS_PATH_RELATIVE

        public static final String BACKUPS_PATH_RELATIVE
        The relative path where the backup files are.
        See Also:
        Constant Field Values
      • CONFIG_PATH_RELATIVE

        public static final String CONFIG_PATH_RELATIVE
        The relative path where the config files are.
        See Also:
        Constant Field Values
      • LOCKS_PATH_RELATIVE

        public static final String LOCKS_PATH_RELATIVE
        Relative path to the locks directory.
        See Also:
        Constant Field Values
      • INSTANCE_LOCATION_PATH_RELATIVE

        public static final String INSTANCE_LOCATION_PATH_RELATIVE
        The relative path to the instance.loc file.
        See Also:
        Constant Field Values
      • INSTANCE_LOCATION_PATH

        public static final String INSTANCE_LOCATION_PATH
        The path to the instance.loc file.
        See Also:
        Constant Field Values
      • UNIX_SETUP_FILE_NAME

        public static final String UNIX_SETUP_FILE_NAME
        The UNIX setup script file name.
        See Also:
        Constant Field Values
      • UNIX_UNINSTALL_FILE_NAME

        public static final String UNIX_UNINSTALL_FILE_NAME
        The UNIX uninstall script file name.
        See Also:
        Constant Field Values
      • WINDOWS_UNINSTALL_FILE_NAME

        public static final String WINDOWS_UNINSTALL_FILE_NAME
        The Windows uninstall batch file name.
        See Also:
        Constant Field Values
      • UNIX_UPGRADE_FILE_NAME

        public static final String UNIX_UPGRADE_FILE_NAME
        The UNIX upgrade script file name.
        See Also:
        Constant Field Values
      • UNIX_START_FILE_NAME

        public static final String UNIX_START_FILE_NAME
        The UNIX start script file name.
        See Also:
        Constant Field Values
      • WINDOWS_START_FILE_NAME

        public static final String WINDOWS_START_FILE_NAME
        The Windows start batch file name.
        See Also:
        Constant Field Values
      • WINDOWS_STOP_FILE_NAME

        public static final String WINDOWS_STOP_FILE_NAME
        The Windows stop batch file name.
        See Also:
        Constant Field Values
      • UNIX_CONTROLPANEL_FILE_NAME

        public static final String UNIX_CONTROLPANEL_FILE_NAME
        The UNIX control panel script file name.
        See Also:
        Constant Field Values
      • WINDOWS_CONTROLPANEL_FILE_NAME

        public static final String WINDOWS_CONTROLPANEL_FILE_NAME
        The Windows control panel batch file name.
        See Also:
        Constant Field Values
      • MAC_JAVA_APP_STUB_NAME

        public static final String MAC_JAVA_APP_STUB_NAME
        The MacOS X Java application stub name.
        See Also:
        Constant Field Values
      • MAC_CONTROLPANEL_FILE_NAME

        public static final String MAC_CONTROLPANEL_FILE_NAME
        The MacOS X control panel application bundle name.
        See Also:
        Constant Field Values
      • UNIX_STATUSCLI_FILE_NAME

        public static final String UNIX_STATUSCLI_FILE_NAME
        The UNIX status command line script file name.
        See Also:
        Constant Field Values
      • WINDOWS_STATUSCLI_FILE_NAME

        public static final String WINDOWS_STATUSCLI_FILE_NAME
        The Windows status command line batch file name.
        See Also:
        Constant Field Values
      • WINDOWS_IMPORT_LDIF

        public static final String WINDOWS_IMPORT_LDIF
        The Windows import LDIF batch file name.
        See Also:
        Constant Field Values
      • HISTORY_LOG_FILE_NAME

        public static final String HISTORY_LOG_FILE_NAME
        Name of the file kept in the history directory containing logs of upgrade and reversions.
        See Also:
        Constant Field Values
      • DEFAULT_JAVA_PROPERTIES_FILE

        public static final String DEFAULT_JAVA_PROPERTIES_FILE
        The default java properties file.
        See Also:
        Constant Field Values
      • RELATIVE_JAVA_PROPERTIES_FILE

        public static final String RELATIVE_JAVA_PROPERTIES_FILE
        The default java properties file relative path.
      • SET_JAVA_PROPERTIES_FILE_WINDOWS

        public static final String SET_JAVA_PROPERTIES_FILE_WINDOWS
        The set java home and arguments properties file for Windows.
        See Also:
        Constant Field Values
      • SCRIPT_UTIL_FILE_UNIX

        public static final String SCRIPT_UTIL_FILE_UNIX
        Script utils file for UNIX systems.
        See Also:
        Constant Field Values
      • SCRIPT_UTIL_FILE_WINDOWS

        public static final String SCRIPT_UTIL_FILE_WINDOWS
        Script utils file for Windows.
        See Also:
        Constant Field Values
      • SET_JAVA_PROPERTIES_FILE_UNIX

        public static final String SET_JAVA_PROPERTIES_FILE_UNIX
        The set java home and arguments properties file for UNIX systems.
        See Also:
        Constant Field Values
      • REQUIRED_DIRECTORIES

        public static final String[] REQUIRED_DIRECTORIES
        Directories required to be present for this installation to be considered valid.
      • DEFAULT_INTERACTIVE_BASE_DN

        public static final String DEFAULT_INTERACTIVE_BASE_DN
        The default base DN prompted to user in setup interactive mode.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Installation

        public Installation​(String rootDirectory,
                            String instanceRootDirectory)
        Creates a new instance from a root directory specified as a string.
        Parameters:
        rootDirectory - of this installation
        instanceRootDirectory - The instance root directory
      • Installation

        public Installation​(File rootDirectory,
                            File instanceDirectory)
        Creates a new instance from a root directory specified as a File.
        Parameters:
        rootDirectory - of this installation
        instanceDirectory - of the instance
    • Method Detail

      • validateRootDirectory

        public static void validateRootDirectory​(File rootDirectory)
                                          throws IllegalArgumentException
        Performs validation on the specified file to make sure that it is an actual OpenDJ installation.
        Parameters:
        rootDirectory - File directory candidate
        Throws:
        IllegalArgumentException - if root directory does not appear to be an OpenDJ installation root. The thrown exception contains a localized message indicating the reason why rootDirectory is not a valid OpenDJ install root.
      • getLocal

        public static Installation getLocal()
        Obtains the installation by reading the classpath of the running JVM to determine the location of the jars and determine the installation root.
        Returns:
        Installation obtained by reading the classpath
      • getRootDirectory

        public File getRootDirectory()
        Gets the top level directory of an OpenDJ installation.
        Returns:
        File object representing the top level directory of and OpenDJ installation
      • getInstanceDirectory

        public File getInstanceDirectory()
        Gets the top level directory of an OpenDJ instance.
        Returns:
        File object representing the top level directory of and OpenDK installation
      • setRootDirectory

        public void setRootDirectory​(File rootDirectory)
        Sets the root directory of this installation.
        Parameters:
        rootDirectory - File of this installation
      • setInstanceDirectory

        public void setInstanceDirectory​(File instanceDirectory)
        Sets the root directory of this instance.
        Parameters:
        instanceDirectory - File of this instance
      • isValid

        public boolean isValid​(File file)
        Indicates whether this installation appears to be an actual OpenDJ installation.
        Parameters:
        file - The root directory
        Returns:
        boolean where true indicates that this does indeed appear to be a valid OpenDJ installation; false otherwise
      • getInvalidityReason

        public String getInvalidityReason()
        Creates a string explaining why this is not a legitimate OpenDJ installation. Null if this is in fact a valid installation.
        Returns:
        localized message indicating the reason this is not an OpenDJ installation
      • getCurrentConfiguration

        public Configuration getCurrentConfiguration()
        Gets the Configuration object representing this file. The current configuration is stored in config/config.ldif.
        Returns:
        Configuration representing the current configuration.
      • getBaseConfiguration

        public Configuration getBaseConfiguration()
                                           throws ApplicationException
        Gets the Configuration object representing this file. The base configuration is stored in config/upgrade/config.ldif.[svn rev].
        Returns:
        Configuration object representing the base configuration.
        Throws:
        ApplicationException - if there was a problem determining the svn rev number.
      • getStatus

        public Status getStatus()
        Gets the current status of this installation.
        Returns:
        Status object representing the state of this installation.
      • getLibrariesDirectory

        public File getLibrariesDirectory()
        Returns the path to the libraries.
        Returns:
        the path to the libraries.
      • getResourcesDirectory

        public File getResourcesDirectory()
        Returns the path to the resources directory.
        Returns:
        the path to the resources directory.
      • getClassesDirectory

        public File getClassesDirectory()
        Returns the path to the classes directory.
        Returns:
        the path to the classes directory.
      • getSchemaConcatFile

        public File getSchemaConcatFile()
        Creates a File object representing config/upgrade/schema.ldif.current which the server creates the first time it starts if there are schema customizations.
        Returns:
        File object with no
      • getBaseSchemaFile

        public File getBaseSchemaFile()
                               throws ApplicationException
        Creates a File object representing config/upgrade/schema.ldif.current which the server creates the first time it starts if there are schema customizations.
        Returns:
        File object with no
        Throws:
        ApplicationException - if there was a problem determining the svn revision number
      • getBaseConfigurationFile

        public File getBaseConfigurationFile()
                                      throws ApplicationException
        Creates a File object representing config/upgrade/schema.ldif.current which the server creates the first time it starts if there are schema customizations.
        Returns:
        File object with no
        Throws:
        ApplicationException - if there was a problem determining the svn revision number
      • getVCSRevision

        public String getVCSRevision()
                              throws ApplicationException
        Gets the VCS revision of the build.
        Returns:
        String representing the VCS revision
        Throws:
        ApplicationException - if for some reason the number could not be determined
      • getInstanceVCSRevision

        public String getInstanceVCSRevision()
                                      throws ApplicationException
        Gets the VCS revision of the instance.
        Returns:
        Integer representing the svn number
        Throws:
        ApplicationException - if for some reason the number could not be determined
      • getCurrentConfigurationFile

        public File getCurrentConfigurationFile()
        Returns the path to the configuration file of the directory server. Note that this method assumes that this code is being run locally.
        Returns:
        the path of the configuration file of the directory server.
      • getBinariesDirectory

        public File getBinariesDirectory()
        Returns the relative path of the directory containing the binaries/scripts of the Open DS installation. The path is relative to the installation path.
        Returns:
        the relative path of the directory containing the binaries/scripts of the Open DS installation.
      • getDatabasesDirectory

        public File getDatabasesDirectory()
        Returns the path to the database files under the install path.
        Returns:
        the path to the database files under the install path.
      • getBackupDirectory

        public File getBackupDirectory()
        Returns the path to the backup files under the install path.
        Returns:
        the path to the backup files under the install path.
      • getConfigurationDirectory

        public File getConfigurationDirectory()
        Returns the path to the config files under the install path.
        Returns:
        the path to the config files under the install path.
      • getLogsDirectory

        public File getLogsDirectory()
        Returns the path to the log files under the install path.
        Returns:
        the path to the log files under the install path.
      • getLocksDirectory

        public File getLocksDirectory()
        Returns the directory where the lock files are stored.
        Returns:
        the path to the lock files.
      • getTemplateDirectory

        public File getTemplateDirectory()
        Gets the directory used to store the template configuration.
        Returns:
        The directory used to store the template configuration.
      • getTemporaryDirectory

        public File getTemporaryDirectory()
        Gets the directory used to store files temporarily.
        Returns:
        File temporary directory
      • getHistoryDirectory

        public File getHistoryDirectory()
        Returns the directory where the lock files are stored.
        Returns:
        the path to the lock files.
      • createHistoryBackupDirectory

        public File createHistoryBackupDirectory()
                                          throws IOException
        Creates a new directory in the history directory appropriate for backing up an installation during an upgrade.
        Returns:
        File representing a new backup directory. The directory can be assumed to exist if this method returns cleanly.
        Throws:
        IOException - if an error occurred creating the directory.
      • getHistoryLogFile

        public File getHistoryLogFile()
        Gets the log file where the history of upgrades and reversions is kept.
        Returns:
        File containing upgrade/reversion history.
      • getConfigurationUpgradeDirectory

        public File getConfigurationUpgradeDirectory()
        Gets the directory config/upgrade.
        Returns:
        File representing the config/upgrade directory
      • getTemporaryUpgradeDirectory

        public File getTemporaryUpgradeDirectory()
        Gets the directory where the upgrader stores files temporarily.
        Returns:
        File representing the upgrader's temporary directory
      • getCommandFile

        public File getCommandFile​(String command)
        Gets the file for invoking a particular command appropriate for the current operating system.
        Parameters:
        command - name of the command
        Returns:
        File representing the command
      • getServerStartCommandFile

        public File getServerStartCommandFile()
        Gets the file responsible for stopping the server appropriate for the current operating system.
        Returns:
        File representing the stop command
      • getServerStopCommandFile

        public File getServerStopCommandFile()
        Gets the file responsible for stopping the server appropriate for the current operating system.
        Returns:
        File representing the stop command
      • getSetupFileName

        public static String getSetupFileName()
        Returns the setup file name to use with the current operating system.
        Returns:
        the setup file name to use with the current operating system.
      • getLdifDirectory

        public File getLdifDirectory()
        Returns the 'ldif' directory.
        Returns:
        the 'ldif' directory.
      • getQuicksetupJarFile

        public File getQuicksetupJarFile()
        Returns the path to the quicksetup jar file.
        Returns:
        the path to the quicksetup jar file.
      • getOpenDSJarFile

        public File getOpenDSJarFile()
        Returns the path to the opends jar file.
        Returns:
        the path to the opends jar file.
      • getUninstallBatFile

        public File getUninstallBatFile()
        Returns the path to the uninstall.bat file.
        Returns:
        the path to the uninstall.bat file.
      • getControlPanelCommandFile

        public File getControlPanelCommandFile()
        Gets the control panel command file appropriate for the current operating system.
        Returns:
        File object representing the control panel command
      • getBuildInformation

        public BuildInformation getBuildInformation()
                                             throws ApplicationException
        Gets information about the build that was used to produce the bits for this installation.
        Returns:
        BuildInformation object describing this installation
        Throws:
        ApplicationException - if there is a problem obtaining the build information
      • getBuildInformation

        public BuildInformation getBuildInformation​(boolean useCachedVersion)
                                             throws ApplicationException
        Gets information about the build that was used to produce the bits for this installation.
        Parameters:
        useCachedVersion - where true indicates that a potentially cached version of the build information is acceptable for use; false indicates the the build information will be created from scratch which is potentially time consuming
        Returns:
        BuildInformation object describing this installation
        Throws:
        ApplicationException - if there is a problem obtaining the build information
      • getInstanceBuildInformation

        public BuildInformation getInstanceBuildInformation()
        Gets information about the build that was used to produce the instance.
        Returns:
        BuildInformation object describing this instance