Package org.archive.cdxserver

Examples of org.archive.cdxserver.CDXQuery


    assertEquals(1,  sr.getReturnedCount());
   
    assertEquals(1, testCDXServer.capturedArgs.size());
   
    Object[] args = testCDXServer.capturedArgs.get(0);
    CDXQuery query = (CDXQuery)args[0];
    String[] filter = query.getFilter();
    assertEquals(1, filter.length);
    assertEquals("!statuscode:(500|502|504)", filter[0]);
   
    AuthToken authToken = (AuthToken)args[1];
    assertFalse(authToken.isIgnoreRobots());
View Full Code Here


      SearchResults sr = cut.query(wbr);

      assertEquals(1, testCDXServer.capturedArgs.size());

      Object[] args = testCDXServer.capturedArgs.get(0);
      CDXQuery query = (CDXQuery)args[0];
      String[] filter = query.getFilter();
      assertNull("there should be no filter", filter);
    }
   
    testCDXServer.clearCapturedArgs();
    cut.setBaseStatusRegexp("!500");
    {
      SearchResults sr = cut.query(wbr);

      assertEquals(1, testCDXServer.capturedArgs.size());
     
      Object[] args = testCDXServer.capturedArgs.get(0);
      CDXQuery query = (CDXQuery)args[0];
      String[] filter = query.getFilter();
      assertEquals(1, filter.length);
      assertEquals("!statuscode:500", filter[0]);
    }
  }
View Full Code Here

    cut.handleRequest(request, response);
   
    assertEquals(1, testCDXServer.capturedArgs.size());
    Object[] args = testCDXServer.capturedArgs.get(0);
   
    CDXQuery query = (CDXQuery)args[0];
    assertEquals("API query should not have filter by default", 0, query.getFilter().length);
   
    assertEquals(CDXLINE1+"\n", sw.toString());
  }
View Full Code Here

    assertTrue("renderMementoTimemap returns true", r);

    assertEquals(1, testCDXServer.capturedArgs.size());
    Object[] args = testCDXServer.capturedArgs.get(0);
   
    CDXQuery query = (CDXQuery)args[0];
    assertEquals("API query should not have filter by default", 0, query.getFilter().length);
   
    // Here we only check if output *looks like* Memento format. Detailed tests
    // shall be done by test case for MementoLinkWriter.
    //System.out.println("response=" + sw.toString());
    assertTrue(sw.toString().startsWith("<http://example.com/>;"));
View Full Code Here

   * @param wbRequest {@link WaybackRequest} either replay or capture-query
   * @param isFuzzy unused (?)
   * @return A {@link CDXQuery} object for the supplied request.
   */
  protected CDXQuery createQuery(WaybackRequest wbRequest, boolean isFuzzy) {
    CDXQuery query = new CDXQuery(wbRequest.getRequestUrl());
       
    query.setLimit(limit);
    //query.setSort(CDXQuery.SortType.reverse);
   
    String statusFilter = baseStatusFilter;
   
    if (wbRequest.isReplayRequest()) {
      if (wbRequest.isBestLatestReplayRequest()) {
        statusFilter = "statuscode:[23]..";
      }
     
      if (wbRequest.isTimestampSearchKey()) {   
        query.setClosest(wbRequest.getReplayTimestamp());
      }
    } else if (wbRequest.isCaptureQueryRequest()) {
      // Add support for range calendar queries:
      // eg: /2005-2007*/
      // by mapping request start and end timestamp
      // to cdx server from= and to= params
      String start = wbRequest.getStartTimestamp();
      if (start != null) {
        query.setFrom(start);
      }
      String end = wbRequest.getEndTimestamp();
      if (end != null) {
        query.setTo(end);
      }
    }
   
    if (timestampDedupLength > 0) {
      //query.setCollapse(new String[]{"timestamp:" + timestampDedupLength});
      query.setCollapseTime(timestampDedupLength);
    }
   
    // CDXServer#writeCdxResponse translates this into FieldRegexFilter
    if (statusFilter != null && !statusFilter.isEmpty())
      query.setFilter(new String[]{statusFilter});
   
    return query;
  }
View Full Code Here

   * @param isFuzzy {@code true} to enable fuzzy query
   * @return CDXCaptureSearchResultWriter
   */
  protected CDXToCaptureSearchResultsWriter getCaptureSearchWriter(WaybackRequest wbRequest, AuthToken waybackAuthToken, boolean isFuzzy)
  {
    final CDXQuery query = createQuery(wbRequest, isFuzzy);
   
    if (isFuzzy && query == null) {
      return null;
    }
   
View Full Code Here

        return captureWriter;
  }
 
  protected CDXToSearchResultWriter getUrlSearchWriter(WaybackRequest wbRequest)
  { 
    final CDXQuery query = new CDXQuery(wbRequest.getRequestUrl());
   
    query.setCollapse(new String[]{CDXLine.urlkey});
    query.setMatchType(MatchType.prefix);
    query.setShowGroupCount(true);
    query.setShowUniqCount(true);
    query.setLastSkipTimestamp(true);
    query.setFl("urlkey,original,timestamp,endtimestamp,groupcount,uniqcount");
   
    return new CDXToUrlSearchResultWriter(query);
    }
View Full Code Here

        SearchResults cResults = wbRequest.getAccessPoint().queryIndex(wbRequest);
        MementoUtils.printTimemapResponse((CaptureSearchResults)cResults, wbRequest, response);       
        return true;
      }
     
      CDXQuery query = new CDXQuery(wbRequest.getRequestUrl());
     
      query.setOutput(wbRequest.getMementoTimemapFormat());
     
      String from = wbRequest.get(MementoConstants.PAGE_STARTS);
     
      if (from != null) {
        query.setFrom(from);
      }
     
      try {
            query.fill(request);
          } catch (ServletRequestBindingException e1) {
            //Ignore
          }
 
        cdxServer.getCdx(request, response, query);
View Full Code Here

  @Override
    public boolean handleRequest(HttpServletRequest httpRequest,
            HttpServletResponse httpResponse) throws ServletException,
            IOException {
   
    CDXQuery query = new CDXQuery(httpRequest);
    cdxServer.getCdx(httpRequest, httpResponse, query);   
    return true;
   
View Full Code Here

TOP

Related Classes of org.archive.cdxserver.CDXQuery

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.