public interface ChecksumPolicy
void validateChecksums() throws ChecksumFailureException { for (checksum : checksums) { switch (checksum.state) { case MATCH: if (policy.onChecksumMatch(...)) { return; } break; case MISMATCH: policy.onChecksumMismatch(...); break; case ERROR: policy.onChecksumError(...); break; } } policy.onNoMoreChecksums(); } void downloadFile() throws Exception { ... policy = newChecksumPolicy(); try { validateChecksums(); } catch (ChecksumFailureException e) { if (!policy.onTransferChecksumFailure(...)) { throw e; } } }Checksum policies might be stateful and are generally not thread-safe.
Modifier and Type | Field and Description |
---|---|
static int |
KIND_UNOFFICIAL
Bit flag indicating a checksum which is not part of the official repository layout/structure.
|
Modifier and Type | Method and Description |
---|---|
void |
onChecksumError(String algorithm,
int kind,
org.eclipse.aether.transfer.ChecksumFailureException exception)
Signals an error while computing the local checksum value or retrieving the checksum value from the remote
repository.
|
boolean |
onChecksumMatch(String algorithm,
int kind)
Signals a match between the locally computed checksum value and the checksum value declared by the remote
repository.
|
void |
onChecksumMismatch(String algorithm,
int kind,
org.eclipse.aether.transfer.ChecksumFailureException exception)
Signals a mismatch between the locally computed checksum value and the checksum value declared by the remote
repository.
|
void |
onNoMoreChecksums()
Signals that all available checksums have been processed.
|
boolean |
onTransferChecksumFailure(org.eclipse.aether.transfer.ChecksumFailureException exception)
Signals that (even after a potential retry) checksum validation has failed.
|
void |
onTransferRetry()
Signals that the download is being retried after a previously thrown
ChecksumFailureException that is
retry-worthy . |
static final int KIND_UNOFFICIAL
boolean onChecksumMatch(String algorithm, int kind)
algorithm
- The name of the checksum algorithm being used, must not be null
.kind
- A bit field providing further details about the checksum. See the KIND_*
constants in this
interface for possible bit flags.true
to accept the download as valid and stop further validation, false
to continue
validation with the next checksum.void onChecksumMismatch(String algorithm, int kind, org.eclipse.aether.transfer.ChecksumFailureException exception) throws org.eclipse.aether.transfer.ChecksumFailureException
algorithm
- The name of the checksum algorithm being used, must not be null
.kind
- A bit field providing further details about the checksum. See the KIND_*
constants in this
interface for possible bit flags.exception
- The exception describing the checksum mismatch, must not be null
.org.eclipse.aether.transfer.ChecksumFailureException
- If the checksum validation is to be failed. If the method returns normally,
validation continues with the next checksum.void onChecksumError(String algorithm, int kind, org.eclipse.aether.transfer.ChecksumFailureException exception) throws org.eclipse.aether.transfer.ChecksumFailureException
algorithm
- The name of the checksum algorithm being used, must not be null
.kind
- A bit field providing further details about the checksum. See the KIND_*
constants in this
interface for possible bit flags.exception
- The exception describing the checksum error, must not be null
.org.eclipse.aether.transfer.ChecksumFailureException
- If the checksum validation is to be failed. If the method returns normally,
validation continues with the next checksum.void onNoMoreChecksums() throws org.eclipse.aether.transfer.ChecksumFailureException
org.eclipse.aether.transfer.ChecksumFailureException
- If the checksum validation is to be failed. If the method returns normally, the
download is assumed to be valid.void onTransferRetry()
ChecksumFailureException
that is
retry-worthy
. Policies that maintain internal state will usually
have to reset some of this state at this point to prepare for a new round of validation.boolean onTransferChecksumFailure(org.eclipse.aether.transfer.ChecksumFailureException exception)
exception
- The exception that was thrown from a prior call to
onChecksumMismatch(String, int, ChecksumFailureException)
,
onChecksumError(String, int, ChecksumFailureException)
or onNoMoreChecksums()
.true
to accept the download nevertheless and let artifact resolution succeed, false
to
reject the transferred file as unusable.Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.