Package org.archive.wayback.core

Examples of org.archive.wayback.core.WaybackRequest


  /**
   * test of {@link EmbeddedCDXServerIndex#setBaseStatusRegexp(String)}
   * @throws Exception
   */
  public void testQueryWithCustomStatusFilter() throws Exception {
    WaybackRequest wbr = new WaybackRequest();
    wbr.setRequestUrl("http://example.com/");
    wbr.setCaptureQueryRequest();
   
    // urlkey, timestamp, original, mimetype, statuscode, digest, redirect, robotflags,
    // length, offset, filename.
    FieldSplitFormat fmt = CDXFieldConstants.CDX_ALL_NAMES;
    testCDXServer.cdxLines = new CDXLine[] {
View Full Code Here


   * {@link AuthToken#isIgnoreRobots()} flag is set.
   * @throws Exception
   */
  public void testIgnoreRobotPaths() throws Exception {
    cut.setIgnoreRobotPaths(Arrays.asList(new String[]{ "com,norobots" }));
    WaybackRequest wbr = new WaybackRequest();
    wbr.setRequestUrl("http://norobots.com/");
    wbr.setCaptureQueryRequest();
   
    // urlkey, timestamp, original, mimetype, statuscode, digest, redirect, robotflags,
    // length, offset, filename.
    FieldSplitFormat fmt = CDXFieldConstants.CDX_ALL_NAMES;
    testCDXServer.cdxLines = new CDXLine[] {
View Full Code Here

    //   getMementoTimemapFormat() - passed to CDXQuery.output
    //   getRequestUrl() - passed to CDXQuery
    //   get(MementoConstants.PAGE_STARTS) (optional, passed to CDXQuery.from
    //   getAccessPoint() - if getMementoTimemapFormat() == MementoConstants.FORMAT_LINK,
    //     CDX is looked up by calling AccessPoint#queryIndex(WaybackRequest)
    WaybackRequest wbr = new WaybackRequest();
    wbr.setRequestUrl("http://example.com/");
    wbr.setMementoTimemapFormat("memento");
   
    FieldSplitFormat fmt = CDXFieldConstants.CDX_ALL_NAMES;
    testCDXServer.cdxLines = new CDXLine[] {
        new CDXLine(CDXLINE1, fmt)
    };
View Full Code Here

//      startDate = getEarliestTimestamp();
//      endDate = getLatestTimestamp();
//      dateStr = Timestamp.parseAfter(dateStr).getDateStr();
    }

    WaybackRequest wbRequest = WaybackRequest.createReplayRequest(urlStr, dateStr, startDate, endDate);
    ArchivalUrl.assignFlags(wbRequest, flags);

    return wbRequest;
  }
View Full Code Here

    urlString = UrlOperations.fixupHTTPUrlWithOneSlash(urlString);
    boolean handled = true;
   
    ArcResource r = null;
   
    WaybackRequest wbRequest = new WaybackRequest();
    wbRequest.setAccessPoint(inner);
    wbRequest.setRequestUrl(urlString);

    try {
      String ref = httpRequest.getHeader("Referer");
     
      PerfStats.clearAll();     
     
      if ((ref == null) || !skipHost.matcher(ref).find()) {
        wbRequest.setTimestampSearchKey(true);
        wbRequest.setReplayDate(new Date());
        wbRequest.setReplayRequest();
       
        try {
          inner.queryIndex(wbRequest);
          // Succeeded, so send redirect to query
          httpResponse.sendRedirect(inner.getReplayPrefix() + urlString);
          return true;
        } catch (ResourceIndexNotAvailableException e) {
          throw new LiveDocumentNotAvailableException(e.toString());
        } catch (ResourceNotInArchiveException e) {
          //Continue
        } catch (BadQueryException e) {
          throw new LiveDocumentNotAvailableException(e.toString());
        } catch (AccessControlException e) {
          //Continue
          //throw new LiveDocumentNotAvailableException(e.toString());
        } catch (ConfigurationException e) {
          throw new LiveDocumentNotAvailableException(e.toString());
        }
      }
     
      wbRequest.setLiveWebRequest(true);
     
      if (inner.isEnablePerfStatsHeader()) {
        PerfStats.timeStart(AccessPoint.PerfStat.Total);
        httpResponse = new PerfWritingHttpServletResponse(httpRequest, httpResponse, AccessPoint.PerfStat.Total, inner.getPerfStatsHeader());
      }
     
      Thread.currentThread().setName("Thread " +
          Thread.currentThread().getId() + " " + getBeanName() +
          " handling: " + urlString);
     
      CaptureSearchResult result = new FastCaptureSearchResult();
     
      r = this.getLiveWebResource(result, urlString);
     
      if (r != null) {       
        CaptureSearchResults results = new CaptureSearchResults();
        results.addSearchResult(result);
     
        wbRequest.setReplayTimestamp(result.getCaptureTimestamp());
         
        inner.getReplay().getRenderer(wbRequest, result, r).renderResource(httpRequest, httpResponse, wbRequest, result, r,
            inner.getUriConverter(), results)
      } else {
        throw new LiveDocumentNotAvailableException(urlString);
View Full Code Here

    new Partitioner<Partition<CaptureSearchResult>>(partitionMap);
 
  public BubbleCalendarData(UIResults results) {
    this.results = results;
    CaptureSearchResults cResults = results.getCaptureResults();
    WaybackRequest wbRequest = results.getWbRequest();
    StringFormatter fmt = wbRequest.getFormatter();
    String searchUrl =
      UrlOperations.stripDefaultPortFromUrl(wbRequest.getRequestUrl());

    searchUrlForHTML = fmt.escapeHtml(searchUrl);
    searchUrlForJS = fmt.escapeJavaScript(searchUrl);
    firstResultDate = cResults.getFirstResultDate();
    firstResultReplayUrl = fmt.escapeHtml(results.resultToReplayUrl(cResults.getResults().getFirst()));
    lastResultDate = cResults.getLastResultDate();
    lastResultReplayUrl = fmt.escapeHtml(results.resultToReplayUrl(cResults.getResults().getLast()));
    Date searchStartDate = wbRequest.getStartDate();
    Date searchEndDate = wbRequest.getEndDate();
    months = capturePartitioner.getRange(monthSize,searchStartDate,searchEndDate);
    years =  partitionPartitioner.getRange(yearSize,searchStartDate,searchEndDate);

   
    // To build the graph, we need to break all the results into 1 month
View Full Code Here

    // Accept-Datetime specified but is invalid and timestamp not specified, must return a 400
    if (invalidAcceptDateTime && (date == null)) {
      throw new TimeGateBadQueryException("Invald Memento TimeGate datetime request, Accept-Datetime: " + acceptDateTime, requestPath);
    }
   
    WaybackRequest wbRequest = this.parse(requestPath, accessPoint, date);
   
    if (wbRequest != null) {
      wbRequest.setResultsPerPage(getMaxRecords());
      wbRequest.setMementoTimegate();
    }
   
    return wbRequest;
  }
View Full Code Here

      String requestPath, Date mementoDate) throws BetterRequestException  {
//    String nowTS = Timestamp.currentTimestamp().getDateStr();
//    String newUrl = accessPoint.getUriConverter().makeReplayURI(nowTS, requestPath);
//    throw new BetterRequestException(newUrl);
   
    WaybackRequest wbRequest = new WaybackRequest();
   
    if (wbRequest.getStartTimestamp() == null) {
      wbRequest.setStartTimestamp(getEarliestTimestamp());
    }

    if (wbRequest.getEndTimestamp() == null) {
      wbRequest.setEndTimestamp(getLatestTimestamp());
    }
   
    if (mementoDate == null) {
      mementoDate = new Date();
      wbRequest.setBestLatestReplayRequest();
    }
   
    wbRequest.setReplayDate(mementoDate);
    wbRequest.setAnchorDate(mementoDate);
    wbRequest.setReplayRequest();
    wbRequest.setRequestUrl(requestPath);
   
    return wbRequest;
  }
View Full Code Here

    super(wrapped);
  }

  public WaybackRequest parse(HttpServletRequest httpRequest,
      AccessPoint accessPoint) throws BetterRequestException {
    WaybackRequest wbRequest = super.parse(httpRequest, accessPoint);
    if (wbRequest != null) {
      String replayTimestamp = wbRequest.getReplayTimestamp();
      if ((replayTimestamp == null) || replayTimestamp.length() == 0) {
        // lets call it a star query:
        // TODO: should we clone?
        wbRequest.setStartTimestamp(null);
        wbRequest.setEndTimestamp(null);
      }
      String requestPath =
        accessPoint.translateRequestPathQuery(httpRequest);
      ArchivalUrl aUrl = new ArchivalUrl(wbRequest);
      String bestPath = aUrl.toString();
      if (accessPoint.isForceCleanQueries()) {
        if (!bestPath.equals(requestPath)) {
          String betterURI = (wbRequest.isReplayRequest() ?
              accessPoint.getReplayPrefix() :
                accessPoint.getQueryPrefix())
              + bestPath;
          throw new BetterRequestException(betterURI);
        }
View Full Code Here

    prrp.setLocalhostNames(localhostNames);
  }
  public WaybackRequest parse(HttpServletRequest httpRequest,
            AccessPoint wbContext) throws BadQueryException, BetterRequestException {
 
      WaybackRequest wbRequest = super.parse(httpRequest, wbContext);
      if (wbRequest != null) {
         
          // Get the id from the request. If no id, use the ip-address instead.
             
          // Then get the timestamp (or rather datestr) matching this id.
              String id = httpRequest.getHeader("Proxy-Id");
             
              if (id == null) {
                id = httpRequest.getRemoteAddr();
              }
             
          // First try exact timestamp from replayDateStr
          String replayDateStr = httpRequest.getHeader("Proxy-Timestamp");
         
          if (replayDateStr != null) {
            BDBMap.addTimestampForId(httpRequest.getContextPath(), id, replayDateStr);
          } else {
                // TODO: This is hacky.
                replayDateStr = BDBMap.getTimestampForId(httpRequest.getContextPath(), id);
          }
           
              wbRequest.setReplayTimestamp(replayDateStr);
              wbRequest.setAnchorTimestamp(replayDateStr);
      }
      return wbRequest;
  }
View Full Code Here

TOP

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

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.