Examples of ARCWriter


Examples of org.archive.io.arc.ARCWriter

      throw e;
    }
   
    // store URL
    ARCLocation location = null;
    ARCWriter writer = null;
    try {
      writer = cache.getWriter();
      location = storeFile(tmpFile, writer, urlString, method);
    } catch(IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of org.archive.io.arc.ARCWriter

    if(!arcDir.isDirectory()) {
      arcDir.mkdir();
    }
    File [] files = {arcDir};
    boolean compress = true;
    ARCWriter writer = new ARCWriter(new AtomicInteger(),
        Arrays.asList(files), "test", compress,
        DEFAULT_MAX_ARC_FILE_SIZE);
    Properties p = new Properties();
    p.setProperty(ARCCacheDirectory.LIVE_WEB_ARC_DIR, args[0]);
    p.setProperty(ARCCacheDirectory.LIVE_WEB_ARC_PREFIX, "test");
    p.setProperty(CACHE_PATH, arcDir.getAbsolutePath());

    URLCacher uc = new URLCacher();
    ARCCacheDirectory cache = new ARCCacheDirectory();
//    try {
////      cache.init(p);
////      uc.init(p);
//    } catch (ConfigurationException e) {
//      e.printStackTrace();
//      System.exit(1);
//    }
    for(int k = 1; k < args.length; k++) {
      try {
        url = new URL(args[k]);
      } catch (MalformedURLException e1) {
        e1.printStackTrace();
        continue;
      }
      try {
        uc.cache(cache, url.toString());
      } catch (URIException e) {
        e.printStackTrace();
      } catch (LiveDocumentNotAvailableException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
    try {
      writer.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

Examples of org.archive.io.arc.ARCWriter

   */
  public void directoryToArc(File srcDir, File tgtDir, String prefix)
  throws IOException {
   
    File target[] = {tgtDir};
    ARCWriter writer = new ARCWriter(new AtomicInteger(),
        Arrays.asList(target),prefix,true,
        ARCConstants.DEFAULT_MAX_ARC_FILE_SIZE);
    File sources[] = srcDir.listFiles();
    logger.info("Found " + sources.length + " files in " + srcDir);
    for(int i = 0; i<sources.length; i++) {
      addFile(sources[i]);
    }
    logger.info("Associated " + sources.length + " files in " + srcDir);

    // sort keys and write them all:
    Object arr[] = components.keySet().toArray();
    Arrays.sort(arr);
    for(int i = 0; i < arr.length; i++) {
      String key = (String) arr[i];
      RecordComponents rc = components.get(key);
      rc.writeRecord(writer,srcDir);
      logger.info("Wrote record keyed " + rc.key);     
    }
    writer.close();
    logger.info("Closed arc file named " +
        writer.getFile().getAbsolutePath());
  }
View Full Code Here

Examples of org.archive.io.arc.ARCWriter

       FileUtils.assertReadable(dir);
       WARCReader reader = WARCReaderFactory.get(warc);
       List<String> metadata =  new ArrayList<String>();
       metadata.add("Made from " + reader.getReaderIdentifier() + " by " +
           this.getClass().getName() + "/" + getRevision());
       ARCWriter writer =
           new ARCWriter(
                   new AtomicInteger(),
                   new WriterPoolSettingsData(
                           prefix,
                           suffix,
                           -12,
View Full Code Here

Examples of org.archive.io.arc.ARCWriter

            setTotalBytesWritten(getTotalBytesWritten() +
              (writer.getPosition() - position));
            position = writer.getPosition();
        }
       
        ARCWriter w = (ARCWriter)writer;
        try {
            if (in instanceof ReplayInputStream) {
                w.write(curi.toString(), curi.getContentType(),
                    ip, curi.getFetchBeginTime(),
                    recordLength, (ReplayInputStream)in);
            } else {
                w.write(curi.toString(), curi.getContentType(),
                    ip, curi.getFetchBeginTime(),
                    recordLength, in);
            }
        } catch (IOException e) {
            // Invalidate this file (It gets a '.invalid' suffix).
View Full Code Here

Examples of org.archive.io.arc.ARCWriter

  public void directoryToArc(File srcDir, File tgtDir, String prefix)
  throws IOException {
   
    File target[] = {tgtDir};

    ARCWriter writer = new ARCWriter(new AtomicInteger(),
        getSettings(true,prefix,Arrays.asList(target)));
    File sources[] = srcDir.listFiles();
    LOGGER.info("Found " + sources.length + " files in " + srcDir);
    for(int i = 0; i<sources.length; i++) {
      addFile(sources[i]);
    }
    LOGGER.info("Associated " + sources.length + " files in " + srcDir);

    // sort keys and write them all:
    Object arr[] = components.keySet().toArray();
    Arrays.sort(arr);
    for(int i = 0; i < arr.length; i++) {
      String key = (String) arr[i];
      RecordComponents rc = components.get(key);
      rc.writeRecord(writer,srcDir);
      LOGGER.info("Wrote record keyed " + rc.key);     
    }
    writer.close();
    LOGGER.info("Closed arc file named " +
        writer.getFile().getAbsolutePath());
  }
View Full Code Here

Examples of org.archive.io.arc.ARCWriter

        getMethod.releaseConnection();
      }
    }

    // now write the content, or a fake record:
    ARCWriter writer = null;
    ReplayInputStream replayIS = null;
    try {
      writer = cache.getWriter();
      if(gotUrl) {
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.