Examples of WaybackRequest


Examples of org.archive.wayback.core.WaybackRequest

   * @see org.archive.wayback.RequestParser#parse(javax.servlet.http.HttpServletRequest)
   */
  public WaybackRequest parse(HttpServletRequest httpRequest,
      AccessPoint wbContext) throws BadQueryException {

    WaybackRequest wbRequest = null;

    for(int i = 0; i < parsers.length; i++) {
      wbRequest = parsers[i].parse(httpRequest, wbContext);
      if(wbRequest != null) {
        break;
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

   * info from the httpRequest object.
   */
  public WaybackRequest parse(HttpServletRequest httpRequest,
      AccessPoint wbContext) throws BadQueryException {
   
    WaybackRequest wbRequest = null;
    @SuppressWarnings("unchecked")
    Map<String,String[]> queryMap = httpRequest.getParameterMap();
    String query = getMapParam(queryMap, SEARCH_QUERY);
    if(query == null) {
      return null;
    }
    wbRequest = new WaybackRequest();
   
    String base = wbContext.translateRequestPath(httpRequest);
    if(base.startsWith(REPLAY_BASE)) {
      wbRequest.put(WaybackConstants.REQUEST_TYPE,
          WaybackConstants.REQUEST_REPLAY_QUERY);
    } else if(base.startsWith(QUERY_BASE)){
      wbRequest.put(WaybackConstants.REQUEST_TYPE,
          WaybackConstants.REQUEST_URL_QUERY);
    } else if(base.startsWith(XQUERY_BASE)){
      wbRequest.put(WaybackConstants.REQUEST_TYPE,
          WaybackConstants.REQUEST_URL_QUERY);
      wbRequest.put(WaybackConstants.REQUEST_XML_DATA,"1");
     
    } else {
      return null;
    }
   
    String numResults = getMapParam(queryMap, SEARCH_RESULTS);
    String startPage = getMapParam(queryMap, START_PAGE);

    if (numResults != null) {
      int nr = Integer.parseInt(numResults);
      wbRequest.setResultsPerPage(nr);
    } else {
      wbRequest.setResultsPerPage(maxRecords);
    }
    if (startPage != null) {
      int sp = Integer.parseInt(startPage);
      wbRequest.setPageNum(sp);
    } else {
      wbRequest.setPageNum(1);
    }

    // first try the entire line_tokens:
    for (int i = 0; i < lineTokens.length; i++) {
      String token = lineTokens[i] + ":";
      int index = query.indexOf(token);
      if (index > -1) {
        // found it, take value as the remainder of the query
        String value = query.substring(index + token.length());
        // TODO: trim trailing whitespace?
        wbRequest.put(lineTokens[i], value);
        query = query.substring(0, index);
      }
    }

    // now split whatever is left on whitespace:
    String[] parts = WHITESPACE_PATTERN.split(query);
    for (int i = 0; i < parts.length; i++) {
      String token = parts[i];
      int colonIndex = token.indexOf(':');
      if (colonIndex == -1) {
        throw new BadQueryException("Bad search token(" + token + ")");
      }
      String key = token.substring(0, colonIndex);
      String value = token.substring(colonIndex + 1);
      // TODO: make sure key is in singleTokens?
      // let's just let em all thru for now:
      wbRequest.put(key, value);
    }
    if(wbRequest.get(WaybackConstants.REQUEST_START_DATE) == null) {
      wbRequest.put(WaybackConstants.REQUEST_START_DATE,
          getEarliestTimestamp());
    }
    if(wbRequest.get(WaybackConstants.REQUEST_END_DATE) == null) {
      wbRequest.put(WaybackConstants.REQUEST_END_DATE,
          getLatestTimestamp());
    }
    wbRequest.fixup(httpRequest);

    return wbRequest;
  }
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

  private boolean dispatchLocal(HttpServletRequest httpRequest,
      HttpServletResponse httpResponse)
  throws ServletException, IOException {
   
    WaybackRequest wbRequest = new WaybackRequest();
    wbRequest.setContextPrefix(getAbsoluteLocalPrefix(httpRequest));
    wbRequest.setContext(this);
    UIResults uiResults = new UIResults(wbRequest);
    String translated = "/" + translateRequestPathQuery(httpRequest);
    uiResults.storeInRequest(httpRequest,translated);
    RequestDispatcher dispatcher = null;
//    // special case for the front '/' page:
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

      HttpServletResponse httpResponse)
  throws ServletException, IOException {

    httpResponse.setHeader("header", httpRequest.getHeader("referer") );

    WaybackRequest wbRequest = null;
    boolean handled = false;

    try {
      wbRequest = parser.parse(httpRequest, this);

      if(wbRequest != null) {
        wbRequest.setContext(this);
        handled = true;
        wbRequest.setContextPrefix(getAbsoluteLocalPrefix(httpRequest));
        if(authentication != null) {
          if(!authentication.isTrue(wbRequest)) {
            throw new AuthenticationControlException("Not authorized");
          }
        }

        if(exclusionFactory != null) {
          wbRequest.setExclusionFilter(exclusionFactory.get());
        }
        if(wbRequest.isReplayRequest()) {

          handleReplay(wbRequest,httpRequest,httpResponse);
         
        } else {
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

   * WaybackRequest object, except the Submit button argument.
   */
  public WaybackRequest parse(HttpServletRequest httpRequest,
      AccessPoint wbContext) {

    WaybackRequest wbRequest = null;
    @SuppressWarnings("unchecked")
    Map<String,String[]> queryMap = httpRequest.getParameterMap();
    if(queryMap.size() > 0) {
      wbRequest = new WaybackRequest();
     
      String base = wbContext.translateRequestPath(httpRequest);
      if(base.startsWith(REPLAY_BASE)) {
        wbRequest.put(WaybackConstants.REQUEST_TYPE,
            WaybackConstants.REQUEST_REPLAY_QUERY);
      } else if(base.startsWith(QUERY_BASE)) {
        wbRequest.put(WaybackConstants.REQUEST_TYPE,
            WaybackConstants.REQUEST_URL_QUERY);
      } else if(base.startsWith(XQUERY_BASE)){
        wbRequest.put(WaybackConstants.REQUEST_TYPE,
            WaybackConstants.REQUEST_URL_QUERY);
        wbRequest.put(WaybackConstants.REQUEST_XML_DATA,"1");
       
      } else {
        return null;
      }
      wbRequest.setResultsPerPage(maxRecords);
      Set<String> keys = queryMap.keySet();
      Iterator<String> itr = keys.iterator();
      while(itr.hasNext()) {
        String key = itr.next();
        if(key.equals(SUBMIT_BUTTON)) {
          continue;
        }
        // just jam everything else in:
        String val = getMapParam(queryMap,key);                   
        wbRequest.put(key,val);             
      }
           
     
      //if(wbRequest.get(WaybackConstants.REQUEST_START_DATE) == null) {
      //  wbRequest.put(WaybackConstants.REQUEST_START_DATE, getEarliestTimestamp()); // BUG 120608
      //}
      //if(wbRequest.get(WaybackConstants.REQUEST_END_DATE) == null) {
      //  wbRequest.put(WaybackConstants.REQUEST_END_DATE, getLatestTimestamp()); // BUG 120608
      //}
     
      String partialDate=wbRequest.get(WaybackConstants.REQUEST_DATE); // BUG 120608
      if (partialDate!=null) { // if date exist, ignore start and end date     
        wbRequest.put(WaybackConstants.REQUEST_START_DATE, Timestamp.padStartDateStr(partialDate));
        wbRequest.put(WaybackConstants.REQUEST_END_DATE, Timestamp.padEndDateStr(partialDate));
      }     
    }
    //if(wbRequest != null) {
    //  wbRequest.fixup(httpRequest); // BUG 120608
    //}
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

    prrp.setLocalhostNames(localhostNames);
  }
  public WaybackRequest parse(HttpServletRequest httpRequest,
            AccessPoint wbContext) throws BadQueryException {
 
      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();
              wbRequest.put(WaybackConstants.REQUEST_EXACT_DATE, Timestamp
                      .getTimestampForId(httpRequest.getContextPath(), id));
              wbRequest.fixup(httpRequest);
      }
      return wbRequest;
  }
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

   * @see org.archive.wayback.RequestParser#parse(javax.servlet.http.HttpServletRequest, org.archive.wayback.webapp.WaybackContext)
   */
  public WaybackRequest parse(HttpServletRequest httpRequest,
      AccessPoint wbContext) throws BadQueryException {
   
    WaybackRequest wbRequest = null;
    String server = httpRequest.getServerName() +
      ":" + httpRequest.getServerPort();
    if(server.endsWith(hostPort)) {
      int length = server.length() - hostPort.length();
      if(server.length() > hostPort.length()) {
        String prefix = server.substring(0,length - 1);
        Matcher replayMatcher = REPLAY_REGEX.matcher(prefix);
        if (replayMatcher != null && replayMatcher.matches()) {
          wbRequest = new WaybackRequest();
          String dateStr = replayMatcher.group(1);
          String host = replayMatcher.group(2);

          String requestUrl = getRequestString(host,httpRequest);

          wbRequest.put(WaybackConstants.REQUEST_EXACT_DATE, dateStr);
          wbRequest.put(WaybackConstants.REQUEST_TYPE,
              WaybackConstants.REQUEST_REPLAY_QUERY);
          try {
            wbRequest.setRequestUrl(requestUrl);
          } catch (URIException e) {
            e.printStackTrace();
            wbRequest = null;
          }
        } else {
          Matcher queryMatcher = QUERY_REGEX.matcher(prefix);
          if(queryMatcher != null && queryMatcher.matches()) {
            wbRequest = new WaybackRequest();
            String dateStr = queryMatcher.group(1);
            String host = queryMatcher.group(2);
            String startDate;
            String endDate;
            if(dateStr.length() == 0) {
              startDate = getEarliestTimestamp();
              endDate = getLatestTimestamp();
            } else {
              startDate = Timestamp.parseBefore(dateStr).getDateStr();
              endDate = Timestamp.parseAfter(dateStr).getDateStr();
            }
            wbRequest.put(WaybackConstants.REQUEST_START_DATE,startDate);
            wbRequest.put(WaybackConstants.REQUEST_END_DATE,endDate);
            wbRequest.put(WaybackConstants.REQUEST_TYPE,
                WaybackConstants.REQUEST_URL_QUERY);

            String requestUrl = getRequestString(host,httpRequest);
           
            try {
              wbRequest.setRequestUrl(requestUrl);
            } catch (URIException e) {
              e.printStackTrace();
              wbRequest = null;
            }
          }
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

  /**
   * @param url
   * @return String url that will make a query for all captures of an URL.
   */
  public String makeCaptureQueryUrl(String url) {
    WaybackRequest newWBR = wbRequest.clone();
   
    newWBR.put(WaybackConstants.REQUEST_TYPE,
        WaybackConstants.REQUEST_URL_QUERY);
    try {
      newWBR.setRequestUrl(url);
    } catch (URIException e) {
      // should not happen...
      e.printStackTrace();
    }
    return newWBR.getContextPrefix() + "query?" +
      newWBR.getQueryArguments(1);
  }
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

      // local means query: let the following RequestParsers have a go
      // at it.
      return null;
    }

    WaybackRequest wbRequest = null;
    String requestServer = httpRequest.getServerName();
    String requestPath = httpRequest.getRequestURI();
    //int port = httpRequest.getServerPort();
    String requestQuery = httpRequest.getQueryString();
    String requestScheme = httpRequest.getScheme();
    if (requestQuery != null) {
      requestPath = requestPath + "?" + requestQuery;
    }

    String requestUrl = requestScheme + "://" + requestServer + requestPath;

    wbRequest = new WaybackRequest();
    try {
      wbRequest.setRequestUrl(requestUrl);
    } catch (URIException e) {
      e.printStackTrace();
      return null;
    }
    wbRequest.put(WaybackConstants.REQUEST_TYPE,
        WaybackConstants.REQUEST_REPLAY_QUERY);

    return wbRequest;
  }
View Full Code Here

Examples of org.archive.wayback.core.WaybackRequest

  /**
   * @throws Exception
   */
  public void testGroupBalance() throws Exception {
    WaybackRequest r = new WaybackRequest();
    r.put(WaybackConstants.REQUEST_URL,index.canonicalize("apple.com/"));
    RangeGroup g = index.getRangeGroupForRequest(r);
    assertEquals(g.getName(),"b");
    RangeMember b1 = g.findBestMember();
    assertEquals(b1.getUrlBase(),"b1");
    b1.noteConnectionStart();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.