Package org.archive.wayback.core

Examples of org.archive.wayback.core.Resource


      // TODO: this needs to be prettied up for end user consumption..
      throw new ResourceNotAvailableException("Cannot find ARC file ("
          + fileName + ")");
    } else {

      Resource r = ResourceFactory.getResource(file, offset);
      return r;
    }
  }
View Full Code Here


 
  private Resource getLocalCachedResource(URL url, long maxCacheMS,
      boolean bUseOlder) throws ResourceNotInArchiveException,
      IOException, LiveDocumentNotAvailableException {
   
    Resource resource = null;
    WaybackRequest wbRequest = makeCacheWBRequest(url,maxCacheMS,bUseOlder);
   
    CaptureSearchResults results = null;
    try {
      SearchResults gresults = index.query(wbRequest);
View Full Code Here

  }
 
  private Resource getLiveCachedResource(URL url)
    throws LiveDocumentNotAvailableException, IOException {
   
    Resource resource = null;
   
    LOGGER.info("Caching URL(" + url.toString() + ")");
    ARCLocation location = null;
    try {
      location = cacher.cache(arcCacheDir, url.toString());
View Full Code Here

   */
  public Resource getCachedResource(URL url, long maxCacheMS,
      boolean bUseOlder) throws LiveDocumentNotAvailableException,
      IOException {
   
    Resource resource = null;
    try {
      resource = getLocalCachedResource(url, maxCacheMS, false);
      LOGGER.info("Using Cached URL(" + url.toString() + ")");
     
    } catch(ResourceNotInArchiveException e) {
View Full Code Here

        && !fileName.endsWith(LocalResourceStore.WARC_GZ_EXTENSION)) {
      fileName = fileName + LocalResourceStore.ARC_GZ_EXTENSION;
    }
       
    String fileUrl = urlPrefix + fileName;
    Resource r = null;
    try {

      r = ResourceFactory.getResource(new URL(fileUrl), offset);

    } catch (IOException e) {
View Full Code Here

public class ResourceFactory {

  public static Resource getResource(File file, long offset)
      throws IOException, ResourceNotAvailableException {

    Resource r = null;
    String name = file.getName();
    if (name.endsWith(LocalResourceStore.OPEN_EXTENSION)) {
      name = name.substring(0, name.length()
          - LocalResourceStore.OPEN_EXTENSION.length());
    }
View Full Code Here

    return r;
  }

  public static Resource getResource(URL url, long offset)
      throws IOException, ResourceNotAvailableException {
    Resource r = null;
    String name = url.getFile();
    if (isArc(name)) {

      ARCReader reader = ARCReaderFactory.get(url, offset);
      r = ARCArchiveRecordToResource(reader.get(),reader);
View Full Code Here

  }

  private void handleReplay(WaybackRequest wbRequest,
      HttpServletRequest httpRequest, HttpServletResponse httpResponse)
  throws IOException, ServletException {
    Resource resource = null;
    try {
      SearchResults results = collection.getResourceIndex().query(wbRequest);
      if(!(results instanceof CaptureSearchResults)) {
        throw new ResourceNotAvailableException("Bad results...");
      }
      CaptureSearchResults captureResults = (CaptureSearchResults) results;
 
      // TODO: check which versions are actually accessible right now?
      SearchResult closest = captureResults.getClosest(wbRequest);
      resource = collection.getResourceStore().retrieveResource(closest);
 
      replay.renderResource(httpRequest, httpResponse, wbRequest,
          closest, resource, uriConverter, captureResults);
    } catch(WaybackException e) {
      logNotInArchive(e,wbRequest);
      replay.renderException(httpRequest, httpResponse, wbRequest, e);
    } finally {
      if(resource != null) {
        resource.close();
      }
    }
  }
View Full Code Here

        rules = rulesCache.get(urlString);
      } else {
        try {
         
          tmpRules = new RobotRules();
          Resource resource = webCache.getCachedResource(new URL(urlString),
              maxCacheMS,true);
          tmpRules.parse(resource);
          rulesCache.put(firstUrlString,tmpRules);
          rules = tmpRules;
         
View Full Code Here

    String errMsg = "";
    Exception origException = null;

    for ( ResourceStore store : stores ) {
      try {
        Resource r = store.retrieveResource(result);

        if ( r != null ) {
          return r;
        }
       
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.