Package org.codehaus.plexus.archiver

Examples of org.codehaus.plexus.archiver.ArchiverException


                    manifest = getManifest( file );
                }
            }
            catch ( UnsupportedEncodingException e )
            {
                throw new ArchiverException( "Unsupported encoding while reading "
                                             + "manifest: " + e.getMessage(), e );
            }
        }
        else if ( filesetManifestConfig != null
                  && !filesetManifestConfig.getValue().equals( "skip" ) )
        {
            // we add this to our group of fileset manifests
            getLogger().debug( "Found manifest to merge in file " + file );

            try
            {
                Manifest newManifest;
                if ( is != null )
                {
                    InputStreamReader isr;
                    if ( manifestEncoding == null )
                    {
                        isr = new InputStreamReader( is );
                    }
                    else
                    {
                        isr = new InputStreamReader( is, manifestEncoding );
                    }
                    newManifest = getManifest( isr );
                }
                else
                {
                    newManifest = getManifest( file );
                }

                if ( filesetManifest == null )
                {
                    filesetManifest = newManifest;
                }
                else
                {
                    filesetManifest.merge( newManifest );
                }
            }
            catch ( UnsupportedEncodingException e )
            {
                throw new ArchiverException( "Unsupported encoding while reading "
                                             + "manifest: " + e.getMessage(), e );
            }
            catch ( ManifestException e )
            {
                getLogger().error( "Manifest in file " + file + " is invalid: "
                                   + e.getMessage() );
                throw new ArchiverException( "Invalid Manifest", e );
            }
        }
        else
        {
            // assuming 'skip' otherwise
View Full Code Here


            initZipOutputStream( zOut );
            finalizeZipOutputStream( zOut );
        }
        catch ( IOException ioe )
        {
            throw new ArchiverException( "Could not create almost empty JAR archive"
                                         + " (" + ioe.getMessage() + ")", ioe );
        }
        finally
        {
            // Close the output stream.
View Full Code Here

                while ( count != -1 );
            }
            catch ( IOException ioe )
            {
                String msg = "Problem expanding gzip " + ioe.getMessage();
                throw new ArchiverException( msg, ioe );
            }
            finally
            {
                IOUtil.close( fis );
                IOUtil.close( out );
View Full Code Here

        ResourceIterator iter = getResources();
        ArchiveEntry entry = iter.next();
        if ( iter.hasNext() )
        {
            throw new ArchiverException( "There is more than one file in input." );
        }
        compressor.setSource( entry.getResource() );
        compressor.setDestFile( getDestFile() );
        compressor.compress();
    }
View Full Code Here

                fis = new FileInputStream( getSourceFile() );
                bis = new BufferedInputStream( fis );
                zIn = getBZip2InputStream( bis );
                if ( zIn == null )
                {
                    throw new ArchiverException( getSourceFile().getAbsolutePath() + " is an invalid bz2 file." );
                }
                byte[] buffer = new byte[8 * 1024];
                int count = 0;
                do
                {
                    out.write( buffer, 0, count );
                    count = zIn.read( buffer, 0, buffer.length );
                }
                while ( count != -1 );
            }
            catch ( IOException ioe )
            {
                String msg = "Problem expanding bzip2 " + ioe.getMessage();
                throw new ArchiverException( msg, ioe );
            }
            finally
            {
                IOUtil.close( bis );
                IOUtil.close( fis );
View Full Code Here

            compress( getSource(), zOut );
        }
        catch ( IOException ioe )
        {
            String msg = "Problem creating bzip2 " + ioe.getMessage();
            throw new ArchiverException( msg, ioe );
        }
    }
View Full Code Here

            compress( getSource(), zOut );
        }
        catch ( IOException ioe )
        {
            String msg = "Problem creating gzip " + ioe.getMessage();
            throw new ArchiverException( msg, ioe );
        }
    }
View Full Code Here

        ResourceIterator iter = getResources();
        ArchiveEntry entry = iter.next();
        if ( iter.hasNext() )
        {
            throw new ArchiverException( "There is more than one file in input." );
        }
        compressor.setSource( entry.getResource() );
        compressor.setDestFile( getDestFile() );
        compressor.compress();
    }
View Full Code Here

                logger.warn( "Standard output:" );
                logger.warn( "-------------------------------" );
                logger.warn( stdout.getOutput() );
                logger.warn( "-------------------------------" );

                throw new ArchiverException( "chmod exit code was: " + exitCode );
            }
        }
        catch ( final CommandLineException e )
        {
            throw new ArchiverException( "Error while executing chmod.", e );
        }

    }
View Full Code Here

        }

        ResourceIterator iter = getResources();
        if ( !iter.hasNext() )
        {
            throw new ArchiverException( "You must set at least one file." );
        }

        File tarFile = getDestFile();

        if ( tarFile == null )
        {
            throw new ArchiverException( "You must set the destination tar file." );
        }
        if ( tarFile.exists() && !tarFile.isFile() )
        {
            throw new ArchiverException( tarFile + " isn't a file." );
        }
        if ( tarFile.exists() && !tarFile.canWrite() )
        {
            throw new ArchiverException( tarFile + " is read-only." );
        }

        getLogger().info( "Building tar: " + tarFile.getAbsolutePath() );

        tOut = new TarOutputStream(
            compression.compress( new BufferedOutputStream( new FileOutputStream( tarFile ) ) ) );
        tOut.setDebug( true );
        if ( longFileMode.isTruncateMode() )
        {
            tOut.setLongFileMode( TarOutputStream.LONGFILE_TRUNCATE );
        }
        else if ( longFileMode.isFailMode() || longFileMode.isOmitMode() )
        {
            tOut.setLongFileMode( TarOutputStream.LONGFILE_ERROR );
        }
        else
        {
            // warn or GNU
            tOut.setLongFileMode( TarOutputStream.LONGFILE_GNU );
        }

        longWarningGiven = false;
        while ( iter.hasNext() )
        {
            ArchiveEntry entry = iter.next();
            // Check if we don't add tar file in inself
            if ( ResourceUtils.isSame( entry.getResource(), tarFile ) )
            {
                throw new ArchiverException( "A tar file cannot include itself." );
            }
            String fileName = entry.getName();
            String name = StringUtils.replace( fileName, File.separatorChar, '/' );

            tarFile( entry, tOut, name );
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.archiver.ArchiverException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.