Package org.fcrepo.persistence.common
Class MultiDigestInputStreamWrapper
- java.lang.Object
-
- org.fcrepo.persistence.common.MultiDigestInputStreamWrapper
-
public class MultiDigestInputStreamWrapper extends Object
Wrapper for an InputStream that allows for the computation and evaluation of multiple digests at once- Author:
- bbpennel
-
-
Constructor Summary
Constructors Constructor Description MultiDigestInputStreamWrapper(InputStream sourceStream, Collection<URI> digests, Collection<org.fcrepo.config.DigestAlgorithm> wantDigests)Construct a MultiDigestInputStreamWrapper
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckFixity()After consuming the inputstream, verify that all of the computed digests matched the provided digests.StringgetDigest(org.fcrepo.config.DigestAlgorithm alg)Get the digest calculated for the provided algorithmList<URI>getDigests()Returns the list of digests calculated for the wrapped InputStream Note: the wrapped InputStream will be consumed if it has not already been read.InputStreamgetInputStream()Get the InputStream wrapped to produce the requested digests
-
-
-
Constructor Detail
-
MultiDigestInputStreamWrapper
public MultiDigestInputStreamWrapper(InputStream sourceStream, Collection<URI> digests, Collection<org.fcrepo.config.DigestAlgorithm> wantDigests)
Construct a MultiDigestInputStreamWrapper- Parameters:
sourceStream- the original source input streamdigests- collection of digests for the input streamwantDigests- list of additional digest algorithms to compute for the input stream
-
-
Method Detail
-
getInputStream
public InputStream getInputStream()
Get the InputStream wrapped to produce the requested digests- Returns:
- wrapped input stream
-
checkFixity
public void checkFixity() throws org.fcrepo.kernel.api.exception.InvalidChecksumException
After consuming the inputstream, verify that all of the computed digests matched the provided digests. Note: the wrapped InputStream will be consumed if it has not already been read.- Throws:
org.fcrepo.kernel.api.exception.InvalidChecksumException- thrown if any of the digests did not match
-
getDigests
public List<URI> getDigests()
Returns the list of digests calculated for the wrapped InputStream Note: the wrapped InputStream will be consumed if it has not already been read.- Returns:
- list of digests calculated from the wrapped InputStream, in URN format.
-
-