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
AFile
that can be written to disk, alongside a secondFile
containing 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 String
CHECKSUM_FILE_SUFFIX
The 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 Path
buildChecksumPathForFile(Path file)
Constructs and returns the checksumPath
handle for a given file.protected byte[]
getBytesForChecksum()
Fetches the target bytes for computation of the checksum.static boolean
isChecksumFile(Path path)
Checks whether the given path translate to a checksum file.void
write()
Creates aFile
with nameWritable.getName()
on disk and writes thebytes
of thisFile
into 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:FileOnDisk
Creates aFile
with nameWritable.getName()
on disk and writes thebytes
of thisFile
into thatFile
.- Specified by:
write
in interfaceWritable<WritableOnDisk>
- Overrides:
write
in 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
-
-