Class BagItWriter
java.lang.Object
io.goobi.viewer.model.export.bagit.BagItWriter
Minimal, dependency-free writer for BagIt bags, serialized as a ZIP.
The caller assembles the payload into <bagRoot>/data/… (arbitrary sub-directory structure) and then calls
writeZippedBag(Path, Path, Map, Integer). This class then:
- writes
bagit.txt(version + encoding declaration), - computes a SHA-512 digest for every payload file and writes
manifest-sha512.txt, - writes
bag-info.txt(the supplied metadata plus a computedPayload-OxumandBag-Size), - writes
tagmanifest-sha512.txtover the tag files, - serializes the whole bag into a ZIP whose single top-level directory is the bag name.
All file I/O is streamed, so bags containing large binary media are handled without loading files into memory. Payload checksums are computed in a single pass while reading each file.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidFinalizes the bag rooted atbagRoot(which must already contain a populateddata/directory) by writing its tag files and manifests, then serializes it intotargetZip.
-
Field Details
-
BAGIT_VERSION
BagIt version declared inbagit.txt.- See Also:
-
ALGORITHM
Checksum algorithm used for both the payload manifest and the tag manifest.- See Also:
-
-
Method Details
-
writeZippedBag
public static void writeZippedBag(Path bagRoot, Path targetZip, Map<String, String> bagInfo, Integer compressionLevel) throws IOExceptionFinalizes the bag rooted atbagRoot(which must already contain a populateddata/directory) by writing its tag files and manifests, then serializes it intotargetZip.- Parameters:
bagRoot- the bag root directory containing adata/payload sub-directorytargetZip- the ZIP file to create (parent directories must exist)bagInfo- ordered metadata entries forbag-info.txt(e.g. Source-Organization, External-Description); may be nullcompressionLevel- ZIP compression level 0-9, or null for the default; use a low value for already-compressed media payloads- Throws:
IOException- on any I/O error
-