| package org.eclipse.epp.installer.core.operations; |
| |
| import java.io.File; |
| import java.io.IOException; |
| |
| import org.eclipse.core.runtime.IPath; |
| import org.eclipse.core.runtime.Path; |
| import org.eclipse.epp.installer.core.InstallOptions; |
| import org.eclipse.epp.installer.core.model.Context; |
| import org.eclipse.epp.installer.core.model.ISequence; |
| import org.eclipse.epp.installer.core.model.SingletonOperation; |
| import org.eclipse.epp.installer.internal.core.operations.FinaliseBackupOperation; |
| import org.eclipse.epp.installer.internal.core.operations.SaveLogFileOperation; |
| |
| |
| public class CreateEclipseUninstallerOperation extends SingletonOperation implements |
| ISequence { |
| |
| private static final String INSTALLER_CONFIGURATION_DIR = "installer"; |
| |
| /** |
| * Install log file name. |
| */ |
| public static final String INSTALL_LOG = "install.log"; |
| |
| /** |
| * Install directory. |
| */ |
| private File installDirectory; |
| private InstallOptions installOptions; |
| |
| public CreateEclipseUninstallerOperation(InstallOptions installOptions, File installDirectory) { |
| if (installDirectory == null || installOptions == null) { |
| throw new IllegalArgumentException(); |
| } |
| this.installOptions = installOptions; |
| this.installDirectory = installDirectory; |
| } |
| |
| /** |
| * Prepare operation. |
| * |
| * @throws IOException |
| * throws exception if file operations could not be complited. |
| */ |
| protected void prepare() throws IOException { |
| IPath eclipsePath = new Path(installDirectory.getAbsolutePath()).addTrailingSeparator(); |
| String installerConfigurationPath = eclipsePath.append(INSTALLER_CONFIGURATION_DIR).toOSString(); |
| String uninstallCmd = "\"" + eclipsePath.append("eclipse").toOSString() + "\"" + |
| " -configuration " + "\"" + installerConfigurationPath + "\"" + |
| " -nosplash" + |
| " -vmargs" + |
| // " -D" + Context.INSTALLER_JAR_PROPERTY + "=" + System.getProperty(Context.INSTALLER_JAR_PROPERTY) + |
| " -D" + Context.INSTALLER_CONFIGURATION_TYPE_PROPERTY + "=uninstall"; |
| addPrerequisite(new RegisterProductOperation(installOptions, uninstallCmd)); |
| addPrerequisite(new SaveLogFileOperation(new File(installDirectory, INSTALL_LOG))); |
| addPrerequisite(new FinaliseBackupOperation()); |
| } |
| |
| /** |
| * Return string representation. |
| * |
| * @return Return string representation. |
| */ |
| public String toString() { |
| return "Creating uninstaller..."; |
| } |
| |
| } |