// 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);