UpgradeServices.java revision 3541688024dba67a647e29de859a327fc1018b05
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2011-2014 ForgeRock AS.
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (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
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
*/
/*
* Portions Copyrighted 2014 Nomura Research Institute, Ltd
*/
/**
* This is the primary upgrade class that determines the how the services need
* to be upgraded and performs the upgrade.
*
* @author steve
*/
public class UpgradeServices {
private static volatile UpgradeServices instance;
private final SimpleDateFormat dateFormat;
private final String createdDate;
private UpgradeServices() throws UpgradeException {
try {
step.initialize();
if (step.isApplicable()) {
}
throw new UpgradeException("Unable to initialize upgrade steps");
}
}
}
final Class<? extends UpgradeStep> upgradeStepClass = Class.forName(className).asSubclass(UpgradeStep.class);
}
/**
* Returns the singleton instance of UpgradeServices, which will hold all the details about the different upgrade
* steps.
*
* @return The singleton UpgradeServices instance.
* @throws UpgradeException If there was an error while initializing the upgrade steps.
*/
synchronized (UpgradeServices.class) {
instance = new UpgradeServices();
}
}
}
return instance;
}
/**
* Creates the <code>upgrade</code> and <code>backups</code> folders if they are not already present.
*
* @param baseDir The base directory of the OpenAM configuration.
* @throws UpgradeException If there was an error while creating the necessary directories.
*/
}
+ " cannot be created as file of the same name already exists");
}
if (!d.exists()) {
}
if (!d.mkdir()) {
}
} else if (!d.canWrite()) {
// make bootstrap writable if it is not
if (!d.setWritable(true)) {
}
}
}
/**
* Kick off the upgrade process.
*
* @param adminToken A valid admin SSOToken.
* @param licenseAccepted Whether the license has been accepted or not.
* @throws UpgradeException If an error occurred while performing upgrade.
*/
if (!licenseAccepted) {
throw new UpgradeException("License terms have not been accepted");
}
if (debug.messageEnabled()) {
}
}
if (debug.messageEnabled()) {
}
// reset the version is newer flag
// reenable this after the CLI upgrade notifies the console correctly
//AMSetupServlet.isVersionNewer();
}
/**
* Writes the detailed upgrade report to a file.
*
* @param adminToken Valid admin SSOToken.
* @throws UpgradeException If there was an error while writing the report file.
*/
try {
/*
* As we have got this far then the user must have accepted the license, so we log this implicitly.
*/
}
+ createdDate;
// if exists then there has been an error
if (f.exists()) {
}
} catch (IOException ioe) {
}
}
/**
* Generates a short upgrade report suitable for the upgrade screen.
*
* @param adminToken Valid admin SSOToken.
* @param html Whether the output should be HTML or plain text.
* @return The short upgrade report.
*/
}
}
/**
* Generates a detailed upgrade report suitable for reviewing changes.
*
* @param adminToken Valid admin SSOToken.
* @param html Whether the output should be HTML or plain text.
* @return The detailed upgrade report.
*/
}
}
/**
* Creates a backup of the services/subconfigurations in case there is a need for a rollback.
*
* @param adminToken Valid admin SSOToken.
* @throws UpgradeException If there was an error while creating the backup.
*/
if (backupFile.exists()) {
throw new UpgradeException("Upgrade cannot continue as backup file exists");
}
try {
} finally {
try {
} catch (IOException ioe) {
//ignored
}
}
}
if (backupPasswdFile.exists()) {
debug.error("Upgrade cannot continue as backup password file exists! " + backupPasswdFile.getName());
throw new UpgradeException("Upgrade cannot continue as backup password file exists");
}
try {
} catch (IOException ioe) {
} finally {
}
}
}
private String generateBackupPassword() {
try {
} catch (PWResetException pre) {
// default implementation will not do this
}
return password;
}
/**
* Runs tagswap on a report, so the report structure is not hardcoded.
*
* @param reportContents Key-value mapping for the tags, these will be used to replace the localized report.
* @param key The i18n key in the localization file for this given report.
* @return The tagswapped report.
*/
}
/**
* Tagswaps a given String based on the passed in tags.
*
* @param tags Key-value mapping for the tags, these will be used to replace the localized report.
* @param content The content that needs to be tagswapped.
* @return The tagswapped content.
*/
}
return content;
}
}