protected RangeGroup getRangeGroupForRequest(WaybackRequest wbRequest)
      throws BadQueryException, ResourceIndexNotAvailableException {

    String keyUrl;
    try {
      checkMapFile();
    } catch (IOException e) {
      // TODO: this is too much error info if we're repeatedly failing..
      e.printStackTrace();
      throw new ResourceIndexNotAvailableException(e.getMessage());
    }

    if (groups == null || groups.length == 0) {
      throw new ResourceIndexNotAvailableException("empty map file");
    }

    String searchUrl = wbRequest.getRequestUrl();
    if (searchUrl == null) {
      throw new BadQueryException("No " + WaybackRequest.REQUEST_URL + " specified");
    }

    try {
      keyUrl = canonicalizer.urlStringToKey(searchUrl);
    } catch (URIException e) {
      throw new BadQueryException("invalid " + WaybackRequest.REQUEST_URL + " " + searchUrl);
    }
    RangeGroup dummy = new RangeGroup("", keyUrl, "");
    int loc = Arrays.binarySearch(groups, dummy, comparator);
    if (loc < 0) {
      loc = (loc * -1) - 2;
    }
    LOGGER.info("Using group(" + groups[loc].getName() + ") for url (" + keyUrl + ")");
    return groups[loc];
  }
  public WaybackRequest parse(String requestPath) {
    WaybackRequest wbRequest = null;
    Matcher matcher = WB_PATH_QUERY2_REGEX.matcher(requestPath);
    if (matcher != null && matcher.matches()) {

      wbRequest = new WaybackRequest();
      String startDateStr = matcher.group(1);
      String endDateStr = matcher.group(2);
      String urlStr = matcher.group(3);
      String startDate = Timestamp.parseBefore(startDateStr).getDateStr();
      String endDate = Timestamp.parseAfter(endDateStr).getDateStr();
      wbRequest.setStartTimestamp(startDate);
      wbRequest.setEndTimestamp(endDate);

      wbRequest.setUrlQueryRequest();
      wbRequest.setRequestUrl(urlStr);
    }
    return wbRequest;
  }
Example #3
0
  /**
   * @param jspPath
   * @param httpRequest
   * @param httpResponse
   * @param wbRequest
   * @param results
   * @return
   * @throws IOException
   * @throws ServletException
   * @throws ParseException
   */
  public String includeJspString(
      String jspPath,
      HttpServletRequest httpRequest,
      HttpServletResponse httpResponse,
      WaybackRequest wbRequest,
      CaptureSearchResults results,
      CaptureSearchResult result,
      Resource resource)
      throws ServletException, IOException {

    if (wbRequest.isAjaxRequest()) {
      return "";
    }

    UIResults uiResults = new UIResults(wbRequest, uriConverter, results, result, resource);

    StringHttpServletResponseWrapper wrappedResponse =
        new StringHttpServletResponseWrapper(httpResponse);
    uiResults.forward(httpRequest, wrappedResponse, jspPath);
    return wrappedResponse.getStringResponse();
  }
 /* (non-Javadoc)
  * @see org.archive.wayback.resultspartitioner.ResultsPartitioner#rangeToTitle(java.util.Calendar, java.util.Calendar)
  */
 protected String rangeToTitle(Calendar start, Calendar end, WaybackRequest wbRequest) {
   return wbRequest.getFormatter().format("ResultPartitions.year", start.getTime());
 }