Examples of BadQueryException


Examples of org.archive.wayback.exception.BadQueryException

         existStartDate=false; // BUG 120608
         startDateStr = Timestamp.earliestTimestamp().getDateStr();
       }
       int hitsPerPage = wbRequest.getResultsPerPage();
       if(hitsPerPage < 1) {
         throw new BadQueryException("Hits per page must be positive");
       }
       if(hitsPerPage > maxRecords) {
         throw new BadQueryException("Hits per page must be less than " +
             maxRecords);
       }
       int start = (wbRequest.getPageNum()-1) * hitsPerPage;
      
     /* BUG 0000155 */
        String multDet = wbRequest.get(WaybackConstants.REQUEST_MULT_DETAILS);
     String docId = wbRequest.get(WaybackConstants.REQUEST_DOC_ID);
     String indexId = wbRequest.get(WaybackConstants.REQUEST_INDEX_ID);
     /* BUG 0000155 */                          
    
       if ((urlStr==null || urlStr.length()<=0) && (docId==null || indexId==null)) {
           throw new BadQueryException("Url is empty.");
       }
       // Construct the search url.
       MutableString ms = new MutableString(this.searchUrlBase)
           .append("?query=");
       // Add 'date:...+' to query string.   
       if (existStartDate || existEndDate) { // BUG wayback 0000051;  if exist startDate OR endDate
         ms.append("date%3A").append(startDateStr).append('-').append(endDateStr);  
       }    
       else if (exactDateStr!=null) { // BUG wayback 0000153
         ms.append("closestdate%3A").append(exactDateStr);
       }
      
       ms.append('+');
       // Add 'url:URL'.
       if(wbRequest.get(WaybackConstants.REQUEST_TYPE).equals(
                  WaybackConstants.REQUEST_URL_PREFIX_QUERY)) {
           ms.append("url%3A").append(urlStr);
       } else {
           try {       
           if (docId!=null && indexId!=null) {
             // do nothing
           }
           else if (wbRequest.get(WaybackConstants.REQUEST_ALIASES)!=null && wbRequest.get(WaybackConstants.REQUEST_ALIASES).equals("true")) {
                ms.append("exacturlexpand%3A").append(java.net.URLEncoder.encode(urlStr, "UTF-8"));
           }
           else {                        
            URL url=null;
            boolean error=false;
            try {
              url=new URL(urlStr);
            }
            catch (MalformedURLException e) {
              error=true;
            }
            
            if (!error && !urlStr.endsWith("/") && url.getQuery()==null && url.getPath().indexOf('.')==-1) { // BUG nutchwax 0000357 - add also a "/" if the url's query is null and is not a file
              ms.append("exacturlexpandmin%3A").append(java.net.URLEncoder.encode(urlStr, "UTF-8"));
            }
            else {            
              ms.append("exacturl%3A").append(java.net.URLEncoder.encode(urlStr, "UTF-8"));
            }
           }
           }
           catch (UnsupportedEncodingException e) {
             throw new BadQueryException(e.toString());
           }
           catch (NullPointerException e) {
               throw new BadQueryException(e.toString());
           }
       }
       ms.append("&hitsPerPage=").append(hitsPerPage);
       ms.append("&start=").append(start);
       ms.append("&dedupField=site");       
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

    if(wbRequest.isReplayRequest() || wbRequest.isCaptureQueryRequest()) {
      results = new CaptureSearchResults();     
    } else {
      // TODO: this is wrong, but needs exploration into what NutchWax
      //       can actually do.
      throw new BadQueryException("Unable to perform path " +
          "prefix requests with this index type");
    }
    NodeList channel = getSearchChannel(document);
    NodeList nodes = getSearchItems(document);
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

       if (startDateStr == null || startDateStr.length() == 0) {
         startDateStr = Timestamp.earliestTimestamp().getDateStr();
       }
       int hitsPerPage = wbRequest.getResultsPerPage();
       if(hitsPerPage < 1) {
         throw new BadQueryException("Hits per page must be positive");
       }
       if(hitsPerPage > maxRecords) {
         throw new BadQueryException("Hits per page must be less than " +
             maxRecords);
       }
       int start = (wbRequest.getPageNum()-1) * hitsPerPage;
       if (urlStr == null || urlStr.length() <= 0) {
           throw new BadQueryException("Url is empty.");
       }
       // Construct the search url.
       MutableString ms = new MutableString(this.searchUrlBase)
           .append("?query=");
       // Add 'date:...+' to query string.
       ms.append("date%3A").append(startDateStr).append('-').append(endDateStr);
       ms.append('+');
       // Add 'url:URL'.
       if(wbRequest.isUrlQueryRequest()) {
           ms.append("url%3A");
       } else {
           ms.append("exacturl%3A");
       }
       try {
            ms.append(java.net.URLEncoder.encode("\""+urlStr+"\"", "UTF-8"));
       } catch (UnsupportedEncodingException e) {
         throw new BadQueryException(e.toString());
       }
       ms.append("&hitsPerPage=").append(hitsPerPage);
       ms.append("&start=").append(start);
       ms.append("&dedupField=site");
       // As we are always searching agains an url, a
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

    String urlKey;
    try {
      urlKey = canonicalizer.urlStringToKey(wbRequest.getRequestUrl());
    } catch (IOException e) {
      throw new BadQueryException("Bad URL(" +
          wbRequest.getRequestUrl() + ")");
    }
   
    // Special handling for index where the key is url<space>timestamp
    // for faster binary search lookup
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

   
    String urlKey;
    try {
      urlKey = canonicalizer.urlStringToKey(wbRequest.getRequestUrl());
    } catch (URIException e) {
      throw new BadQueryException("Bad URL(" +
          wbRequest.getRequestUrl() + ")");
    }
   
    if (markPrefixQueries) {
      urlKey += "*\t";
 
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

      results.putFilter(WaybackRequest.REQUEST_TYPE,
          WaybackRequest.REQUEST_URL_QUERY);

    } else {

      throw new BadQueryException("Unknown query type, must be "
          + WaybackRequest.REQUEST_REPLAY_QUERY
          + ", " + WaybackRequest.REQUEST_CAPTURE_QUERY
          + ", or " + WaybackRequest.REQUEST_URL_QUERY);
    }
    return results;
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

      if(errTitle == null) {
        throw new ResourceIndexNotAvailableException("Unknown error!");
      } else if(errTitle.equals("Resource Not In Archive")) {
        throw new ResourceNotInArchiveException(errMessage);
      } else if(errTitle.equals("Bad Query Exception")) {
        throw new BadQueryException(errMessage);
      } else if(errTitle.equals("Resource Index Not Available Exception")) {
        throw new ResourceIndexNotAvailableException(errMessage);
      } else if(errTitle.equals("Access Control Exception")) {
        throw new AccessControlException(errMessage);
      } else {
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

    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 + ")");
      }
      try {
        String key = URLDecoder.decode(token.substring(0, colonIndex),
            "UTF-8");
        String value = URLDecoder.decode(
            token.substring(colonIndex + 1), "UTF-8");
        // TODO: make sure key is in singleTokens?
        // let's just let em all thru for now:
        wbRequest.put(key, value);
      } catch (UnsupportedEncodingException e) {
        throw new BadQueryException("Unsupported encoding: UTF-8");
      }
    }
    if (wbRequest.getStartTimestamp() == null) {
      wbRequest.setStartTimestamp(getEarliestTimestamp());
    }
View Full Code Here

Examples of org.archive.wayback.exception.BadQueryException

    }

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

Examples of org.archive.wayback.exception.BadQueryException

    // URL-Filters:
    chain = new ObjectFilterChain<CaptureSearchResult>();
    try {
      keyUrl = canonicalizer.urlStringToKey(request.getRequestUrl());
    } catch (IOException e) {
      throw new BadQueryException("Bad request URL(" +
          request.getRequestUrl() +")");
    }
    // Date-Filters:
    startDate = request.getStartTimestamp();
    if(startDate == null) {
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.