Skip to content

Commit 1629a43

Browse files
committed
refs #61 - added a convenience method for checking for all bag warnings in the bag linter
1 parent b0eea3b commit 1629a43

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/gov/loc/repository/bagit/conformance/BagLinter.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.nio.file.Path;
1010
import java.text.Normalizer;
1111
import java.util.Collection;
12+
import java.util.Collections;
1213
import java.util.HashSet;
1314
import java.util.List;
1415
import java.util.Set;
@@ -48,6 +49,26 @@ public BagLinter(final BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping
4849
reader = new BagReader(nameMapping);
4950
}
5051

52+
/**
53+
* The BagIt specification is very flexible in what it allows which leads to situations
54+
* where something may be technically allowed, but should be discouraged.
55+
* This method checks a bag for potential problems, or other items that are allowed but discouraged.
56+
* This <strong>does not</strong> validate a bag. See {@link BagVerifier} instead.
57+
*
58+
* @param rootDir the root directory of the bag
59+
*
60+
* @return a set of {@link BagitWarning} detailing all items that should be fixed.
61+
*
62+
* @throws InvalidBagMetadataException if the bag metadata does not conform to the bagit specification
63+
* @throws UnparsableVersionException if there is an error reading the bagit version
64+
* @throws IOException if there was an error reading a file
65+
* @throws UnsupportedAlgorithmException if the {@link BagReader} does not support reading the manifest
66+
* @throws MaliciousPathException If the manifest was crafted to try and access a file outside the bag directory
67+
*/
68+
public Set<BagitWarning> lintBag(final Path rootDir) throws IOException, UnparsableVersionException, InvalidBagMetadataException, MaliciousPathException, UnsupportedAlgorithmException{
69+
return this.lintBag(rootDir, Collections.emptyList());
70+
}
71+
5172
/**
5273
* The BagIt specification is very flexible in what it allows which leads to situations
5374
* where something may be technically allowed, but should be discouraged.

0 commit comments

Comments
 (0)