Class BigFileZipFactory
- java.lang.Object
-
- jetbrains.buildServer.zip.BigFileZipFactory
-
- All Implemented Interfaces:
ZipFactory
- Direct Known Subclasses:
DiskBasedCenZipFactory
,MemoryConservativeZipFactory
public class BigFileZipFactory extends Object
Regular zip factory.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMMONS_COMPRESS
If "teamcity.archive.zip.factory" is set to "commons-compress", this indicates thatBigFileZipFactory
should be used.static String
CONSERVATIVE
If "teamcity.archive.zip.factory" is set to "conservative", this indicates thatMemoryConservativeZipFactory
should be used.static String
DISK_BASED
If "teamcity.archive.zip.factory" is set to "disk-based", this indicates thatDiskBasedCenZipFactory
should be used.
-
Constructor Summary
Constructors Constructor Description BigFileZipFactory(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a new ZIP factory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ZipWriter
createZipArchive(String name)
Creates a zip archive.boolean
isFileExist(String name)
Checks whether the file exists.protected ZipReader
makeNewZipReader(File file)
protected ZipWriter
makeNewZipWriter(File file)
static BigFileZipFactory
newInstance(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a new dynamic ZIP factory.static BigFileZipFactory
newSharedInstance(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a shared dynamic ZIP factory.ZipReader
openZipArchive(String name)
Opens an existent zip archive to read.void
rename(String sourceName, String targetName)
Renames or moves the file.void
setLevel(int level)
Sets the compression level for entries which areZipEntry.DEFLATED
.String
toString()
-
-
-
Field Detail
-
CONSERVATIVE
@NonNls @NotNull public static final String CONSERVATIVE
If "teamcity.archive.zip.factory" is set to "conservative", this indicates that
MemoryConservativeZipFactory
should be used. This is the default behaviour since TeamCity 2018.1.- Since:
- 2017.2.4, 2018.1
- See Also:
newInstance(boolean, boolean)
,DISK_BASED
,COMMONS_COMPRESS
, Constant Field Values
-
DISK_BASED
@NonNls @NotNull public static final String DISK_BASED
If "teamcity.archive.zip.factory" is set to "disk-based", this indicates that
DiskBasedCenZipFactory
should be used.- Since:
- 2017.2.4, 2018.1
- See Also:
newInstance(boolean, boolean)
,CONSERVATIVE
,COMMONS_COMPRESS
, Constant Field Values
-
COMMONS_COMPRESS
@NonNls @NotNull public static final String COMMONS_COMPRESS
If "teamcity.archive.zip.factory" is set to "commons-compress", this indicates that
BigFileZipFactory
should be used. This used to be the default behaviour before TeamCity 2018.1.- Since:
- 2017.2.4, 2018.1
- See Also:
newInstance(boolean, boolean)
,CONSERVATIVE
,DISK_BASED
, Constant Field Values
-
-
Constructor Detail
-
BigFileZipFactory
public BigFileZipFactory(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a new ZIP factory. If you need a dynamic instance of the default Zip64 factory, use
newInstance(boolean, boolean)
instead.- Parameters:
autoCreateDirectories
- whether directories parent to the target ZIP file should be automatically created (only affectsZipFactory.createZipArchive(String)
behaviour).rewriteExistingFiles
- whether the target ZIP file should be silently overwritten if it exists (only affectsZipFactory.createZipArchive(String)
behaviour).- See Also:
newInstance(boolean, boolean)
-
-
Method Detail
-
newInstance
@NotNull public static BigFileZipFactory newInstance(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a new dynamic ZIP factory. The behaviour the factory returned is affected by "teamcity.archive.zip.factory" internal property (can be set to either one of "conservative", "disk-based" and "commons-compress").
The returned factory will support
ZipFactory.setLevel(int)
method.- Parameters:
autoCreateDirectories
- whether directories parent to the target ZIP file should be automatically created (only affectsZipFactory.createZipArchive(String)
behaviour).rewriteExistingFiles
- whether the target ZIP file should be silently overwritten if it exists (only affectsZipFactory.createZipArchive(String)
behaviour).- Returns:
- the newly-created ZIP factory.
- Since:
- 2017.2.4, 2018.1
- See Also:
CONSERVATIVE
,DISK_BASED
,COMMONS_COMPRESS
-
newSharedInstance
@NotNull public static BigFileZipFactory newSharedInstance(boolean autoCreateDirectories, boolean rewriteExistingFiles)
Creates a shared dynamic ZIP factory. The behaviour the factory returned is affected by "teamcity.archive.zip.factory" (can be set to either one of "conservative", "disk-based" and "commons-compress") and "teamcity.archive.zip.level" internal properties.
The returned factory will not support
ZipFactory.setLevel(int)
method.- Parameters:
autoCreateDirectories
- whether directories parent to the target ZIP file should be automatically created (only affectsZipFactory.createZipArchive(String)
behaviour).rewriteExistingFiles
- whether the target ZIP file should be silently overwritten if it exists (only affectsZipFactory.createZipArchive(String)
behaviour).- Returns:
- the newly-created ZIP factory.
- Since:
- 2017.2.4, 2018.1
- See Also:
CONSERVATIVE
,DISK_BASED
,COMMONS_COMPRESS
-
makeNewZipWriter
@NotNull protected ZipWriter makeNewZipWriter(@NotNull File file) throws IOException
- Throws:
IOException
-
makeNewZipReader
@NotNull protected final ZipReader makeNewZipReader(@NotNull File file) throws IOException
- Throws:
IOException
-
createZipArchive
@NotNull public final ZipWriter createZipArchive(@NotNull String name) throws IOException
Creates a zip archive.- Specified by:
createZipArchive
in interfaceZipFactory
- Parameters:
name
- path and name of a zip file to create.- Returns:
- zip writer.
- Throws:
IOException
- See Also:
ZipFactory.createZipArchive(String)
-
openZipArchive
public ZipReader openZipArchive(String name) throws IOException, IllegalStateException
Description copied from interface:ZipFactory
Opens an existent zip archive to read.- Specified by:
openZipArchive
in interfaceZipFactory
- Parameters:
name
- path and name of a zip file to create.- Returns:
- zip reader.
- Throws:
IOException
IllegalStateException
-
isFileExist
public boolean isFileExist(String name)
Description copied from interface:ZipFactory
Checks whether the file exists.- Specified by:
isFileExist
in interfaceZipFactory
- Parameters:
name
- file path and name.- Returns:
- exists.
-
rename
public void rename(String sourceName, String targetName) throws IOException
Description copied from interface:ZipFactory
Renames or moves the file.- Specified by:
rename
in interfaceZipFactory
- Parameters:
sourceName
- an existent file path and name to rename.targetName
- new path and name.- Throws:
IOException
- when couldn't rename.
-
setLevel
public final void setLevel(int level)
Sets the compression level for entries which are
ZipEntry.DEFLATED
. The default setting isDeflater.DEFAULT_COMPRESSION
.This method only affects
ZipFactory.createZipArchive(String)
behaviour.- Specified by:
setLevel
in interfaceZipFactory
- Parameters:
level
- the compression level (0-9).- See Also:
ZipFactory.setLevel(int)
-
toString
public final String toString()
- Overrides:
toString
in classObject
- Since:
- 2017.2.4, 2018.1
- See Also:
Object.toString()
-
-