use of org.commonjava.maven.galley.io.checksum.ChecksummingDecoratorAdvisor.ChecksumAdvice.CALCULATE_AND_WRITE in project indy by Commonjava.
the class DefaultGalleyStorageProvider method getChecksummingTransferDecorator.
private ChecksummingTransferDecorator getChecksummingTransferDecorator() {
ChecksummingDecoratorAdvisor readAdvisor = (transfer, op, eventMetadata) -> {
ChecksummingDecoratorAdvisor.ChecksumAdvice result = NO_DECORATE;
if (checksumAdvisors != null) {
for (IndyChecksumAdvisor advisor : checksumAdvisors) {
Optional<ChecksummingDecoratorAdvisor.ChecksumAdvice> advice = advisor.getChecksumReadAdvice(transfer, op, eventMetadata);
if (advice.isPresent()) {
ChecksummingDecoratorAdvisor.ChecksumAdvice checksumAdvice = advice.get();
if (checksumAdvice.ordinal() > result.ordinal()) {
result = checksumAdvice;
if (checksumAdvice == CALCULATE_AND_WRITE) {
break;
}
}
}
}
}
logger.debug("Advising {} for {} of: {}", result, op, transfer);
return result;
};
ChecksummingDecoratorAdvisor writeAdvisor = (transfer, op, eventMetadata) -> {
ChecksummingDecoratorAdvisor.ChecksumAdvice result = NO_DECORATE;
if (TransferOperation.GENERATE == op) {
result = CALCULATE_AND_WRITE;
} else if (checksumAdvisors != null) {
for (IndyChecksumAdvisor advisor : checksumAdvisors) {
Optional<ChecksummingDecoratorAdvisor.ChecksumAdvice> advice = advisor.getChecksumWriteAdvice(transfer, op, eventMetadata);
if (advice.isPresent()) {
ChecksummingDecoratorAdvisor.ChecksumAdvice checksumAdvice = advice.get();
if (checksumAdvice.ordinal() > result.ordinal()) {
result = checksumAdvice;
if (checksumAdvice == CALCULATE_AND_WRITE) {
break;
}
}
}
}
}
logger.debug("Advising {} for {} of: {}", result, op, transfer);
return result;
};
return new ChecksummingTransferDecorator(readAdvisor, writeAdvisor, specialPathManager, timerProviderFunction(), contentMetadataConsumer, new Md5GeneratorFactory(), new Sha1GeneratorFactory(), new Sha256GeneratorFactory());
}
Aggregations