private CaptureSearchResult adaptInner(ARCRecord rec) throws IOException {
rec.close();
ARCRecordMetaData meta = rec.getMetaData();
CaptureSearchResult result = new CaptureSearchResult();
String arcName = meta.getArc();
int index = arcName.lastIndexOf(File.separator);
if (index > 0 && (index + 1) < arcName.length()) {
arcName = arcName.substring(index + 1);
}
result.setFile(arcName);
result.setOffset(meta.getOffset());
// initialize with default HTTP code...
result.setHttpCode("-");
result.setRedirectUrl("-");
// result.setDigest("sha1:"+rec.getDigestStr());
result.setDigest(rec.getDigestStr());
result.setCaptureTimestamp(meta.getDate());
String uriStr = meta.getUrl();
result.setOriginalUrl(uriStr);
if (uriStr.startsWith(ARCRecord.ARC_MAGIC_NUMBER)) {
result.setMimeType(ARC_FILEDESC_VERSION);
} else if (uriStr.startsWith(WaybackConstants.DNS_URL_PREFIX)) {
// skip URL + HTTP header processing for dns records...
result.setUrlKey(uriStr);
result.setMimeType("text/dns");
result.setCompressedLength(rec.compressedBytes);
} else {
result.setUrlKey(canonicalizer.urlStringToKey(uriStr));
String statusCode = (meta.getStatusCode() == null) ? "-" : meta
.getStatusCode();
result.setHttpCode(statusCode);
Header[] headers = rec.getHttpHeaders();
annotater.annotateHTTPContent(result, rec, headers, meta.getMimetype());
}
return result;