Installation.java revision 014019918f7e3844f558f6159b8d41517254edc2
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
*/
/**
* This class represents the physical state of an OpenDS installation.
* All the operations are dependent upon the root directory that is
* specified in the constructor.
*/
public class Installation {
/**
* Relative path to OpenDS jar files.
*/
public static final String[] OPEN_DS_JAR_RELATIVE_PATHS =
/**
* The relative path where all the Windows binaries (batch files) are.
*/
/**
* The relative path where all the UNIX binaries (scripts) are.
*/
/**
* The relative path where all the MacOS X Applications are.
*/
/**
* The relative path where all the libraries (jar files) are.
*/
public static final String LIBRARIES_PATH_RELATIVE =
/**
* The relative path where the database files are.
*/
/**
* The relative path where the log files are.
*/
/**
* The relative path where the LDIF files are.
*/
/**
* The relative path where the backup files are.
*/
/**
* The relative path where the config files are.
*/
/**
* The relative path where the config files are.
*/
/**
*/
/**
* Relative path to the change log database directory.
*/
/**
* Relative path to the locks directory.
*/
/**
* Relative path to the locks directory.
*/
/**
* The relative path to the current Configuration LDIF file.
*/
/**
* The relative path to the current Configuration LDIF file.
*/
/**
* The relative path to the tools.properties file.
*/
public static final String TOOLS_PROPERTIES =
/**
* The relative path to the instance.loc file.
*/
public static final String INSTANCE_LOCATION_PATH_RELATIVE =
"instance.loc";
/**
* The UNIX setup script file name.
*/
/**
* The Windows setup batch file name.
*/
/**
* The UNIX uninstall script file name.
*/
/**
* The Windows uninstall batch file name.
*/
/**
* The UNIX upgrade script file name.
*/
/**
* The Windows upgrade batch file name.
*/
/**
* Newly upgraded Windows upgrade batch file name. When the upgrade
* batch file requires upgrade it is not done during execution of the
* upgrade utility itself since replacing a running script on Windows
* with a different version leads to unpredictable results. Instead
* this new name is used for the upgraded version and the user is
* expected to manually rename the file following the upgrade.
*/
/**
* The UNIX start script file name.
*/
/**
* The Windows start batch file name.
*/
/**
* The UNIX stop script file name.
*/
/**
* The Windows stop batch file name.
*/
/**
* The UNIX status panel script file name.
*/
/**
* The Windows status panel batch file name.
*/
/**
* The MacOS X Java application stub name.
*/
/**
* The MacOS X status panel application bundle name.
*/
/**
* The UNIX status command line script file name.
*/
/**
* The Windows status command line batch file name.
*/
/**
* Name of the file kept in the histoy directory containing logs
* of upgrade and reversions.
*/
/**
* The name of the directory in an upgrade backup directory (child
* of the 'history' directory) that contains the install files from a
* previous version.
*/
/**
* The name of the directory in an upgrade backup directory (child
* of the 'history' directory) that contains the instance files from a
* previous version.
*/
/**
* The name of the directory in an upgrade backup directory (child
* of the 'history' directory) that contains the files from a
* previous version.
*/
/**
* Generic name for the backup tool.
*/
/**
* Generic name for the ldif-diff tool.
*/
/**
* The default java properties file.
*/
/**
* The default java properties file relative path.
*/
public static final String RELATIVE_JAVA_PROPERTIES_FILE =
/**
* The set java home and arguments properties file for Windows.
*/
public static final String SET_JAVA_PROPERTIES_FILE_WINDOWS =
"set-java-home.bat";
/**
* script utils file for UNIX systems.
*/
/**
* script utils file for Windows.
*/
/**
* The set java home and arguments properties file for UNIX systems.
*/
public static final String SET_JAVA_PROPERTIES_FILE_UNIX =
"set-java-home";
/**
* Directories required to be present for this installation
* to be considered valid.
*/
public static final String[] REQUIRED_DIRECTORIES =
new String[] {
};
/**
* Performs validation on the specified file to make sure that it is
* an actual OpenDS installation.
* @param rootDirectory File directory candidate
* @throws IllegalArgumentException if root directory does not appear to
* be an OpenDS installation root. The thrown exception contains
* a localized message indicating the reason why
* <code>rootDirectory</code> is not a valid OpenDS install root.
*/
throws IllegalArgumentException {
if (rootDirectory == null) {
} else if (!rootDirectory.exists()) {
} else if (!rootDirectory.isDirectory()) {
} else {
}
}
} else {
}
}
if (failureReason != null) {
}
}
static private 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.
* @return Installation obtained by reading the classpath
*/
static public Installation getLocal() {
// This allows testing of configuration components when the OpenDS.jar
// in the classpath does not necessarily point to the server's
.getProperty("org.opends.quicksetup.instance");
if (installRoot == null) {
}
if (instanceRoot == null) {
}
}
return local;
}
private File rootDirectory;
private File instanceDirectory;
private Configuration configuration;
private Configuration baseConfiguration;
private BuildInformation buildInformation;
/**
* Indicates if the install and instance are in the same directory.
* @return true if the install and instance are in the same directory.
*/
public boolean instanceAndInstallInSameDir;
/**
* Creates a new instance from a root directory specified as a string.
*
* @param rootDirectory of this installation
* @param instanceRootDirectory The instance root directory
*/
}
/**
* Creates a new instance from a root directory specified as a File.
*
* @param rootDirectory of this installation
*
* @param instanceDirectory of the instance
*/
if (rootDirectory.getAbsolutePath().
{
instanceAndInstallInSameDir = true ;
}
else
{
instanceAndInstallInSameDir = false;
}
}
/**
* Indicates if the install and instance are in the same directory.
* @return true if the install and instance are in the same directory.
*/
public boolean instanceAndInstallInSameDir()
{
return instanceAndInstallInSameDir;
}
/**
* Gets the top level directory of an OpenDS installation.
*
* @return File object representing the top level directory of
* and OpenDS installation
*/
public File getRootDirectory() {
return this.rootDirectory;
}
/**
* Gets the top level directory of an OpenDS instance.
*
* @return File object representing the top level directory of
* and OpenDS installation
*/
public File getInstanceDirectory() {
return this.instanceDirectory;
}
/**
* Sets the root directory of this installation.
*
* @param rootDirectory File of this installation
*/
// 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.
this.rootDirectory = rootDirectory;
// Obtaining build information is a fairly time consuming operation.
// Try to get a head start if possible.
if (isValid(rootDirectory)) {
try {
": " + bi);
} catch (ApplicationException e) {
}
}
}
/**
* Sets the root directory of this instance.
*
* @param instanceDirectory File of this instance
*/
// 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 filesyste.
this.instanceDirectory = instanceDirectory;
// Obtaining build information is a fairly time consuming operation.
// Try to get a head start if possible.
if (isValid(instanceDirectory)) {
try {
": " + bi);
} catch (ApplicationException e) {
}
}
}
/**
* Indicates whether or not this installation appears to be an actual
* OpenDS installation.
* @param file The root directory
* @return boolean where true indicates that this does indeed appear to be
* a valid OpenDS installation; false otherwise
*/
boolean valid = true;
try {
} catch (IllegalArgumentException e) {
valid = false;
}
return valid;
}
/**
* Creates a string explaining why this is not a legitimate OpenDS
* installation. Null if this is in fact a vaild installation.
* @return localized message indicating the reason this is not an
* OpenDS installation
*/
public String getInvalidityReason() {
try {
} catch (IllegalArgumentException e) {
reason = e.getLocalizedMessage();
}
return reason;
}
/**
* Gets the Configuration object representing this file. The
* current configuration is stored in config/config.ldif.
*
* @return Configuration representing the current configuration.
*/
public Configuration getCurrentConfiguration() {
if (configuration == null) {
}
return configuration;
}
/**
* Gets the Configuration object representing this file. The base
* configuration is stored in config/upgrade/config.ldif.[svn rev].
*
* @return Configuration object representing the base configuration.
* @throws ApplicationException if there was a problem determining the
* svn rev number.
*/
if (baseConfiguration == null) {
}
return baseConfiguration;
}
/**
* Gets the current status of this installation.
* @return Status object representing the state of this installation.
*/
}
return status;
}
/**
* Returns the path to the libraries.
*
* @return the path to the libraries.
*/
public File getLibrariesDirectory() {
}
/**
* Returns the path to the tools properties file.
*
* @return the path to the tools properties file.
*/
public File getToolsPropertiesFile() {
}
/**
* Returns the path to the set-java-home file.
*
* @return the path to the set-java-home file.
*/
public File getSetJavaHomeFile() {
return new File(getLibrariesDirectory(),
}
/**
* Creates a File object representing config/upgrade/schema.ldif.current
* which the server creates the first time it starts if there are schema
* customizations.
*
* @return File object with no
*/
public File getSchemaConcatFile() {
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
* customizations.
*
* @return File object with no
* @throws ApplicationException if there was a problem determining the
* svn revision number
*/
return new File(getConfigurationUpgradeDirectory(),
}
/**
* Creates a File object representing config/upgrade/schema.ldif.current
* which the server creates the first time it starts if there are schema
* customizations.
*
* @return File object with no
* @throws ApplicationException if there was a problem determining the
* svn revision number
*/
return new File(getConfigurationUpgradeDirectory(),
}
/**
* Gets the SVN revision number of the build.
*
* @return Integer representing the svn number
* @throws ApplicationException if for some reason the number could not
* be determined
*/
return bi.getRevisionNumber();
}
/**
* Returns the path to the configuration file of the directory server. Note
* that this method assumes that this code is being run locally.
*
* @return the path of the configuration file of the directory server.
*/
public File getCurrentConfigurationFile() {
}
/**
* Returns the path to the ADS file of the directory server. Note
* that this method assumes that this code is being run locally.
*
* @return the path of the ADS file of the directory server.
*/
public File getADSBackendFile() {
}
/**
* of the Open DS installation. The path is relative to the installation
* path.
*
* of the Open DS installation.
*/
public File getBinariesDirectory() {
} else {
}
return binPath;
}
/**
* Returns the path to the database files under the install path.
*
* @return the path to the database files under the install path.
*/
public File getDatabasesDirectory() {
}
/**
* Returns the path to the backup files under the install path.
*
* @return the path to the backup files under the install path.
*/
public File getBackupDirectory() {
}
/**
* Returns the path to the config files under the install path.
*
* @return the path to the config files under the install path.
*/
public File getConfigurationDirectory() {
}
/**
* Returns the path to the log files under the install path.
*
* @return the path to the log files under the install path.
*/
public File getLogsDirectory() {
}
/**
* Returns the directory where the lock files are stored.
*
* @return the path to the lock files.
*/
public File getLocksDirectory() {
}
/**
* Gets the directory used to store files temporarily.
* @return File temporary directory
*/
public File getTemporaryDirectory() {
}
/**
* Returns the directory where the lock files are stored.
*
* @return the path to the lock files.
*/
public File getHistoryDirectory() {
}
/**
* Creates a new directory in the history directory appropriate
* for backing up an installation during an upgrade.
* @return 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.
*/
new File(getHistoryDirectory(),
if (backupDirectory.exists()) {
}
if (!backupDirectory.mkdirs()) {
throw new IOException("failed to create history backup directory");
}
return backupDirectory;
}
/**
* Gets the log file where the history of upgrades and reversions is kept.
*/
public File getHistoryLogFile() {
}
/**
*/
public File getConfigurationUpgradeDirectory() {
}
/**
* Gets the directory where the upgrader stores files temporarily.
* @return File representing the upgrader's temporary directory
*/
public File getTemporaryUpgradeDirectory() {
}
/**
* Gets the file for invoking a particular command appropriate for
* the current operating system.
* @param command namd of the command
* @return File representing the command
*/
command + ".bat");
} else {
command);
}
return commandFile;
}
/**
* Gets the file responsible for stopping the server appropriate
* for the current operating system.
* @return File representing the stop command
*/
public File getServerStartCommandFile() {
} else {
}
return startCommandFile;
}
/**
* Gets the file responsible for stopping the server appropriate
* for the current operating system.
* @return File representing the stop command
*/
public File getServerStopCommandFile() {
} else {
}
return stopCommandFile;
}
/**
* Returns the 'ldif' directory.
*
* @return the 'ldif' directory.
*/
public File getLdifDirectory() {
}
/**
* Returns the path to the quicksetup jar file.
*
* @return the path to the quicksetup jar file.
*/
public File getQuicksetupJarFile() {
}
/**
* Returns the path to the opends jar file.
*
* @return the path to the opends jar file.
*/
public File getOpenDSJarFile() {
}
/**
* Returns the path to the uninstall.bat file.
*
* @return the path to the uninstall.bat file.
*/
public File getUninstallBatFile() {
}
/**
* Gets the status panel command file appropriate for the current operating
* system.
* @return File object representing the status panel command
*/
public File getStatusPanelCommandFile() {
} else {
}
return statusPanelCommandFile;
}
/**
* Gets the status command file appropriate for the current operating
* system.
* @return File object representing the status command
*/
public File getStatusCommandFile() {
} else {
}
return statusPanelCommandFile;
}
/**
* Gets information about the build that was used to produce the bits
* for this installation.
* @return BuildInformation object describing this installation
* @throws ApplicationException if there is a problem obtaining the
* build information
*/
return getBuildInformation(true);
}
/**
* Gets information about the build that was used to produce the bits
* for this installation.
* @param 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
* @return BuildInformation object describing this installation
* @throws ApplicationException if there is a problem obtaining the
* build information
*/
throws ApplicationException
{
new Callable<BuildInformation>() {
}
});
try {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
throw (ApplicationException)e.getCause();
}
}
return buildInformation;
}
/**
* {@inheritDoc}
*/
}
}