use of org.apache.archiva.checksum.ChecksumReference in project archiva by apache.
the class ValidateChecksumConsumer method processFile.
@Override
public void processFile(String path) throws ConsumerException {
Path checksumFile = this.repositoryDir.resolve(path);
try {
ChecksumReference cf = ChecksummedFile.getFromChecksumFile(checksumFile);
if (!cf.getFile().isValidChecksum(cf.getAlgorithm(), true)) {
log.warn("The checksum for {} is invalid.", checksumFile);
triggerConsumerWarning(NOT_VALID_CHECKSUM, "The checksum for " + checksumFile + " is invalid.");
}
} catch (ChecksumValidationException e) {
if (e.getErrorType() == READ_ERROR) {
log.error("Checksum read error during validation on {}", checksumFile);
triggerConsumerError(CHECKSUM_IO_ERROR, "Checksum I/O error during validation on " + checksumFile);
} else if (e.getErrorType() == INVALID_FORMAT || e.getErrorType() == DIGEST_ERROR) {
log.error("Digester failure during checksum validation on {}", checksumFile);
triggerConsumerError(CHECKSUM_DIGESTER_FAILURE, "Digester failure during checksum validation on " + checksumFile);
} else if (e.getErrorType() == FILE_NOT_FOUND) {
log.error("File not found during checksum validation: ", e);
triggerConsumerError(CHECKSUM_NOT_FOUND, "File not found during checksum validation: " + e.getMessage());
}
}
}
Aggregations