Package org.appng.core.domain
Class PackageArchiveImpl
- java.lang.Object
-
- org.appng.core.domain.PackageArchiveImpl
-
- All Implemented Interfaces:
PackageArchive
public class PackageArchiveImpl extends Object implements PackageArchive
- Author:
- Matthias Herlitzius
-
-
Constructor Summary
Constructors Constructor Description PackageArchiveImpl(File archive, boolean strict)
PackageArchiveImpl(File archive, String originalFilename)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getBytes()
Returns the binary data of the archive's ZIP-file.String
getChecksum()
Returns the checksum for this archive (SHA256).File
getFile()
Returns the archive's ZIP-file.static String
getFileName(String applicationName, String applicationVersion, String applicationTimestamp)
String
getFilePrefix()
static String
getFilePrefix(String applicationName, String applicationVersion)
PackageInfo
getPackageInfo()
Returns aPackageInfo
unmarshalled from the archive's "application.xml".PackageType
getType()
Returns thePackageType
for thisPackageArchive
.boolean
isValid()
Checks whether this is a validPackageArchive
, meaning it's ZIP-file has a valid structure and contains a valid "application.xml".<T> T
processZipFile(ZipFileProcessor<T> processor)
Processes thePackageArchive
's ZIP-file with the givenZipFileProcessor
.String
toString()
-
-
-
Method Detail
-
processZipFile
public <T> T processZipFile(ZipFileProcessor<T> processor) throws IOException
Description copied from interface:PackageArchive
Processes thePackageArchive
's ZIP-file with the givenZipFileProcessor
.- Specified by:
processZipFile
in interfacePackageArchive
- Type Parameters:
T
- the return type of theZipFileProcessor
- Parameters:
processor
- aZipFileProcessor
- Returns:
- an object of type
<T>
- Throws:
IOException
-- if
ZipFileProcessor.process(org.apache.commons.compress.archivers.zip.ZipFile)
throws anIOException
- if the ZIP-file could not be read
- if
-
isValid
public boolean isValid()
Description copied from interface:PackageArchive
Checks whether this is a validPackageArchive
, meaning it's ZIP-file has a valid structure and contains a valid "application.xml".- Specified by:
isValid
in interfacePackageArchive
- Returns:
true
if this a validPackageArchive
,false
otherwise
-
getPackageInfo
public PackageInfo getPackageInfo()
Description copied from interface:PackageArchive
Returns aPackageInfo
unmarshalled from the archive's "application.xml". This methods returnsnull
, ifPackageArchive.isValid()
returnsfalse
.- Specified by:
getPackageInfo
in interfacePackageArchive
- Returns:
- a
PackageInfo
-
getFilePrefix
public String getFilePrefix()
-
getBytes
public byte[] getBytes() throws IOException
Description copied from interface:PackageArchive
Returns the binary data of the archive's ZIP-file. Should only be called ifPackageArchive.isValid()
returnstrue
.- Specified by:
getBytes
in interfacePackageArchive
- Returns:
- the binary data
- Throws:
IOException
- if the ZIP-file could not be read
-
getFile
public File getFile()
Description copied from interface:PackageArchive
Returns the archive's ZIP-file.- Specified by:
getFile
in interfacePackageArchive
- Returns:
- the file
-
getFilePrefix
public static String getFilePrefix(String applicationName, String applicationVersion)
-
getFileName
public static String getFileName(String applicationName, String applicationVersion, String applicationTimestamp)
-
getType
public PackageType getType()
Description copied from interface:PackageArchive
Returns thePackageType
for thisPackageArchive
.- Specified by:
getType
in interfacePackageArchive
- Returns:
- the
PackageType
-
getChecksum
public String getChecksum()
Description copied from interface:PackageArchive
Returns the checksum for this archive (SHA256).- Specified by:
getChecksum
in interfacePackageArchive
- Returns:
- the checksum
-
-