The BAGIT LIBRARY is a software library intended to support the creation, manipulation, and validation of bags. Its current version is 0.97. It is version aware with the earliest supported version being 0.93.
- Java 8
- gradle (for development only)
We no longer support a command line interface for the java version of bagit. If you would like a command line interface for bagging, verifying, and other actions please check out our bagit-python implementation or the ruby based implementation
We no longer support directly serializing a bag. But if that is something you require there are plenty of great libraries that offer this capability
We no longer support fetching. This is due to the various protocalls that could be involved. Again, if this is something you need, there are much better java libraries out there that you can use to fill this functionality.
The "new" bagit interface is very intuitive, but here are some easy to follow examples. Instead of returning messages like in the old interface, now it throws errors so you don't have to parse messages to understand what happened.
Path folder = Paths.get("FolderYouWantToBag");
StandardSupportedAlgorithms algorithm = StandardSupportedAlgorithms.MD5;
boolean includeHiddenFiles = false;
Bag bag = BagCreator.bagInPlace(folder, algorithm, includeHiddenFiles);
Path rootDir = Paths.get("RootDirectoryOfExistingBag");
BagReader reader = new BagReader();
Bag bag = reader.read(rootDir);
Path outputDir = Paths.get("WhereYouWantToWriteTheBagTo");
BagWriter.write(bag, outputDir); //where bag is a Bag object
boolean ignoreHiddenFiles = true;
BagVerifier verifier = new BagVerifier();
verifier.isComplete(bag, ignoreHiddenFiles);
boolean ignoreHiddenFiles = true;
BagVerifier verifier = new BagVerifier();
verifier.isValid(bag, ignoreHiddenFiles);
boolean ignoreHiddenFiles = true;
BagVerifier verifier = new BagVerifier();
if(verifier.canQuickVerify(bag)){
verifier.quicklyVerify(bag, ignoreHiddenFiles);
}
You only need to implement 2 interfaces
public class MyNewSupportedAlgorithm implements SupportedAlgorithm {
@Override
public String getMessageDigestName() {
return "SHA3-256";
}
@Override
public String getBagitName() {
return "sha3256";
}
}
public class MyNewNameMapping implements BagitAlgorithmNameToSupportedAlgorithmMapping {
@Override
public SupportedAlgorithm getMessageDigestName(String bagitAlgorithmName) {
if("sha3256".equals(bagitAlgorithmName)){
return new MyNewSupportedAlgorithm();
}
return StandardSupportedAlgorithms.valueOf(bagitAlgorithmName.toUpperCase());
}
}
and then add the implemented BagitAlgorithmNameToSupportedAlgorithmMapping class to your BagReader or bagVerifier object before using their methods
See the examples directory for examples of how to implement features that have been removed yourself.
Bagit-Java uses Gradle for its build system. Check out the great documentation to learn more.
Inside the bagit-java root directory, run gradle check
.
- Follow their guides
- http://central.sonatype.org/pages/releasing-the-deployment.html
- https://issues.sonatype.org/secure/Dashboard.jspa
- Once you have access, to create an office release and upload it you should specify the version by running
gradle -Pversion=<VERSION> uploadArchives
- Don't forget to tag the repository!
Simply run gradle eclipse
and it will automatically create a eclipse project for you that you can import.
- Further refine reading and writing of bags version 0.93-0.97
- Integrate new proposed specification we are calling "dot bagit"
- Fix bugs/issues reported with new library (on going)
- The Digital Curation Google Group (https://groups.google.com/d/forum/digital-curation) is an open discussion list that reaches many of the contributors to and users of this open-source project
- If you have found a bug please create a new issue on the issues page
- To contact a developer at the Library of Congress please email [email protected]
- If you would like to contribute, please submit a pull request