public String serialize(CaptureSearchResult result) { String r = result.getHttpCode(); return r == null ? DEFAULT_VALUE : r; } }
public String serialize(CaptureSearchResult result) { String r = result.getHttpCode(); return r == null ? DEFAULT_VALUE : r; } }
public int filterObject(CaptureSearchResult o) { String code = o.getHttpCode(); if(excludes != null) { if(excludes.containsKey(code)) { return FILTER_EXCLUDE; } } if(includes != null) { if(!includes.containsKey(code)) { return FILTER_EXCLUDE; } } return FILTER_INCLUDE; } }
public int filterObject(CaptureSearchResult o) { String code = o.getHttpCode(); if(excludes != null) { if(excludes.containsKey(code)) { return FILTER_EXCLUDE; } } if(includes != null) { if(!includes.containsKey(code)) { return FILTER_EXCLUDE; } } return FILTER_INCLUDE; } }
@Override public boolean canHandle(WaybackRequest wbRequest, CaptureSearchResult result, Resource httpHeadersResource, Resource payloadResource) { if (!wbRequest.isLiveWebRequest() && !wbRequest.hasMementoAcceptDatetime()) { String code = result.getHttpCode(); if ((code != null) && code.startsWith("3")) { return true; } } return false; } }
@Override public boolean canHandle(WaybackRequest wbRequest, CaptureSearchResult result, Resource httpHeadersResource, Resource payloadResource) { if (!wbRequest.isLiveWebRequest() && !wbRequest.hasMementoAcceptDatetime()) { String code = result.getHttpCode(); if ((code != null) && code.startsWith("3")) { return true; } } return false; } }
@Override public int filterObject(CaptureSearchResult o) { if (timestampDedupLength <= 0) { return FILTER_INCLUDE; } String timestamp = o.getCaptureTimestamp(); timestamp = timestamp.substring(0, Math.min(timestampDedupLength, timestamp.length())); int httpCode = NumberUtils.toInt(o.getHttpCode(), WORST_HTTP_CODE); boolean isDupe = false; if ((lastTimestamp != null) && timestamp.equals(lastTimestamp)) { if (httpCode < bestHttpCode) { bestHttpCode = httpCode; } else { isDupe = true; } } else { bestHttpCode = httpCode; } lastTimestamp = timestamp; return isDupe ? FILTER_EXCLUDE : FILTER_INCLUDE; } }
@Override public int filterObject(CaptureSearchResult o) { if (timestampDedupLength <= 0) { return FILTER_INCLUDE; } String timestamp = o.getCaptureTimestamp(); timestamp = timestamp.substring(0, Math.min(timestampDedupLength, timestamp.length())); int httpCode = NumberUtils.toInt(o.getHttpCode(), WORST_HTTP_CODE); boolean isDupe = false; if ((lastTimestamp != null) && timestamp.equals(lastTimestamp)) { if (httpCode < bestHttpCode) { bestHttpCode = httpCode; } else { isDupe = true; } } else { bestHttpCode = httpCode; } lastTimestamp = timestamp; return isDupe ? FILTER_EXCLUDE : FILTER_INCLUDE; } }
/** * {@code true} if HTTP response code is either {@code 4xx} or {@code 5xx}. * @return */ public boolean isHttpError() { if (isRevisitDigest() && (getDuplicatePayload() != null)) { return getDuplicatePayload().isHttpError(); } String httpCode = getHttpCode(); return (httpCode.startsWith("4") || httpCode.startsWith("5")); }
/** * {@code true} if HTTP response code is either {@code 4xx} or {@code 5xx}. * @return */ public boolean isHttpError() { if (isRevisitDigest() && (getDuplicatePayload() != null)) { return getDuplicatePayload().isHttpError(); } String httpCode = getHttpCode(); return (httpCode.startsWith("4") || httpCode.startsWith("5")); }
sb.append(result.getMimeType()); sb.append(DELIMITER); sb.append(result.getHttpCode()); sb.append(DELIMITER); sb.append(result.getDigest());
/** * {@code true} if HTTP response code is {@code 2xx}. * @return */ public boolean isHttpSuccess() { if (isRevisitDigest() && (getDuplicatePayload() != null)) { return getDuplicatePayload().isHttpSuccess(); } String httpCode = getHttpCode(); return (httpCode.startsWith("2")); } }
/** * {@code true} if HTTP response code is {@code 3xx}. * @return */ public boolean isHttpRedirect() { if (isRevisitDigest() && (getDuplicatePayload() != null)) { return getDuplicatePayload().isHttpRedirect(); } String httpCode = getHttpCode(); return (httpCode.startsWith("3")); }
/** * {@code true} if HTTP response code is {@code 3xx}. * @return */ public boolean isHttpRedirect() { if (isRevisitDigest() && (getDuplicatePayload() != null)) { return getDuplicatePayload().isHttpRedirect(); } String httpCode = getHttpCode(); return (httpCode.startsWith("3")); }
/** * {@code true} if HTTP response code is {@code 2xx}. * @return */ public boolean isHttpSuccess() { if (isRevisitDigest() && (getDuplicatePayload() != null)) { return getDuplicatePayload().isHttpSuccess(); } String httpCode = getHttpCode(); return (httpCode.startsWith("2")); } }
@Override public void addTimegateHeaders( HttpServletResponse response, CaptureSearchResults results, WaybackRequest wbRequest, boolean includeOriginal) { MementoUtils.addTimegateHeaders(response, results, wbRequest, includeOriginal); // Add custom JSON header CaptureSearchResult result = results.getClosest(); JSONObject obj = new JSONObject(); JSONObject closestSnapshot = new JSONObject(); try { obj.put("wb_url", MementoUtils.getMementoPrefix(wbRequest.getAccessPoint()) + wbRequest.getAccessPoint().getUriConverter().makeReplayURI(result.getCaptureTimestamp(), wbRequest.getRequestUrl())); obj.put("timestamp", result.getCaptureTimestamp()); obj.put("status", result.getHttpCode()); closestSnapshot.put("closest", obj); } catch (JSONException je) { } String json = closestSnapshot.toString(); json = json.replace("\\/", "/"); response.setHeader("X-Link-JSON", json); }
@Override public void addTimegateHeaders( HttpServletResponse response, CaptureSearchResults results, WaybackRequest wbRequest, boolean includeOriginal) { MementoUtils.addTimegateHeaders(response, results, wbRequest, includeOriginal); // Add custom JSON header CaptureSearchResult result = results.getClosest(); JSONObject obj = new JSONObject(); JSONObject closestSnapshot = new JSONObject(); try { obj.put("wb_url", MementoUtils.getMementoPrefix(wbRequest.getAccessPoint()) + wbRequest.getAccessPoint().getUriConverter().makeReplayURI(result.getCaptureTimestamp(), wbRequest.getRequestUrl())); obj.put("timestamp", result.getCaptureTimestamp()); obj.put("status", result.getHttpCode()); closestSnapshot.put("closest", obj); } catch (JSONException je) { } String json = closestSnapshot.toString(); json = json.replace("\\/", "/"); response.setHeader("X-Link-JSON", json); }
public int filterObject(CaptureSearchResult r) { String httpCode = r.getHttpCode();
private int annotate(CaptureSearchResult o) { if(lastSeen == null) { // TODO: log missing record digest reference return FILTER_EXCLUDE; } o.setFile(lastSeen.getFile()); o.setOffset(lastSeen.getOffset()); o.setDigest(lastSeen.getDigest()); o.setHttpCode(lastSeen.getHttpCode()); o.setMimeType(lastSeen.getMimeType()); o.setRedirectUrl(lastSeen.getRedirectUrl()); o.flagDuplicateHTTP(lastSeen.getCaptureTimestamp()); return FILTER_INCLUDE; }
private int annotate(CaptureSearchResult o) { if(lastSeen == null) { // TODO: log missing record digest reference return FILTER_EXCLUDE; } o.setFile(lastSeen.getFile()); o.setOffset(lastSeen.getOffset()); o.setDigest(lastSeen.getDigest()); o.setHttpCode(lastSeen.getHttpCode()); o.setMimeType(lastSeen.getMimeType()); o.setRedirectUrl(lastSeen.getRedirectUrl()); o.flagDuplicateHTTP(lastSeen.getCaptureTimestamp()); return FILTER_INCLUDE; }