/** * Do the work. * * @exception Exception Thrown in unrecoverable error. */ public void execute() throws Exception { expandFile( source, dest ); }
/** * Description of the Method */ protected void expandFile( final File srcF, final File dir ) throws Exception { ZipInputStream zis = null; try { // code from WarExpand zis = new ZipInputStream( new FileInputStream( srcF ) ); for ( ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry() ) { extractFile( srcF, dir, zis, ze.getName(), new Date( ze.getTime() ), ze.isDirectory() ); } // log("expand complete", Project.MSG_VERBOSE); zis.close(); zis = null; } catch ( IOException ioe ) { throw new Exception( "Error while expanding " + srcF.getPath(), ioe ); } finally { IOUtil.close( zis ); } }
protected void expand( File source, File outputDirectory, boolean overwrite ) throws DeploymentException { Expand expander = new Expand(); expander.setDest( outputDirectory ); expander.setOverwrite( overwrite ); expander.setSrc( source ); try { expander.execute(); } catch ( Exception e ) { throw new DeploymentException( "Unable to extract " + source + " to " + outputDirectory + ".", e ); } } }
@Override public void populateJenkinsHome(byte[] _template, boolean clean) throws IOException { try { if (clean && jenkinsHome.isDirectory()) { FileUtils.cleanDirectory(jenkinsHome); } if (!jenkinsHome.isDirectory() && ! jenkinsHome.mkdirs()) { throw new IOException("Could not create directory: " + jenkinsHome); } File template = File.createTempFile("template", ".dat"); try { FileUtils.writeByteArrayToFile(template, _template); Expand expand = new Expand(); expand.setSrc(template); expand.setOverwrite(true); expand.setDest(jenkinsHome); expand.execute(); } finally { template.delete(); } } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
Expand ex = new Expand(); ex.setDest( serviceDir ); ex.setOverwrite( false ); ex.setSrc( jar ); ex.execute();
/** * Do the work. * * @exception Exception Thrown in unrecoverable error. */ public void execute() throws Exception { expandFile( source, dest ); }
extractFile( srcF, dir, zis, ze.getName(),
Expand expander = new Expand(); expander.setDest( dest ); expander.setOverwrite( false ); expander.setSrc( file ); expander.execute();