Package org.archive.wayback.core

Examples of org.archive.wayback.core.CaptureSearchResult


    Date minMonth = addMonth(cur,-1);
    Date addYear = addYear(cur,1);
    Date addMonth = addMonth(cur,1);
    Iterator<CaptureSearchResult> itr = results.iterator();
    while(itr.hasNext()) {
      CaptureSearchResult result = itr.next();
      Date d = result.getCaptureDate();
      if(d.compareTo(cur) < 0) {
        prevResult = result;
        if(d.compareTo(minMonth) < 0) {
          monthPrevResult = result;
        }
View Full Code Here


  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;
View Full Code Here

    }
  }
 
  // Single place to do the flex cdx-line parsing logic
  public static CaptureSearchResult parseCDXLineFlex(String line) {
    CaptureSearchResult result = new CaptureSearchResult();
    return parseCDXLineFlex(line, result);
  }
View Full Code Here

    return parseCDXLineFlex(line, result);
  }
 
  // Use FastCaptureSearchResult to
  public static CaptureSearchResult parseCDXLineFlexFast(String line) { 
    CaptureSearchResult result = new FastCaptureSearchResult();
    return parseCDXLineFlex(line, result);
  }
View Full Code Here

   *         parsed according the the specification for this CDXFormat
   * @throws CDXFormatException
   */
  public CaptureSearchResult parseResult(String line)
  throws CDXFormatException {
    CaptureSearchResult result = new CaptureSearchResult();
    String[] parts = line.split(delimiterS);

    if(parts.length != fields.length) {
      throw new CDXFormatException("Wrong number of fields");
    }
View Full Code Here

implements ClosestResultSelector {

  public CaptureSearchResult getClosest(WaybackRequest wbRequest,
      CaptureSearchResults results) throws BetterRequestException {

    CaptureSearchResult closest = results.getClosest();
    String reqDateStr = wbRequest.getReplayTimestamp();
    String resDateStr = closest.getCaptureTimestamp();
   
    boolean doRedirect = false;
   
    // if the request date is shorter than the result date, always redirect:
    if(reqDateStr.length() < resDateStr.length()) {
View Full Code Here

        return input;
      }
    }
   
    if (urlScope != null) {
      CaptureSearchResult result = context.getCaptureSearchResult();
      if (result != null && !result.getUrlKey().contains(urlScope)) {
        return input;
      }
    }
   
    if (pattern == null) {
View Full Code Here

   
    for (Rule rule : rules) {
     
      // Check urlScope
      if (rule.urlkeyContains != null) {
        CaptureSearchResult result = context.getCaptureSearchResult();
        if ((result != null) && !result.getUrlKey().contains(rule.urlkeyContains)) {
          continue;
        }
      }
     
      int index = input.indexOf(rule.startAfter);
View Full Code Here

            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();
View Full Code Here

     
      String digest = result.getDigest();
     
      if (isRevisit) {
        if (!isReverse) {
          CaptureSearchResult payload = digestToOriginal.get(digest);
          if (payload != null) {
            result.flagDuplicateDigest(payload);
          } else {
            result.flagDuplicateDigest();
          }
View Full Code Here

TOP

Related Classes of org.archive.wayback.core.CaptureSearchResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.