| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.FileNotFoundException; |
| | | import java.util.logging.Level; |
| | | import java.util.logging.Logger; |
| | | |
| | | /** |
| | | * BuildExtractor unzips an OpenDS installation package (.zip file) from a user |
| | |
| | | */ |
| | | public class BuildExtractor extends Application implements Runnable { |
| | | |
| | | static private final Logger LOG = |
| | | Logger.getLogger(BuildExtractor.class.getName()); |
| | | |
| | | /** |
| | | * Creates and run a BuildExtractor using command line arguments. |
| | | * @param args String[] command line arguments |
| | | */ |
| | | public static void main(String[] args) { |
| | | try { |
| | | QuickSetupLog.initLogFileHandler( |
| | | File.createTempFile( |
| | | UpgradeLauncher.LOG_FILE_PREFIX + "-ext-", |
| | | UpgradeLauncher.LOG_FILE_SUFFIX)); |
| | | } catch (Throwable t) { |
| | | System.err.println("Unable to initialize log"); |
| | | t.printStackTrace(); |
| | | } |
| | | new BuildExtractor(args).run(); |
| | | } |
| | | |
| | |
| | | retCode = 1; |
| | | notifyListeners(t.getLocalizedMessage() + getLineBreak()); |
| | | } |
| | | LOG.log(Level.INFO, "extractor exiting code=" + retCode); |
| | | System.exit(retCode); |
| | | } |
| | | |
| | |
| | | |
| | | private void expandZipFile(File buildFile) |
| | | throws ApplicationException, IOException { |
| | | ZipExtractor extractor = new ZipExtractor(buildFile, |
| | | 1, 10, // TODO figure out these values |
| | | Utils.getNumberZipEntries(), this); |
| | | LOG.log(Level.INFO, "expanding zip file " + buildFile.getPath()); |
| | | ZipExtractor extractor = new ZipExtractor(buildFile); |
| | | extractor.extract(getStageDirectory()); |
| | | LOG.log(Level.INFO, "extraction finished"); |
| | | } |
| | | |
| | | private File getStageDirectory() throws ApplicationException { |
| | |
| | | Installation installation = new Installation(getInstallationPath()); |
| | | stageDir = installation.getTemporaryUpgradeDirectory(); |
| | | if (stageDir.exists()) { |
| | | FileManager fm = new FileManager(this); |
| | | FileManager fm = new FileManager(); |
| | | fm.deleteRecursively(stageDir); |
| | | } |
| | | if (!stageDir.mkdirs()) { |
| | |
| | | throw ApplicationException.createFileSystemException( |
| | | "failed to create staging directory " + stageDir, null); |
| | | } |
| | | LOG.log(Level.INFO, "stage directory " + stageDir.getPath()); |
| | | return stageDir; |
| | | } |
| | | |