コード例 #1
0
ファイル: Indexer.java プロジェクト: danyaljj/BlackLab
 public void indexGzip(final String gzFileName, InputStream gzipStream) {
   if (!TarGzipReader.canProcessTarGzip()) {
     // Apache commons-compress not found, skip file
     terminateIndexing =
         !getListener()
             .errorOccurred(
                 "Cannot index .gz, Apache common-compress not on classpath",
                 "tgz",
                 new File(gzFileName),
                 null);
     // logger.warn("Skipping " + tgzFileName + ", Apache common-compress not found on
     // classpath!");
     return;
   }
   TarGzipReader.processGzip(
       gzFileName,
       gzipStream,
       new FileHandler() {
         @Override
         public boolean handle(String filePath, InputStream contents) {
           try {
             indexInputStream(filePath, contents, "*", false);
           } catch (Exception e) {
             log("*** Error indexing .gz file: " + filePath, e);
             terminateIndexing =
                 !getListener()
                     .errorOccurred(e.getMessage(), "gz", new File(filePath), new File(filePath));
           }
           return continueIndexing();
         }
       });
 }
コード例 #2
0
ファイル: Indexer.java プロジェクト: danyaljj/BlackLab
 public void indexTarGzip(
     final String tgzFileName,
     InputStream tarGzipStream,
     final String glob,
     final boolean recurseArchives) {
   if (!TarGzipReader.canProcessTarGzip()) {
     // Apache commons-compress not found, skip file
     terminateIndexing =
         !getListener()
             .errorOccurred(
                 "Cannot index .tar.gz, Apache common-compress not on classpath",
                 "tgz",
                 new File(tgzFileName),
                 null);
     // logger.warn("Skipping " + tgzFileName + ", Apache common-compress not found on
     // classpath!");
     return;
   }
   final Pattern pattGlob = Pattern.compile(FileUtil.globToRegex(glob));
   TarGzipReader.processTarGzip(
       tarGzipStream,
       new FileHandler() {
         @Override
         public boolean handle(String filePath, InputStream contents) {
           try {
             File f = new File(filePath);
             String fn = f.getName();
             Matcher m = pattGlob.matcher(fn);
             if (m.matches()) {
               String entryName = tgzFileName + File.separator + filePath;
               indexInputStream(entryName, contents, glob, recurseArchives);
             } else {
               boolean isArchive =
                   fn.endsWith(".zip") || fn.endsWith(".gz") || fn.endsWith(".tgz");
               if (isArchive) {
                 if (recurseArchives && processArchivesAsDirectories) {
                   indexInputStream(
                       tgzFileName + File.pathSeparator + filePath,
                       contents,
                       glob,
                       recurseArchives);
                 }
               }
             }
           } catch (Exception e) {
             log("*** Error indexing tgz file: " + tgzFileName, e);
             terminateIndexing =
                 !getListener()
                     .errorOccurred(
                         e.getMessage(), "tgz", new File(tgzFileName), new File(filePath));
           }
           return continueIndexing();
         }
       });
 }