Package com.dotcms.repackage.org.apache.tika.metadata

Examples of com.dotcms.repackage.org.apache.tika.metadata.Metadata


    // store content metadata on disk
        File contentM=APILocator.getFileAssetAPI().getContentMetadataFile(inode);

    Tika t = new Tika();
    Metadata met = new Metadata();
    t.setMaxStringLength(-1);
    Reader fulltext = null;
    InputStream is = null;
    // if the limit is not "unlimited"
    // I can use the faster parseToString
    try {

      if(forceMemory){
        // no worry about the limit and less time to process.
        String content = t.parseToString(new FileInputStream(binFile), met);
        metaMap = new HashMap<String, String>();
        for (int i = 0; i < met.names().length; i++) {
          String name = met.names()[i];
          if (UtilMethods.isSet(name) && met.get(name) != null) {
            // we will want to normalize our metadata for searching
            String[] x = translateKey(name);
            for (String y : x)
              metaMap.put(y, met.get(name));
          }
        }
        metaMap.put(FileAssetAPI.CONTENT_FIELD, content);
      }
      else {


        is = TikaInputStream.get(binFile);
        fulltext = t.parse(is, met);
        metaMap = new HashMap<String, String>();
        for (int i = 0; i < met.names().length; i++) {
          String name = met.names()[i];
          if (UtilMethods.isSet(name) && met.get(name) != null) {
            // we will want to normalize our metadata for searching
            String[] x = translateKey(name);
            for (String y : x)
              metaMap.put(y, met.get(name));
          }
        }

        if(!contentM.exists() && contentM.getParentFile().mkdirs() && contentM.createNewFile()) {
          OutputStream out=new FileOutputStream(contentM);
View Full Code Here

TOP

Related Classes of com.dotcms.repackage.org.apache.tika.metadata.Metadata

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.