use of org.apache.archiva.checksum.ChecksumValidationException 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());
}
}
}
use of org.apache.archiva.checksum.ChecksumValidationException in project archiva by apache.
the class LegacyToDefaultConverter method verifyChecksum.
private boolean verifyChecksum(Path file, String fileName, ChecksumAlgorithm digester, Artifact artifact, String key) throws IOException {
boolean result;
Path checksumFile = file.resolveSibling(fileName);
// We ignore the check, if the checksum file does not exist
if (!Files.exists(checksumFile)) {
return true;
}
ChecksummedFile csFile = new ChecksummedFile(file);
try {
result = csFile.isValidChecksum(digester, true);
} catch (ChecksumValidationException e) {
addWarning(artifact, Messages.getString(key));
result = false;
}
return result;
}
Aggregations