WebStartInstaller.java revision cf364c082dfe5ea566abc3c20bc5546a4629c5eb
/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2014 ForgeRock AS
*/
/**
* This is an implementation of the Installer class that is used to install
* the Directory Server using Web Start.
*
* It just takes a UserData object and based on that installs OpenDS.
*
*
* This object has as parameter a WebStartDownloader object that is downloading
* some jar files. Until the WebStartDownloader has not finished downloading
* the jar files will be on the ProgressStep.DOWNLOADING step because
* we require all the jar files to be downloaded in order to install and
* configure the Directory Server.
*
* Based on the Java properties set through the QuickSetup.jnlp file this
* class will retrieve the zip file containing the install, unzip it and extract
* it in the path specified by the user and that is contained in the
* UserData object.
*
*
* When there is an update during the installation it will notify the
* ProgressUpdateListener objects that have been added to it. The notification
* will send a ProgressUpdateEvent.
*
* This class is supposed to be fully independent of the graphical layout.
*
*/
public class WebStartInstaller extends Installer {
/**
* WebStartInstaller constructor.
*/
public WebStartInstaller()
{
initLoader();
}
/**
* Actually performs the install in this thread. The thread is blocked.
*
*/
public void run()
{
initMaps();
boolean downloadedBits = false;
try
{
checkAbort();
if (isVerbose())
{
}
checkAbort();
downloadedBits = true;
try
{
}
catch (Throwable t)
{
}
checkAbort();
if (isVerbose())
{
}
checkAbort();
// create license accepted file
createData();
checkAbort();
{
if (isVerbose())
{
}
checkAbort();
}
if (mustStart())
{
if (isVerbose())
{
}
if (!isVerbose())
{
pointAdder.start();
}
try
{
}
finally
{
if (!isVerbose())
{
pointAdder.stop();
}
}
if (!isVerbose())
{
}
else
{
}
checkAbort();
}
if (mustCreateAds())
{
if (isVerbose())
{
}
updateADS();
checkAbort();
}
if (mustConfigureReplication())
{
if (isVerbose())
{
}
checkAbort();
}
if (mustInitializeSuffixes())
{
if (isVerbose())
{
}
checkAbort();
}
if (mustStop())
{
if (isVerbose())
{
}
if (!isVerbose())
{
}
if (!isVerbose())
{
}
}
checkAbort();
updateSummaryWithServerState(hmSummary, false);
} catch (ApplicationException ex)
{
} else {
// Stop the server if necessary
try {
if (!isVerbose())
{
}
if (!isVerbose())
{
}
} catch (Throwable t) {
}
}
updateSummaryWithServerState(hmSummary, false);
}
}
catch (Throwable t)
{
// Stop the server if necessary
try {
}
}
updateSummaryWithServerState(hmSummary, false);
}
}
/**
* {@inheritDoc}
*/
{
}
/**
* {@inheritDoc}
*/
{
} else {
}
return summary;
}
/**
* Initialize the different map used in this class.
*
*/
private void initMaps()
{
initSummaryMap(hmSummary, false);
/*
* hmTime contains the relative time that takes for each task to be
* accomplished. For instance if downloading takes twice the time of
* extracting, the value for downloading will be the double of the value for
* extracting.
*/
int totalTime = 0;
new ArrayList<InstallProgressStep>();
if (createNotReplicatedSuffix())
{
{
case CREATE_BASE_ENTRY:
break;
case IMPORT_FROM_LDIF_FILE:
break;
break;
}
}
{
}
if (mustStart())
{
}
if (mustCreateAds())
{
}
if (mustConfigureReplication())
{
}
if (mustInitializeSuffixes())
{
}
if (mustStop())
{
}
int cumulatedTime = 0;
for (InstallProgressStep s : steps)
{
if (statusTime != null)
{
}
}
}
throws ApplicationException {
{
throw new ApplicationException(
}
return in;
}
/**
* Creates the parent Directory for the server location if it does not exist.
* @throws ApplicationException if something goes wrong.
*/
private void createParentDirectoryIfRequired() throws ApplicationException
{
{
try
{
{
throw new ApplicationException(
}
}
catch (IOException ioe)
{
throw new ApplicationException(
ioe);
}
}
}
/**
* This method extracts the zip file.
* @param is the input stream with the contents of the zip file.
* @param minRatio the value of the ratio in the install that corresponds to
* the moment where we start extracting the zip files. Used to update
* properly the install progress ratio.
* @param maxRatio the value of the ratio in the installation that corresponds
* to the moment where we finished extracting the last zip file. Used to
* update properly the install progress ratio.
* @throws ApplicationException if an error occurs.
*/
throws ApplicationException {
this);
}
/**
* Returns the name of the zip file name that contains all the installation.
* @return the name of the zip file name that contains all the installation.
*/
private String getZipFileName()
{
// Passed as a java option in the JNLP file
}
/**
* Uninstall what has already been installed.
* @param downloadedBits whether the bits were downloaded or not.
*/
private void uninstall(boolean downloadedBits) {
if (downloadedBits)
{
if (!isVerbose())
{
}
else
{
}
// Stop the server if necessary
try {
} catch (ApplicationException e) {
}
}
try {
} catch (ApplicationException e) {
}
}
else
{
if (!isVerbose())
{
}
else
{
}
if (serverRoot.exists())
{
try {
} catch (ApplicationException e) {
}
}
}
if (!isVerbose())
{
}
}
/**
* {@inheritDoc}
*/
public String getInstallationPath()
{
return getUserData().getServerLocation();
}
/**
* {@inheritDoc}
*/
public String getInstancePath()
{
// TODO
return getUserData().getServerLocation();
}
}