Package org.archive.wayback.core

Examples of org.archive.wayback.core.Resource


          LOGGER.fine("Adding extra url("+firstUrlString+") for prev cached rules("+urlString+")");
          rulesCache.put(firstUrlString, rules);
        }
      } else {
        //long start = System.currentTimeMillis();;
        Resource resource = null;
        try {
          PerfStats.timeStart(PerfStat.RobotsFetchTotal);
         
          if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("ROBOT: NotCached - Downloading("+urlString+")");
          }
       
          tmpRules = new RobotRules();         
          resource = webCache.getCachedResource(new URL(urlString),
              maxCacheMS,true);
          //long elapsed = System.currentTimeMillis() - start;
          //PerformanceLogger.noteElapsed("RobotRequest", elapsed, urlString);

          if(resource.getStatusCode() != 200) {
            LOGGER.info("ROBOT: NotAvailable("+urlString+")");
            throw new LiveDocumentNotAvailableException(urlString);
          }
          tmpRules.parse(resource);         
          rulesCache.put(firstUrlString,tmpRules);
          rules = tmpRules;
         
          if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("ROBOT: Downloaded("+urlString+")");
          }

        } catch (LiveDocumentNotAvailableException e) {
          LOGGER.info("ROBOT: LiveDocumentNotAvailableException("+urlString+")");

        } catch (MalformedURLException e) {
//          e.printStackTrace();
          LOGGER.warning("ROBOT: MalformedURLException("+urlString+")");
          return null;
        } catch (IOException e) {
          LOGGER.warning("ROBOT: IOException("+urlString+"):"+e.getLocalizedMessage());
          return null;
        } catch (LiveWebCacheUnavailableException e) {
          LOGGER.severe("ROBOT: LiveWebCacheUnavailableException("+urlString+")");
          if (filterGroup != null) {
            filterGroup.setLiveWebGone();
          }
          return null;
        } catch (LiveWebTimeoutException e) {
          LOGGER.severe("ROBOT: LiveDocumentTimedOutException("+urlString+")");
          if (filterGroup != null) {
            filterGroup.setRobotTimedOut();
          }
          return null;
        } finally {
          if (resource != null) {
            try {
              resource.close();
            } catch (IOException e) {
             
            }
            resource = null;
          }
View Full Code Here


        else
          {
            fileUrl = prefix + fileName;
          }
       
    Resource r = null;
    try {
      int attempts = retries;
          while(attempts-- > 0) {
            try {
              r = ResourceFactory.getResource(fileUrl, offset);
View Full Code Here

    final long offset = result.getOffset();

    String errMsg = "Unable to retrieve";
    Exception origException = null;
   
    Resource r = null;
    // TODO: attempt multiple threads?
    for(String url : urls) {
       
      try {
View Full Code Here

            "BODY {\n" +
            "  color: #fff;\n" +
            "  background: transparent url(bg.gif);\n" +
            "}\n";
        final byte[] payloadBytes = payload.getBytes("UTF-8");
        Resource payloadResource = createTestHtmlResource(payloadBytes);
       
        response.setStatus(200);
        response.setCharacterEncoding("UTF-8");
        response.setHeader(EasyMock.eq("Content-Length"), EasyMock.<String>notNull());
        response.setHeader(cut.getGuessedCharsetHeader(), "UTF-8");
View Full Code Here

        "var el1 = document.createElement('img');\n" +
        "el1.src = img;\n" +
        "document.getElementById('imgdiv').appendChild(el1)\n";
   
    final byte[] payloadBytes = payload.getBytes("UTF-8");
    Resource payloadResource = createTestJSResource(payloadBytes);
   
    // ResultURIConverter argument is passed down from AccessPoint#getUriConverter().
    // it is typically ProxyHttpsResultURIConverter(), the same class for converterFactory
    // (but a separate instance) - we reuse proxyURIConverter above.
    HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
View Full Code Here

     * @throws Exception
     */
    public void testBasicBehavior() throws Exception {
        String payload = "<HTML></HTML>\n";
        final byte[] payloadBytes = payload.getBytes("UTF-8");
        Resource payloadResource = createTestHtmlResource(payloadBytes);
       
        Capture<ReplayParseContext> parseContextCapture = new Capture<ReplayParseContext>();
        Capture<Node> nodeCapture = new Capture<Node>();
        nodeHandler.handleParseStart(EasyMock.<ReplayParseContext>anyObject());
        nodeHandler.handleParseComplete(EasyMock.<ReplayParseContext>anyObject());
View Full Code Here

     * @throws Exception
     */
    public void testRevisit() throws Exception {
        final String payload = "<HTML></HTML>\n";
        final byte[] payloadBytes = payload.getBytes("UTF-8");
        Resource payloadResource = createTestHtmlResource(payloadBytes);
        // payloadResource is Content-Encoding: gzip, revisit must be gzipped, too.
        Resource headerResource = createTestRevisitResource(payloadBytes, true, true);

        Capture<ReplayParseContext> parseContextCapture = new Capture<ReplayParseContext>();
        Capture<Node> nodeCapture = new Capture<Node>();
        nodeHandler.handleParseStart(EasyMock.<ReplayParseContext>anyObject());
        nodeHandler.handleParseComplete(EasyMock.<ReplayParseContext>anyObject());
View Full Code Here

                "  <frame src=\"top.html\">\n" +
                "  <frame src=\"center.html\">\n" +
                "  <frame src=\"bottom.html\">\n" +
                "</frameset>\n";
        byte[] payloadBytes = payload.getBytes("UTF-8");
        Resource payloadResource = createTestHtmlResource(payloadBytes);
       
        Capture<ReplayParseContext> parseContextCapture = new Capture<ReplayParseContext>();
        nodeHandler.handleParseStart(EasyMock.capture(parseContextCapture));
        nodeHandler.handleParseComplete(EasyMock.<ReplayParseContext>anyObject());
        nodeHandler.handleNode(EasyMock.<ParseContext>anyObject(), EasyMock.<Node>anyObject());
View Full Code Here

                "  <frame src=\"top.html\">\n" +
                "  <frame src=\"center.html\">\n" +
                "  <frame src=\"bottom.html\">\n" +
                "</frameset>\n";
        byte[] payloadBytes = payload.getBytes("UTF-8");
        Resource payloadResource = createTestHtmlResource(payloadBytes);
       
        Capture<ReplayParseContext> parseContextCapture = new Capture<ReplayParseContext>();
        nodeHandler.handleParseStart(EasyMock.capture(parseContextCapture));
        nodeHandler.handleParseComplete(EasyMock.<ReplayParseContext>anyObject());
        nodeHandler.handleNode(EasyMock.<ParseContext>anyObject(), EasyMock.<Node>anyObject());
View Full Code Here

    if (filename == null || filename.isEmpty()) {
      throw new ResourceNotAvailableException("No ARC/WARC name in search result...", filename);
    }
   
    Resource resource = null;
    boolean breakOnErr = false;
   
    StringBuilder excMsg = new StringBuilder();
    IOException lastExc = null;
       
View Full Code Here

TOP

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

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.