Working with the Library of Congress BagIt library, it is possible to create Bags on disk, using either symlinks or hardlinks to avoid duplicating large content files:

  1. Create a Bag directory with a subdirectory called data.

  2. In the data subdirectory, add hardlinks or symlinks to the content files.

  3. Using the BagIt library, create a PreBag object and call the makeBagInPlace method to write the manifest files required by the BagIt specification.

 

makebag.java
import java.io.File
import gov.loc.repository.bagit.Bag;
import gov.loc.repository.bagit.BagFactory;
import gov.loc.repository.bagit.PreBag;

/** Read a directory on disk with files in a data/ subdirectory and create a valid bag. */
public class makebag {
    public static void main( String[] args ) {
        File bagdir = new File(args[0]);
        PreBag preBag = new BagFactory().createPreBag(bagdir);
        Bag bag = preBag.makeBagInPlace(BagFactory.LATEST, false);
    }  
}
  • No labels