You can remove the getFileFormat() function and the tika*.jar and replace the UpdateIndexFileDocument main part with
// BEGIN USER CODE
InputStream is = null;
if (filedocument.getHasContents()== false) {
return false;
}
try {
is = Core.getFileDocumentContent(getContext(), filedocument.getMendixObject());
} catch (Exception e) {
logger.error("Error reading stream, file is missing from disk " + filedocument.getName());
return false;
}
try {
String text = null;
int pos = filedocument.getName().lastIndexOf('.');
String ext = filedocument.getName().substring(pos+1).toLowerCase();
logger.debug("Index file document, filetype " + ext);
switch (ext){
case "pdf":
text = textFromPDF(is);
break;
case "doc":
case "xls":
text = textFromOffice97(is);
break;
case "docx":
text = textFromOfficeX(is);
break;
case "xlsx":
text = textFromXLSX(is);
break;
case "pptx":
text = textFromPPTX(is);
break;
case "xml":
text = textFromXML(is);
break;
case "html":
text = textFromHTML(is);
break;
case "txt":
text = textFromTextFile(is);
break;
default:
logger.error("Unsupported file type " + ext + " " + filedocument.getName());
break;
}
if (text != null && !text.isEmpty()) {
// Add the tag-stripped contents as a Reader-valued Text field so it will
// get tokenized and indexed.
StringReader reader = new StringReader(text);
Document doc = new Document();
doc.add(new TextField(LuceneFactory.TEXT, reader));
doc.add(new TextField(LuceneFactory.MXTYPE, __filedocument.getType(), Field.Store.YES));
doc.add(new TextField(LuceneFactory.MXID, Long.toString(__filedocument.getId().toLong()), Field.Store.YES));
LuceneFactory.getInstance().addDocumentQueued(indexId, doc);
}
} catch (Exception e){
logger.error("Error indexing filedocument", e);
}
return true;
Easy and safe way to join or combine your confidential data files such as PDF files which includes your personal data as well is Merge PDF Tool This Software is built with complete security that no data loss will be entertained in using the tool. You can trust the tool as I have personally used it before. visit https://www.osttopstapp.com/merge-pdf.html