Repository navigation
Open
Labels
Description
Currently we throw an exception at the first problem we discover when verifying a bag:
bagit-java/src/main/java/gov/loc/repository/bagit/verify/BagVerifier.java
Lines 151 to 173 in 0e4f80b
| @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") | |
| void checkHashes(final Manifest manifest) throws CorruptChecksumException, InterruptedException, VerificationException{ | |
| final CountDownLatch latch = new CountDownLatch( manifest.getFileToChecksumMap().size()); | |
| //TODO maybe return all of these at some point... | |
| final Collection<Exception> exceptions = Collections.synchronizedCollection(new ArrayList<>()); | |
| for(final Entry<Path, String> entry : manifest.getFileToChecksumMap().entrySet()){ | |
| executor.execute(new CheckManifestHashesTask(entry, manifest.getAlgorithm().getMessageDigestName(), latch, exceptions)); | |
| } | |
| latch.await(); | |
| if(!exceptions.isEmpty()){ | |
| final Exception e = exceptions.iterator().next(); | |
| if(e instanceof CorruptChecksumException){ | |
| logger.debug(messages.getString("checksums_not_matching_error"), exceptions.size()); | |
| throw (CorruptChecksumException)e; | |
| } | |
| throw new VerificationException(e); | |
| } | |
| } |
Instead we should return a list of errors in the case that there is more than one problem with a bag and let the user of this library decide how to deal with them.
Activity