Class AbstractZipArchiver

  • All Implemented Interfaces:
    Archiver, FinalizerEnabled, org.codehaus.plexus.logging.LogEnabled, org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
    Direct Known Subclasses:
    ZipArchiver

    public abstract class AbstractZipArchiver
    extends AbstractArchiver
    • Field Detail

      • archiveType

        protected java.lang.String archiveType
      • entries

        protected final java.util.Hashtable<java.lang.String,​java.lang.String> entries
      • addedDirs

        protected final AddedDirs addedDirs
      • doubleFilePass

        protected boolean doubleFilePass
      • skipWriting

        protected boolean skipWriting
      • addingNewFiles

        protected boolean addingNewFiles
        true when we are adding new files into the Zip file, as opposed to adding back the unchanged files
      • zipArchiveOutputStream

        protected org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream zipArchiveOutputStream
    • Constructor Detail

      • AbstractZipArchiver

        public AbstractZipArchiver()
    • Method Detail

      • getComment

        public java.lang.String getComment()
      • setComment

        public void setComment​(java.lang.String comment)
      • getEncoding

        public java.lang.String getEncoding()
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
      • setCompress

        public void setCompress​(boolean compress)
      • isCompress

        public boolean isCompress()
      • isRecompressAddedZips

        public boolean isRecompressAddedZips()
      • setRecompressAddedZips

        public void setRecompressAddedZips​(boolean recompressAddedZips)
      • setUpdateMode

        public void setUpdateMode​(boolean update)
      • isInUpdateMode

        public boolean isInUpdateMode()
      • setFilesonly

        public void setFilesonly​(boolean f)
        If true, emulate Sun's jar utility by not adding parent directories; optional, defaults to false.
        Parameters:
        f - true to emilate sun jar utility
      • isFilesonly

        public boolean isFilesonly()
      • zipFile

        protected void zipFile​(org.apache.commons.compress.parallel.InputStreamSupplier in,
                               ConcurrentJarCreator zOut,
                               java.lang.String vPath,
                               long lastModified,
                               java.io.File fromArchive,
                               int mode,
                               java.lang.String symlinkDestination,
                               boolean addInParallel)
                        throws java.io.IOException,
                               ArchiverException
        Adds a new entry to the archive, takes care of duplicates as well.
        Parameters:
        in - the stream to read data for the entry from.
        zOut - the stream to write to.
        vPath - the name this entry shall have in the archive.
        lastModified - last modification time for the entry.
        fromArchive - the original archive we are copying this
        symlinkDestination -
        addInParallel - Indicates if the entry should be add in parallel. If set to false it is added synchronously. If the entry is symbolic link this parameter is ignored.
        Throws:
        java.io.IOException
        ArchiverException
      • zipFile

        protected void zipFile​(ArchiveEntry entry,
                               ConcurrentJarCreator zOut,
                               java.lang.String vPath)
                        throws java.io.IOException,
                               ArchiverException
        Method that gets called when adding from java.io.File instances.

        This implementation delegates to the six-arg version.

        Parameters:
        entry - the file to add to the archive
        zOut - the stream to write to
        vPath - the name this entry shall have in the archive
        Throws:
        java.io.IOException
        ArchiverException
      • zipDir

        protected void zipDir​(org.codehaus.plexus.components.io.resources.PlexusIoResource dir,
                              ConcurrentJarCreator zOut,
                              java.lang.String vPath,
                              int mode,
                              java.lang.String encodingToUse)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • createInputStreamSupplier

        protected org.apache.commons.compress.parallel.InputStreamSupplier createInputStreamSupplier​(java.io.InputStream inputStream)
      • createEmptyZip

        protected boolean createEmptyZip​(java.io.File zipFile)
                                  throws ArchiverException
        Create an empty zip file
        Parameters:
        zipFile - The file
        Returns:
        true for historic reasons
        Throws:
        ArchiverException
      • cleanUp

        protected void cleanUp()
                        throws java.io.IOException
        Do any clean up necessary to allow this instance to be used again.

        When we get here, the Zip file has been closed and all we need to do is to reset some globals.

        This method will only reset globals that have been changed during execute(), it will not alter the attributes or nested child elements. If you want to reset the instance so that you can later zip a completely different set of files, you must use the reset method.

        Overrides:
        cleanUp in class AbstractArchiver
        Throws:
        java.io.IOException
        See Also:
        reset()
      • reset

        public void reset()
        Makes this instance reset all attributes to their default values and forget all children.
        See Also:
        cleanUp()
      • revert

        protected boolean revert​(java.lang.StringBuffer messageBuffer)
        Overrides:
        revert in class AbstractArchiver
      • close

        protected void close()
                      throws java.io.IOException
        Specified by:
        close in class AbstractArchiver
        Throws:
        java.io.IOException
      • normalizeLastModifiedDate

        protected java.util.Date normalizeLastModifiedDate​(java.util.Date lastModifiedDate)
        Description copied from class: AbstractArchiver
        Normalize last modified time value to get reproducible archive entries, based on archive binary format (tar uses UTC timestamp but zip uses local time then requires tweaks to make the value reproducible whatever the current timezone is).
        Overrides:
        normalizeLastModifiedDate in class AbstractArchiver
        Returns: