public static FileInputStream fileInputStream( File file, String operation ) throws ArchiverException { try { return new FileInputStream( file ); } catch ( IOException e ) { throw new ArchiverException( "Problem reading input file for " + operation + " " + file.getParent() + ", " + e.getMessage() ); } }
public static FileOutputStream fileOutputStream( File file, String operation ) throws ArchiverException { try { return new FileOutputStream( file ); } catch ( IOException e ) { throw new ArchiverException( "Problem creating output file for " + operation + " " + file.getParent() + ", " + e.getMessage() ); } }
public static @Nonnull XZCompressorInputStream getXZInputStream( InputStream in ) throws ArchiverException { try { return new XZCompressorInputStream( in ); } catch ( IOException ioe ) { throw new ArchiverException( "Trouble creating BZIP2 compressor, invalid file ?", ioe ); } }
private InputStream getGzipInputStream( FileInputStream in ) throws ArchiverException { try { return Streams.bufferedInputStream( new GZIPInputStream( in ) ); } catch ( IOException e ) { throw new ArchiverException( "Problem creating GZIP input stream", e ); } }
private Manifest getManifest( InputStream is ) throws ArchiverException { try { return new Manifest( is ); } catch ( IOException e ) { throw new ArchiverException( "Unable to read manifest file" + " (" + e.getMessage() + ")", e ); } }
/** * File to incorporate as application.xml. */ public void setAppxml( File descr ) throws ArchiverException { deploymentDescriptor = descr; if ( !deploymentDescriptor.exists() ) { throw new ArchiverException( "Deployment descriptor: " + deploymentDescriptor + " does not exist." ); } addFile( descr, "META-INF/application.xml" ); }
/** * set the deployment descriptor to use (WEB-INF/web.xml); * required unless <tt>update=true</tt> */ public void setWebxml( File descr ) throws ArchiverException { deploymentDescriptor = descr; if ( !deploymentDescriptor.exists() ) { throw new ArchiverException( "Deployment descriptor: " + deploymentDescriptor + " does not exist." ); } addFile( descr, "WEB-INF" + File.separatorChar + "web.xml" ); }
public static @Nonnull SnappyInputStream getSnappyInputStream( InputStream bis ) throws ArchiverException { try { return new SnappyInputStream( bis ); } catch ( IOException e ) { throw new ArchiverException( "Trouble creating Snappy compressor, invalid file ?", e ); } }
public static @Nonnull BZip2CompressorInputStream getBZip2InputStream( InputStream bis ) throws ArchiverException { try { // Note that bis must be buffered for performance. Does not need buffering around BZip2CompressorInputStream return new BZip2CompressorInputStream( bis ); } catch ( IOException e ) { throw new ArchiverException( "Trouble creating BZIP2 compressor, invalid file ?", e ); } }
@Override public void close() { try { if ( this.xzOut != null ) { this.xzOut.close(); xzOut = null; } } catch ( final IOException e ) { throw new ArchiverException( "Failure closing target.", e ); } }
@Override public void close() { try { if ( this.zOut != null ) { this.zOut.close(); zOut = null; } } catch ( final IOException e ) { throw new ArchiverException( "Failure closing target.", e ); } }
@Override public void close() { try { if ( this.zOut != null ) { this.zOut.close(); zOut = null; } } catch ( final IOException e ) { throw new ArchiverException( "Failure closing target.", e ); } }
public static ArchiveEntry createDirectoryEntry( String target, final File file, int permissions, int defaultDirMode1 ) throws ArchiverException, IOException { if ( !file.isDirectory() ) { throw new ArchiverException( "Not a directory: " + file ); } final PlexusIoResource res = createResource( file ); return new ArchiveEntry( target, res, DIRECTORY, permissions, null, defaultDirMode1 ); }
@Override protected void initZipOutputStream( ConcurrentJarCreator zOut ) throws ArchiverException, IOException { // If no webxml file is specified, it's an error. if ( deploymentDescriptor == null && !isInUpdateMode() ) { throw new ArchiverException( "appxml attribute is required" ); } super.initZipOutputStream( zOut ); }
/** * override of parent; validates configuration * before initializing the output stream. * * @param zOut */ @Override protected void initZipOutputStream( ConcurrentJarCreator zOut ) throws ArchiverException, IOException { // If no webxml file is specified, it's an error. if ( expectWebXml && deploymentDescriptor == null && !isInUpdateMode() ) { throw new ArchiverException( "webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)" ); } super.initZipOutputStream( zOut ); }
public static void chmod( final File file, final int mode ) throws ArchiverException { if ( !Os.isFamily( Os.FAMILY_UNIX ) ) { return; } try { AttributeUtils.chmod( file, mode ); } catch ( IOException e ) { throw new ArchiverException( "Failed setting file attributes", e ); } }
public static void copyFully( @WillClose InputStream zIn, @WillClose OutputStream out, String gzip ) throws ArchiverException { // There must be 1 million libs out there that do this try { copyFullyDontCloseOutput( zIn, out, gzip ); out.close(); out = null; } catch ( final IOException e ) { throw new ArchiverException( "Failure copying.", e ); } finally { IOUtil.close( out ); } }
public static ArchiveEntry createFileEntry( String target, PlexusIoResource resource, int permissions, PlexusIoResourceCollection collection, int defaultDirectoryPermissions ) throws ArchiverException { if ( resource.isDirectory() ) { throw new ArchiverException( "Not a file: " + resource.getName() ); } final int type = resource.isSymbolicLink() ? SYMLINK : FILE; return new ArchiveEntry( target, resource, type, permissions, collection, defaultDirectoryPermissions ); }
@Override public void compress() throws ArchiverException { try { xzOut = new XZCompressorOutputStream( bufferedOutputStream( fileOutputStream( getDestFile() ) ) ); compress( getSource(), xzOut ); } catch ( IOException ioe ) { throw new ArchiverException( "Problem creating xz " + ioe.getMessage(), ioe ); } }
private Iterator<PlexusIoResource> getFiles(final File contentDirectory) throws IOException { if (!contentDirectory.isDirectory()) { throw new ArchiverException(contentDirectory.getAbsolutePath() + " is not a directory."); } final PlexusIoFileResourceCollection collection = new PlexusIoFileResourceCollection(); collection.setIncludes(getIncludes()); collection.setExcludes(getExcludes()); collection.setBaseDir(contentDirectory); collection.setIncludingEmptyDirectories(false); collection.setPrefix(""); collection.setUsingDefaultExcludes(true); return collection.getResources(); }