public static void unzip(InputStream is, String destDir) throws FileNotFoundException, IOException { unzip(is, new File(destDir)); }
public static void unzip(InputStream is, String destDir) throws FileNotFoundException, IOException { unzip(is, new File(destDir)); }
private File stage(InputStream inputStream) throws IOException { File stagingDir = new File(installDir, "fedorawar"); stagingDir.mkdirs(); Zip.unzip(inputStream, stagingDir); return stagingDir; } private File repackage(File stagingDir, File outputFile) throws IOException {
/** * Unpacks the contents of the FEDORA_HOME directory from the Distribution. * * @throws InstallationFailedException */ private void unpack() throws InstallationFailedException { System.out.println("Preparing FEDORA_HOME..."); if (!_installDir.exists() && !_installDir.mkdirs()) { throw new InstallationFailedException( "Unable to create FEDORA_HOME: " + _installDir.getAbsolutePath()); } if (!_installDir.isDirectory()) { throw new InstallationFailedException(_installDir.getAbsolutePath() + " is not a directory"); } try { Zip.unzip(_dist.get(Distribution.FEDORA_HOME), _installDir); setScriptsExecutable(new File(_installDir, "client" + File.separator + "bin")); File serverDir = new File(_installDir, "server"); if (_clientOnlyInstall) { FileUtils.delete(serverDir); } else { setScriptsExecutable(new File(serverDir, "bin")); } } catch (IOException e) { throw new InstallationFailedException(e.getMessage(), e); } }
@Override protected void installTomcat() throws InstallationFailedException { System.out.println("Installing Tomcat..."); try { Zip.unzip(getDist().get(Distribution.TOMCAT), System .getProperty("java.io.tmpdir")); } catch (IOException e) { throw new InstallationFailedException(e.getMessage(), e); } File f = new File(System.getProperty("java.io.tmpdir"), Distribution.TOMCAT_BASENAME); if (!FileUtils.move(f, getTomcatHome())) { throw new InstallationFailedException("Move to " + getTomcatHome().getAbsolutePath() + " failed."); } FedoraHome.setScriptsExecutable(new File(getTomcatHome(), "bin")); }
@Test public void testUnzip() throws Exception { FileInputStream fis = new FileInputStream(ZIP_FILE); Zip.unzip(fis, TMP_DIR); FileReader fr = new FileReader(TMP_DIR + File.separator + "foo" + File.separator + "foo.txt"); BufferedReader buff = new BufferedReader(fr); boolean eof = false; while (!eof) { String line = buff.readLine(); if (line == null) { eof = true; } else { assertEquals("foo", line); } } buff.close(); } }