opends/src/server/org/opends/server/tools/upgrade/AbstractUpgradeTask.java
@@ -31,12 +31,12 @@ /** * Abstract upgrade task implementation. */ public abstract class AbstractUpgradeTask implements UpgradeTask abstract class AbstractUpgradeTask implements UpgradeTask { /** * Creates a new abstract upgrade task. */ protected AbstractUpgradeTask() AbstractUpgradeTask() { // No implementation required. } opends/src/server/org/opends/server/tools/upgrade/FileManager.java
@@ -52,7 +52,7 @@ * system files. This class handles application notifications for interesting * events. */ public class FileManager class FileManager { /** opends/src/server/org/opends/server/tools/upgrade/FormattedNotificationCallback.java
@@ -40,15 +40,20 @@ */ private static final long serialVersionUID = 1L; static final int TITLE_CALLBACK = 5; /** Output a title. */ public static final int TITLE_CALLBACK = 5; static final int SUBTITLE_CALLBACK = 6; /** Output a sub-title. */ public static final int SUBTITLE_CALLBACK = 6; static final int NOTICE_CALLBACK = 7; /** Output a notice message. */ public static final int NOTICE_CALLBACK = 7; static final int ERROR_CALLBACK = 8; /** Output an error. */ public static final int ERROR_CALLBACK = 8; static final int BREAKLINE = 9; /** Output a line break. */ public static final int BREAKLINE = 9; /** * An integer representing the message's sub-type. @@ -63,7 +68,7 @@ * @param messageSubType * An integer representing the sub-type of this message. */ public FormattedNotificationCallback(final Message message, FormattedNotificationCallback(final Message message, final int messageSubType) { super(TextOutputCallback.INFORMATION, message.toString()); @@ -79,15 +84,4 @@ { return messageSubType; } /** * Sets the message's sub-type. * * @param messageSubType * The message's sub-type. */ public void setMessageSubType(int messageSubType) { this.messageSubType = messageSubType; } } opends/src/server/org/opends/server/tools/upgrade/Installation.java
@@ -32,142 +32,142 @@ * operations are dependent upon the root directory that is specified in the * constructor. */ public final class Installation final class Installation { /** Relative path to bootstrap OpenDJ jar file. */ public static final String OPENDJ_BOOTSTRAP_JAR_RELATIVE_PATH = static final String OPENDJ_BOOTSTRAP_JAR_RELATIVE_PATH = "lib/bootstrap.jar"; /** * The relative path where all the Windows binaries (batch files) are. */ public static final String WINDOWS_BINARIES_PATH_RELATIVE = "bat"; static final String WINDOWS_BINARIES_PATH_RELATIVE = "bat"; /** * The relative path where all the UNIX binaries (scripts) are. */ public static final String UNIX_BINARIES_PATH_RELATIVE = "bin"; static final String UNIX_BINARIES_PATH_RELATIVE = "bin"; /** * The relative path where the database files are. */ public static final String DATABASES_PATH_RELATIVE = "db"; static final String DATABASES_PATH_RELATIVE = "db"; /** * The relative path where the log files are. */ public static final String LOGS_PATH_RELATIVE = "logs"; static final String LOGS_PATH_RELATIVE = "logs"; /** * The relative path where the config files are. */ public static final String CONFIG_PATH_RELATIVE = "config"; static final String CONFIG_PATH_RELATIVE = "config"; /** * The relative path where the config files are. */ public static final String HISTORY_PATH_RELATIVE = "history"; static final String HISTORY_PATH_RELATIVE = "history"; /** * Path to the config/upgrade directory where upgrade base files are stored. */ public static final String UPGRADE_PATH = "upgrade"; static final String UPGRADE_PATH = "upgrade"; /** * Relative path to the change log database directory. */ public static final String CHANGELOG_PATH_RELATIVE = "changelogDb"; static final String CHANGELOG_PATH_RELATIVE = "changelogDb"; /** * Relative path to the locks directory. */ public static final String LOCKS_PATH_RELATIVE = "locks"; static final String LOCKS_PATH_RELATIVE = "locks"; /** * Relative path to the locks directory. */ public static final String TMP_PATH_RELATIVE = "tmp"; static final String TMP_PATH_RELATIVE = "tmp"; /** * Relative path to the snmp directory. */ public static final String SNMP_PATH_RELATIVE = "snmp"; static final String SNMP_PATH_RELATIVE = "snmp"; /** * Relative path to the security directory. */ public static final String SECURITY_PATH_RELATIVE = "security"; static final String SECURITY_PATH_RELATIVE = "security"; /** * The relative path to the current Configuration LDIF file. */ public static final String CURRENT_CONFIG_FILE_NAME = "config.ldif"; static final String CURRENT_CONFIG_FILE_NAME = "config.ldif"; /** * The path to the default instance. */ public static final String DEFAULT_INSTANCE_PATH = "/var/opendj"; static final String DEFAULT_INSTANCE_PATH = "/var/opendj"; /** * The relative path to the instance.loc file. */ public static final String INSTANCE_LOCATION_PATH_RELATIVE = "instance.loc"; static final String INSTANCE_LOCATION_PATH_RELATIVE = "instance.loc"; /** * The path to the instance.loc file. */ public static final String INSTANCE_LOCATION_PATH = "/etc/opendj/" static final String INSTANCE_LOCATION_PATH = "/etc/opendj/" + INSTANCE_LOCATION_PATH_RELATIVE; /** * The relative path to tmpl_instance. */ public static final String TEMPLATE_RELATIVE_PATH = "template"; static final String TEMPLATE_RELATIVE_PATH = "template"; /** * Relative path to the schema directory. */ public static final String SCHEMA_PATH_RELATIVE = "schema"; static final String SCHEMA_PATH_RELATIVE = "schema"; /** * The relative path to buildinfo file. */ public static final String BUILDINFO_RELATIVE_PATH = "buildinfo"; static final String BUILDINFO_RELATIVE_PATH = "buildinfo"; /** * The UNIX setup script file name. */ public static final String UNIX_SETUP_FILE_NAME = "setup"; static final String UNIX_SETUP_FILE_NAME = "setup"; /** * The UNIX upgrade script file name. */ public static final String UNIX_UPGRADE_FILE_NAME = "upgrade"; static final String UNIX_UPGRADE_FILE_NAME = "upgrade"; /** * The UNIX uninstall script file name. */ public static final String UNIX_UNINSTALL_FILE_NAME = "uninstall"; static final String UNIX_UNINSTALL_FILE_NAME = "uninstall"; /** * The Windows upgrade batch file name. */ public static final String WINDOWS_UPGRADE_FILE_NAME = "upgrade.bat"; static final String WINDOWS_UPGRADE_FILE_NAME = "upgrade.bat"; /** * The UNIX configure script file name. */ public static final String UNIX_CONFIGURE_FILE_NAME = "configure"; static final String UNIX_CONFIGURE_FILE_NAME = "configure"; /** * The MacOS X Java application stub name. */ public static final String MAC_JAVA_APP_STUB_NAME = "JavaApplicationStub"; static final String MAC_JAVA_APP_STUB_NAME = "JavaApplicationStub"; /** * Generic name for the backup tool. */ public static final String BACKUP = "backup"; static final String BACKUP = "backup"; } opends/src/server/org/opends/server/tools/upgrade/LicenseFile.java
@@ -40,7 +40,7 @@ * NOTE: the license file location must be kept in sync with build.xml and * org.opends.quicksetup.LicenseFile. */ public class LicenseFile class LicenseFile { /** * Get the directory in which legal files are stored. @@ -132,7 +132,7 @@ * the Legal directory in the top level installation directory * <CODE>false</CODE> otherwise. */ static public boolean exists() static boolean exists() { return getFile().exists(); } @@ -142,7 +142,7 @@ * * @return the textual contents of the license file. */ static public String getText() static String getText() { FileReader reader; @@ -181,7 +181,7 @@ * @return <CODE>true</CODE> if the license has been accepted by the user * <CODE>false</CODE> otherwise. */ static public boolean getApproval() static boolean getApproval() { return approved; } @@ -192,7 +192,7 @@ * @param p_approved * the license approval status */ static public void setApproval(boolean p_approved) static void setApproval(boolean p_approved) { approved = p_approved; } @@ -200,7 +200,7 @@ /** * Create a file which indicates that the license has been approved. */ static public void createFileLicenseApproved() static void createFileLicenseApproved() { if (getApproval()) { @@ -221,7 +221,7 @@ * @return <CODE>true</CODE> if the license had already been approved by the * user <CODE>false</CODE> otherwise. */ static public boolean isAlreadyApproved() static boolean isAlreadyApproved() { File f = new File(getInstanceLegalDirectory() + File.separatorChar opends/src/server/org/opends/server/tools/upgrade/ProgressNotificationCallback.java
@@ -55,7 +55,7 @@ * @param progress * An integer representing the percentage of the task's progress. */ public ProgressNotificationCallback(final int messageType, ProgressNotificationCallback(final int messageType, final Message message, final int progress) { super(messageType, message.toString()); @@ -73,24 +73,13 @@ } /** * Sets the percentage's progress. * * @param progress * The percentage's progress. */ public void setProgress(int progress) { this.progress = progress; } /** * Change the progress on an existing progress notification callback. * * @param progress * The new value of the progress. * @return A progress Notification Callback */ public ProgressNotificationCallback changeProgress(int progress) ProgressNotificationCallback setProgress(int progress) { this.progress = progress; return this; opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -75,18 +75,18 @@ /** * The success exit code value. */ public static final int EXIT_CODE_SUCCESS = 0; static final int EXIT_CODE_SUCCESS = 0; /** * The error exit code value. */ public static final int EXIT_CODE_ERROR = 1; static final int EXIT_CODE_ERROR = 1; /** * The exit code value that will be used if upgrade requires manual * intervention. */ public static final int EXIT_CODE_MANUAL_INTERVENTION = 2; static final int EXIT_CODE_MANUAL_INTERVENTION = 2; /** * Developers should register upgrade tasks below. @@ -322,7 +322,7 @@ * @return A list containing all the tasks which are required in order to * upgrade from {@code fromVersion} to {@code toVersion}. */ public static List<UpgradeTask> getUpgradeTasks( private static List<UpgradeTask> getUpgradeTasks( final BuildVersion fromVersion, final BuildVersion toVersion) { final List<UpgradeTask> tasks = new LinkedList<UpgradeTask>(); opends/src/server/org/opends/server/tools/upgrade/UpgradeCli.java
@@ -196,7 +196,7 @@ * * @return {@code true} if the upgrade process is forced. */ public boolean isForceUpgrade() private boolean isForceUpgrade() { return force.isPresent(); } @@ -207,7 +207,7 @@ * * @return {@code true} if the errors are forced to be ignored. */ public boolean isIgnoreErrors() private boolean isIgnoreErrors() { return ignoreErrors.isPresent(); } @@ -217,7 +217,7 @@ * * @return {@code true} if license is accepted by default. */ public boolean isAcceptLicense() private boolean isAcceptLicense() { return acceptLicense.isPresent(); } opends/src/server/org/opends/server/tools/upgrade/UpgradeContext.java
@@ -27,13 +27,9 @@ package org.opends.server.tools.upgrade; import static org.opends.messages.ToolMessages. ERR_UPGRADE_DISPLAY_NOTIFICATION_ERROR; import static org.opends.messages.ToolMessages. ERR_UPGRADE_DISPLAY_CONFIRM_ERROR; import static org.opends.messages.ToolMessages.INFO_PROMPT_NO_COMPLETE_ANSWER; import static org.opends.messages.ToolMessages.INFO_PROMPT_YES_COMPLETE_ANSWER; import static org.opends.messages.ToolMessages.INFO_TASKINFO_CMD_CANCEL_CHAR; import static org.opends.messages.ToolMessages.*; import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_ERROR; import javax.security.auth.callback.Callback; @@ -45,6 +41,8 @@ import org.opends.server.tools.ClientException; import org.opends.server.util.BuildVersion; /** * Context information which is passed to upgrade tasks. This might include * server configuration, etc. @@ -65,7 +63,7 @@ /** * The call-back handler for interacting with the upgrade application. */ private CallbackHandler handler; private final CallbackHandler handler; /** * If ignore errors is enabled. @@ -88,6 +86,7 @@ private boolean isForceUpgradeMode; /** * Constructor for the upgrade context. * @@ -99,44 +98,52 @@ * The call-back handler for interacting with the upgrade * application. */ UpgradeContext(final BuildVersion fromVersion, final BuildVersion toVersion, CallbackHandler handler) public UpgradeContext(final BuildVersion fromVersion, final BuildVersion toVersion, CallbackHandler handler) { this.fromVersion = fromVersion; this.toVersion = toVersion; this.handler = handler; } /** * Returns the old version. * * @return The old version. */ public BuildVersion getFromVersion() BuildVersion getFromVersion() { return fromVersion; } /** * Returns the new version. * * @return The new version. */ public BuildVersion getToVersion() BuildVersion getToVersion() { return toVersion; } /** * Returns the ignore error mode. * * @return {code true} if ignore error mode is activated. */ public boolean isIgnoreErrorsMode() boolean isIgnoreErrorsMode() { return isIgnoreErrorsMode; } /** * Sets the ignore errors mode. * @@ -148,16 +155,20 @@ this.isIgnoreErrorsMode = isIgnoreErrorsMode; } /** * Returns the accept license mode. * * @return {@code true} if accept license mode is activated. */ public boolean isAcceptLicenseMode() boolean isAcceptLicenseMode() { return isAcceptLicenseMode; } /** * Sets the accept license mode. * @@ -169,38 +180,32 @@ this.isAcceptLicenseMode = isAcceptLicenseMode; } /** * Returns the callback handler. * * @return The actual callback handler. */ public CallbackHandler getHandler() CallbackHandler getHandler() { return handler; } /** * Sets the upgrade callback handler. * * @param handler * The call-back handler for interacting with the upgrade * application. */ public void setHandler(CallbackHandler handler) { this.handler = handler; } /** * Returns the status of the interactive mode. * * @return {@code true} if interactive mode is activated. */ public boolean isInteractiveMode() boolean isInteractiveMode() { return isInteractiveMode; } /** * Sets the interactive mode. * @@ -212,16 +217,20 @@ this.isInteractiveMode = isInteractiveMode; } /** * Returns the status of the force upgrade mode. * * @return {@code true} if the force upgrade mode is activated. */ public boolean isForceUpgradeMode() boolean isForceUpgradeMode() { return isForceUpgradeMode; } /** * Sets the force upgrade mode. * @@ -233,6 +242,8 @@ this.isForceUpgradeMode = isForceUpgradeMode; } /** * Sends notification message to the application via the call-back handler. * @@ -241,7 +252,7 @@ * @throws ClientException * If an error occurred while reporting the message. */ public void notify(final Message message) throws ClientException void notify(final Message message) throws ClientException { try { @@ -255,6 +266,8 @@ } } /** * Sends notification message to the application via the call-back handler * containing specific sub type message. @@ -266,8 +279,7 @@ * @throws ClientException * If an error occurred while reporting the message. */ public void notify(final Message message, final int msgType) throws ClientException void notify(final Message message, final int msgType) throws ClientException { try { @@ -281,6 +293,8 @@ } } /** * Displays a progress callback. * @@ -289,7 +303,7 @@ * @throws ClientException * If an error occurred while reporting the message. */ public void notifyProgress(final ProgressNotificationCallback callback) void notifyProgress(final ProgressNotificationCallback callback) throws ClientException { try @@ -303,6 +317,8 @@ } } /** * Asks a confirmation to the user. Answer is yes or no. * @@ -314,13 +330,12 @@ * If an error occurred while reporting the message. * @return an integer corresponding to the user's answer. */ public int confirmYN(final Message message, final int defaultOption) int confirmYN(final Message message, final int defaultOption) throws ClientException { final ConfirmationCallback confirmYNCallback = new ConfirmationCallback(message.toString(), ConfirmationCallback.WARNING, ConfirmationCallback.YES_NO_OPTION, defaultOption); final ConfirmationCallback confirmYNCallback = new ConfirmationCallback( message.toString(), ConfirmationCallback.WARNING, ConfirmationCallback.YES_NO_OPTION, defaultOption); try { handler.handle(new Callback[] { confirmYNCallback }); @@ -333,6 +348,8 @@ return confirmYNCallback.getSelectedIndex(); } /** * Returns the default option string. * opends/src/server/org/opends/server/tools/upgrade/UpgradeTasks.java
@@ -129,10 +129,10 @@ try { context.notifyProgress(pnc.changeProgress(20)); context.notifyProgress(pnc.setProgress(20)); copy(schemaFileTemplate, configSchemaDirectory, true); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final IOException e) { @@ -169,10 +169,10 @@ try { context.notifyProgress(pnc.changeProgress(20)); context.notifyProgress(pnc.setProgress(20)); copy(configFile, configDirectory, true); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final IOException e) { @@ -273,7 +273,7 @@ displayChangeCount(pathDestination.getPath(), changeCount); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final IOException e) { @@ -319,7 +319,7 @@ final File pathDestination = new File(configSchemaDirectory, fileName); context.notifyProgress(pnc.changeProgress(20)); context.notifyProgress(pnc.setProgress(20)); try { @@ -329,7 +329,7 @@ displayChangeCount(pathDestination.getPath(), changeCount); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final IOException e) { @@ -541,7 +541,7 @@ updateConfigUpgradeSchemaFile(configSchemaDirectory, String .valueOf(context.getToVersion().getRevisionNumber())); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final Exception ex) { @@ -584,7 +584,7 @@ + File.separator + "opends-snmp.security"); if (oldSnmpConfig.exists()) { context.notifyProgress(pnc.changeProgress(20)); context.notifyProgress(pnc.setProgress(20)); LOG.log(Level.INFO, summary.toString()); final File snmpConfig = @@ -593,7 +593,7 @@ FileManager.rename(oldSnmpConfig, snmpConfig); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } } catch (final Exception ex) @@ -659,7 +659,7 @@ displayChangeCount(configFile.getPath(), changeCount); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final Exception e) { @@ -705,7 +705,7 @@ throws ClientException { countErrors++; context.notifyProgress(pnc.changeProgress(-100)); context.notifyProgress(pnc.setProgress(-100)); LOG.log(Level.SEVERE, message.toString()); if (!context.isIgnoreErrorsMode()) { @@ -764,7 +764,7 @@ displayChangeCount(configFile.getPath(), changeCount); context.notifyProgress(pnc.changeProgress(100)); context.notifyProgress(pnc.setProgress(100)); } catch (final Exception e) { opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -117,7 +117,7 @@ * * @return the path of the installation of the directory server. */ public static String getInstallPathFromClasspath() static String getInstallPathFromClasspath() { String installPath = DirectoryServer.getServerRoot(); if (installPath != null) @@ -173,7 +173,7 @@ * The installation path * @return the path of the installation of the directory server. */ public static String getInstancePathFromInstallPath(final String installPath) static String getInstancePathFromInstallPath(final String installPath) { String instancePathFileName = Installation.INSTANCE_LOCATION_PATH; final File configureScriptPath = @@ -239,7 +239,7 @@ * File to get the path * @return the absolute path for the given file. */ public static String getPath(File f) static String getPath(File f) { String path = null; if (f != null) @@ -274,7 +274,7 @@ * the relative path. * @return the absolute path for the given parentPath and relativePath. */ public static String getPath(final String parentPath, static String getPath(final String parentPath, final String relativePath) { return getPath(new File(new File(parentPath), relativePath)); @@ -287,7 +287,7 @@ * @return <CODE>true</CODE> if we are running under windows and * <CODE>false</CODE> otherwise. */ public static boolean isWindows() static boolean isWindows() { return SetupUtils.isWindows(); } @@ -299,7 +299,7 @@ * @return <CODE>true</CODE> if we are running under Unix and * <CODE>false</CODE> otherwise. */ public static boolean isUnix() static boolean isUnix() { return SetupUtils.isUnix(); } @@ -313,7 +313,7 @@ * possible child 0f <code>ancestor</code> * @return return true if ancestor is a parent of descendant */ static public boolean isParentOf(final File ancestor, File descendant) static boolean isParentOf(final File ancestor, File descendant) { if (ancestor != null) { @@ -338,7 +338,7 @@ * path in the file system; <code>false</code> otherwise or if * either of the files are null */ public static boolean isDescendant(File descendant, File path) { static boolean isDescendant(File descendant, File path) { boolean isDescendant = false; if (descendant != null && path != null) { File parent = descendant.getParentFile();