use of org.dcache.util.Checksums in project dcache by dCache.
the class AbstractXrootdRequestHandler method selectChecksum.
protected QueryResponse selectChecksum(ChecksumInfo info, Set<Checksum> checksums, QueryRequest msg) throws XrootdException {
if (!checksums.isEmpty()) {
/**
* xrdcp expects lower case names for checksum algorithms
* https://github.com/xrootd/xrootd/issues/459
* TODO: remove toLowerCase() call when above issue is addressed
*/
Optional<String> type = info.getType();
if (type.isPresent()) {
Optional<Checksum> result = checksums.stream().filter((c) -> type.get().equalsIgnoreCase(c.getType().getName())).findFirst();
if (result.isPresent()) {
Checksum checksum = result.get();
return new QueryResponse(msg, checksum.getType().getName().toLowerCase() + " " + checksum.getValue());
}
throw new XrootdException(kXR_Unsupported, "Checksum exists, " + "but not of the requested type.");
}
Checksum checksum = Checksums.preferredOrder().min(checksums);
return new QueryResponse(msg, checksum.getType().getName().toLowerCase() + " " + checksum.getValue());
}
throw new XrootdException(kXR_Unsupported, "No checksum available " + "for this file.");
}
Aggregations