Class FileOnDiskWithChecksum
- java.lang.Object
-
- app.coronawarn.server.services.distribution.assembly.structure.WritableOnDisk
-
- app.coronawarn.server.services.distribution.assembly.structure.file.FileOnDisk
-
- app.coronawarn.server.services.distribution.assembly.structure.file.FileOnDiskWithChecksum
-
- All Implemented Interfaces:
File<WritableOnDisk>,Writable<WritableOnDisk>
- Direct Known Subclasses:
ArchiveOnDisk,TemporaryExposureKeyExportFile
public class FileOnDiskWithChecksum extends FileOnDisk
AFilethat can be written to disk, alongside a secondFilecontaining the hashsum of the actualFileOnDisk.
The checksum file resides in the same folder as the actual file, and will use the same file name with suffixCHECKSUM_FILE_SUFFIX.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCHECKSUM_FILE_SUFFIXThe file suffix for checksum files.
-
Constructor Summary
Constructors Constructor Description FileOnDiskWithChecksum(String name, byte[] bytes)Creates a new file on disk.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PathbuildChecksumPathForFile(Path file)Constructs and returns the checksumPathhandle for a given file.protected byte[]getBytesForChecksum()Fetches the target bytes for computation of the checksum.static booleanisChecksumFile(Path path)Checks whether the given path translate to a checksum file.voidwrite()Creates aFilewith nameWritable.getName()on disk and writes thebytesof thisFileinto thatFile.-
Methods inherited from class app.coronawarn.server.services.distribution.assembly.structure.file.FileOnDisk
getBytes, getRoot, prepare, setBytes
-
Methods inherited from class app.coronawarn.server.services.distribution.assembly.structure.WritableOnDisk
getFileOnDisk, getName, getParent, isArchive, isDirectory, isFile, setParent
-
-
-
-
Field Detail
-
CHECKSUM_FILE_SUFFIX
public static final String CHECKSUM_FILE_SUFFIX
The file suffix for checksum files.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileOnDiskWithChecksum
public FileOnDiskWithChecksum(String name, byte[] bytes)
Creates a new file on disk. A separate checksum will be generated automatically in the same folder.- Parameters:
name- the name of the filebytes- the content of the file
-
-
Method Detail
-
write
public void write()
Description copied from class:FileOnDiskCreates aFilewith nameWritable.getName()on disk and writes thebytesof thisFileinto thatFile.- Specified by:
writein interfaceWritable<WritableOnDisk>- Overrides:
writein classFileOnDisk
-
getBytesForChecksum
protected byte[] getBytesForChecksum()
Fetches the target bytes for computation of the checksum. Will take the bytes of itsFileOnDisk.- Returns:
- the checksum bytes
-
isChecksumFile
public static boolean isChecksumFile(Path path)
Checks whether the given path translate to a checksum file.- Parameters:
path- the path handle of the checksum file- Returns:
- true if it is a checksum file, false otherwise
-
-