Package org.codehaus.plexus.archiver
Class AbstractUnArchiver
- java.lang.Object
-
- org.codehaus.plexus.archiver.AbstractUnArchiver
-
- All Implemented Interfaces:
FinalizerEnabled,UnArchiver
- Direct Known Subclasses:
AbstractZipUnArchiver,BZip2UnArchiver,GZipUnArchiver,SnappyUnArchiver,TarUnArchiver,XZUnArchiver,ZstdUnArchiver
public abstract class AbstractUnArchiver extends java.lang.Object implements UnArchiver, FinalizerEnabled
- Author:
- Emmanuel Venisse
-
-
Constructor Summary
Constructors Constructor Description AbstractUnArchiver()AbstractUnArchiver(java.io.File sourceFile)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddArchiveFinalizer(ArchiveFinalizer finalizer)protected voidcreateSymbolicLink(java.io.File link, java.io.File target)Creates a symbolic link.protected abstract voidexecute()protected abstract voidexecute(java.lang.String path, java.io.File outputDirectory)voidextract()Extract the archive.voidextract(java.lang.String path, java.io.File outputDirectory)Take a path into the archive and extract it to the specified directory.protected voidextractFile(java.io.File srcF, java.io.File dir, java.io.InputStream compressedInputStream, java.lang.String entryName, java.util.Date entryDate, boolean isDirectory, java.lang.Integer mode, java.lang.String symlinkDestination, org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers)java.io.FilegetDestDirectory()java.io.FilegetDestFile()org.codehaus.plexus.components.io.filemappers.FileMapper[]getFileMappers()Get chain of components which rewrite the target path of each unpacked file.org.codehaus.plexus.components.io.fileselectors.FileSelector[]getFileSelectors()Returns a set ofFileSelectorinstances, which may be used to select the files to extract from the archive.protected org.slf4j.LoggergetLogger()java.io.FilegetSourceFile()SymlinkFailureModegetSymlinkFailureMode()Returns what happens to a symbolic link entry that the file system refuses to create.booleanisIgnorePermissions()booleanisOverwrite()Gets a flag indicating destination files are always overwritten.protected booleanisSelected(java.lang.String fileName, org.codehaus.plexus.components.io.resources.PlexusIoResource fileInfo)booleanisUseJvmChmod()Deprecated.voidsetArchiveFinalizers(java.util.List<ArchiveFinalizer> archiveFinalizers)voidsetDestDirectory(java.io.File destDirectory)voidsetDestFile(java.io.File destFile)voidsetFileMappers(org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers)Sets chain of components to be used for rewriting target path of each unpacked file.voidsetFileSelectors(org.codehaus.plexus.components.io.fileselectors.FileSelector[] fileSelectors)Sets a set ofFileSelectorinstances, which may be used to select the files to extract from the archive.voidsetIgnorePermissions(boolean ignorePermissions)voidsetOverwrite(boolean b)Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?voidsetSourceFile(java.io.File sourceFile)voidsetSymlinkFailureMode(SymlinkFailureMode symlinkFailureMode)Sets what happens to a symbolic link entry that the file system refuses to create.protected voidsetTargetLastModified(java.io.File target, long millis)voidsetUseJvmChmod(boolean useJvmChmod)Deprecated.protected booleanshouldExtractEntry(java.io.File targetDirectory, java.io.File targetFileName, java.lang.String entryName, java.util.Date entryDate)protected voidvalidate()protected voidvalidate(java.lang.String path, java.io.File outputDirectory)
-
-
-
Method Detail
-
getLogger
protected org.slf4j.Logger getLogger()
-
getDestDirectory
public java.io.File getDestDirectory()
- Specified by:
getDestDirectoryin interfaceUnArchiver
-
setDestDirectory
public void setDestDirectory(java.io.File destDirectory)
- Specified by:
setDestDirectoryin interfaceUnArchiver
-
getDestFile
public java.io.File getDestFile()
- Specified by:
getDestFilein interfaceUnArchiver
-
setDestFile
public void setDestFile(java.io.File destFile)
- Specified by:
setDestFilein interfaceUnArchiver
-
getSourceFile
public java.io.File getSourceFile()
- Specified by:
getSourceFilein interfaceUnArchiver
-
setSourceFile
public void setSourceFile(java.io.File sourceFile)
- Specified by:
setSourceFilein interfaceUnArchiver
-
isOverwrite
public boolean isOverwrite()
Description copied from interface:UnArchiverGets a flag indicating destination files are always overwritten.- Specified by:
isOverwritein interfaceUnArchiver- Returns:
true, if destination files are overwritten, even if they are newer than the corresponding entry in the archive.
-
setOverwrite
public void setOverwrite(boolean b)
Description copied from interface:UnArchiverShould we overwrite files in dest, even if they are newer than the corresponding entries in the archive?- Specified by:
setOverwritein interfaceUnArchiver
-
getFileMappers
public org.codehaus.plexus.components.io.filemappers.FileMapper[] getFileMappers()
Description copied from interface:UnArchiverGet chain of components which rewrite the target path of each unpacked file.- Specified by:
getFileMappersin interfaceUnArchiver- Returns:
FileMappers to be used for rewriting each target path, ornullif no rewriting shall happen.
-
setFileMappers
public void setFileMappers(org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers)
Description copied from interface:UnArchiverSets chain of components to be used for rewriting target path of each unpacked file.- Specified by:
setFileMappersin interfaceUnArchiver- Parameters:
fileMappers-FileMapperto be used for rewriting each target path, ornullif no rewriting shall happen.
-
extract
public final void extract() throws ArchiverExceptionDescription copied from interface:UnArchiverExtract the archive.- Specified by:
extractin interfaceUnArchiver- Throws:
ArchiverException
-
extract
public final void extract(java.lang.String path, java.io.File outputDirectory) throws ArchiverExceptionDescription copied from interface:UnArchiverTake a path into the archive and extract it to the specified directory.- Specified by:
extractin interfaceUnArchiver- Parameters:
path- Path inside the archive to be extracted.outputDirectory- Directory to extract to.- Throws:
ArchiverException
-
addArchiveFinalizer
public void addArchiveFinalizer(ArchiveFinalizer finalizer)
- Specified by:
addArchiveFinalizerin interfaceFinalizerEnabled
-
setArchiveFinalizers
public void setArchiveFinalizers(java.util.List<ArchiveFinalizer> archiveFinalizers)
- Specified by:
setArchiveFinalizersin interfaceFinalizerEnabled
-
validate
protected void validate(java.lang.String path, java.io.File outputDirectory)
-
validate
protected void validate() throws ArchiverException- Throws:
ArchiverException
-
setFileSelectors
public void setFileSelectors(org.codehaus.plexus.components.io.fileselectors.FileSelector[] fileSelectors)
Description copied from interface:UnArchiverSets a set ofFileSelectorinstances, which may be used to select the files to extract from the archive. If file selectors are present, then a file is only extracted, if it is confirmed by all file selectors.- Specified by:
setFileSelectorsin interfaceUnArchiver
-
getFileSelectors
public org.codehaus.plexus.components.io.fileselectors.FileSelector[] getFileSelectors()
Description copied from interface:UnArchiverReturns a set ofFileSelectorinstances, which may be used to select the files to extract from the archive. If file selectors are present, then a file is only extracted, if it is confirmed by all file selectors.- Specified by:
getFileSelectorsin interfaceUnArchiver
-
isSelected
protected boolean isSelected(java.lang.String fileName, org.codehaus.plexus.components.io.resources.PlexusIoResource fileInfo) throws ArchiverException- Throws:
ArchiverException
-
execute
protected abstract void execute() throws ArchiverException- Throws:
ArchiverException
-
execute
protected abstract void execute(java.lang.String path, java.io.File outputDirectory) throws ArchiverException- Throws:
ArchiverException
-
isUseJvmChmod
@Deprecated public boolean isUseJvmChmod()
Deprecated.- Specified by:
isUseJvmChmodin interfaceUnArchiver- Returns:
- Since:
- 1.1
-
setUseJvmChmod
@Deprecated public void setUseJvmChmod(boolean useJvmChmod)
Deprecated.jvm chmod won't set group level permissions !- Specified by:
setUseJvmChmodin interfaceUnArchiver- Since:
- 1.1
-
isIgnorePermissions
public boolean isIgnorePermissions()
- Specified by:
isIgnorePermissionsin interfaceUnArchiver- Since:
- 1.1
-
setIgnorePermissions
public void setIgnorePermissions(boolean ignorePermissions)
- Specified by:
setIgnorePermissionsin interfaceUnArchiver- Since:
- 1.1
-
getSymlinkFailureMode
public SymlinkFailureMode getSymlinkFailureMode()
Description copied from interface:UnArchiverReturns what happens to a symbolic link entry that the file system refuses to create.- Specified by:
getSymlinkFailureModein interfaceUnArchiver- Returns:
- the failure mode;
SymlinkFailureMode.FAILunless the implementation supports another - Since:
- 4.15.0
-
setSymlinkFailureMode
public void setSymlinkFailureMode(SymlinkFailureMode symlinkFailureMode)
Description copied from interface:UnArchiverSets what happens to a symbolic link entry that the file system refuses to create.- Specified by:
setSymlinkFailureModein interfaceUnArchiver- Parameters:
symlinkFailureMode- the failure mode- Since:
- 4.15.0
-
extractFile
protected void extractFile(java.io.File srcF, java.io.File dir, java.io.InputStream compressedInputStream, java.lang.String entryName, java.util.Date entryDate, boolean isDirectory, java.lang.Integer mode, java.lang.String symlinkDestination, org.codehaus.plexus.components.io.filemappers.FileMapper[] fileMappers) throws java.io.IOException, ArchiverException- Throws:
java.io.IOExceptionArchiverException
-
createSymbolicLink
protected void createSymbolicLink(java.io.File link, java.io.File target) throws java.io.IOExceptionCreates a symbolic link. Visible for testing, so a test can simulate a file system that refuses links.- Parameters:
link- the link to createtarget- the link target as stored in the archive- Throws:
java.io.IOException- if the link cannot be created- Since:
- 4.15.0
-
shouldExtractEntry
protected boolean shouldExtractEntry(java.io.File targetDirectory, java.io.File targetFileName, java.lang.String entryName, java.util.Date entryDate) throws java.io.IOException- Throws:
java.io.IOException
-
setTargetLastModified
protected void setTargetLastModified(java.io.File target, long millis)
-
-