@Test public void testCreateExcelOOXMLDocumentSlow() { try { final SearchResourceContext resourceContext = new SearchResourceContext(); resourceContext.setBusinessControlFor(olatResourcable); final Thread excelTextExtractionThread = new Thread(new Runnable() { @Override public void run() { try { FileDocumentFactory.createDocument(resourceContext, new LocalFileImpl(getTestFile("ExcelOOXMLDocumentSlow.xlsx"))); } catch (Exception e) { } } }); excelTextExtractionThread.start(); Thread.sleep(5000); assertFalse("Text extraction for Excel (xlsx) must not take longer than 2s.", excelTextExtractionThread.getState().equals(State.RUNNABLE)); } catch (final Exception e) { e.printStackTrace(); fail(e.getClass().getSimpleName() + ": " + e.getMessage()); } }
public static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf) throws IOException, DocumentException { final String fileName = leaf.getName(); final String suffix = getSuffix(fileName); if (log.isDebugEnabled()) { log.debug("suffix=" + suffix); } if (PDF_SUFFIX.indexOf(suffix) >= 0) { return PdfDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (HTML_SUFFIX.indexOf(suffix) >= 0) { return HtmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (XML_SUFFIX.indexOf(suffix) >= 0) { if (IMS_MANIFEST_FILE.equals(fileName)) { return IMSMetadataDocument.createDocument(leafResourceContext, leaf); } return XmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (TEXT_SUFFIX.indexOf(suffix) >= 0) { return TextDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(WORD_X_SUFFIX) >= 0) { return WordOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(EXCEL_X_SUFFIX) >= 0) { if (excelFileEnabled) { return ExcelOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xlsx) is not enabled."); } if (suffix.indexOf(POWERPOINT_X_SUFFIX) >= 0) { if (pptFileEnabled) { return PowerPointOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (pptx) is not enabled."); } if (WORD_SUFFIX.indexOf(suffix) >= 0) { return WordDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (POWERPOINT_SUFFIX.indexOf(suffix) >= 0) { if (pptFileEnabled) { return PowerPointDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (ppt) is not enabled."); } if (EXCEL_SUFFIX.indexOf(suffix) >= 0) { if (excelFileEnabled) { return ExcelDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xls) is not enabled."); } if (OD_TEXT_SUFFIX.indexOf(suffix) >= 0 || OD_SPREADSHEET_SUFFIX.indexOf(suffix) >= 0 || OD_PRESENTATION_SUFFIX.indexOf(suffix) >= 0 || OD_FORMULA_SUFFIX.indexOf(suffix) >= 0 || OD_GRAPHIC_SUFFIX.indexOf(suffix) >= 0) { return OpenDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } return UnkownDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); }
FileDocumentFactory { public static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf) throws IOException, DocumentException { final String fileName = leaf.getName(); final String suffix = getSuffix(fileName); if (log.isDebugEnabled()) { log.debug("suffix=" + suffix); } if (PDF_SUFFIX.indexOf(suffix) >= 0) { return PdfDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (HTML_SUFFIX.indexOf(suffix) >= 0) { return HtmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (XML_SUFFIX.indexOf(suffix) >= 0) { if (IMS_MANIFEST_FILE.equals(fileName)) { return IMSMetadataDocument.createDocument(leafResourceContext, leaf); } return XmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (TEXT_SUFFIX.indexOf(suffix) >= 0) { return TextDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(WORD_X_SUFFIX) >= 0) { return WordOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(EXCEL_X_SUFFIX) >= 0) { if (excelFileEnabled) { return ExcelOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xlsx) is not enabled."); } if (suffix.indexOf(POWERPOINT_X_SUFFIX) >= 0) { if (pptFileEnabled) { return PowerPointOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (pptx) is not enabled."); } if (WORD_SUFFIX.indexOf(suffix) >= 0) { return WordDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (POWERPOINT_SUFFIX.indexOf(suffix) >= 0) { if (pptFileEnabled) { return PowerPointDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (ppt) is not enabled."); } if (EXCEL_SUFFIX.indexOf(suffix) >= 0) { if (excelFileEnabled) { return ExcelDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xls) is not enabled."); } if (OD_TEXT_SUFFIX.indexOf(suffix) >= 0 || OD_SPREADSHEET_SUFFIX.indexOf(suffix) >= 0 || OD_PRESENTATION_SUFFIX.indexOf(suffix) >= 0 || OD_FORMULA_SUFFIX.indexOf(suffix) >= 0 || OD_GRAPHIC_SUFFIX.indexOf(suffix) >= 0) { return OpenDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } return UnkownDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } }
FileDocumentFactory { public static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf) throws IOException, DocumentException { final String fileName = leaf.getName(); final String suffix = getSuffix(fileName); if (log.isDebugEnabled()) { log.debug("suffix=" + suffix); } if (PDF_SUFFIX.indexOf(suffix) >= 0) { return PdfDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (HTML_SUFFIX.indexOf(suffix) >= 0) { return HtmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (XML_SUFFIX.indexOf(suffix) >= 0) { if (IMS_MANIFEST_FILE.equals(fileName)) { return IMSMetadataDocument.createDocument(leafResourceContext, leaf); } return XmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (TEXT_SUFFIX.indexOf(suffix) >= 0) { return TextDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(WORD_X_SUFFIX) >= 0) { return WordOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(EXCEL_X_SUFFIX) >= 0) { if (excelFileEnabled) { return ExcelOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xlsx) is not enabled."); } if (suffix.indexOf(POWERPOINT_X_SUFFIX) >= 0) { if (pptFileEnabled) { return PowerPointOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (pptx) is not enabled."); } if (WORD_SUFFIX.indexOf(suffix) >= 0) { return WordDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (POWERPOINT_SUFFIX.indexOf(suffix) >= 0) { if (pptFileEnabled) { return PowerPointDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (ppt) is not enabled."); } if (EXCEL_SUFFIX.indexOf(suffix) >= 0) { if (excelFileEnabled) { return ExcelDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xls) is not enabled."); } if (OD_TEXT_SUFFIX.indexOf(suffix) >= 0 || OD_SPREADSHEET_SUFFIX.indexOf(suffix) >= 0 || OD_PRESENTATION_SUFFIX.indexOf(suffix) >= 0 || OD_FORMULA_SUFFIX.indexOf(suffix) >= 0 || OD_GRAPHIC_SUFFIX.indexOf(suffix) >= 0) { return OpenDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } return UnkownDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } FileDocumentFactory(final SearchModule searchModule, MimeTypeProvider mimeTypeProvider);  FileDocumentFactory(final SearchModule searchModule); }
FileDocumentFactory { public static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf) throws IOException, DocumentException { final String fileName = leaf.getName(); final String suffix = getSuffix(fileName); if (log.isDebugEnabled()) { log.debug("suffix=" + suffix); } if (PDF_SUFFIX.indexOf(suffix) >= 0) { return PdfDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (HTML_SUFFIX.indexOf(suffix) >= 0) { return HtmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (XML_SUFFIX.indexOf(suffix) >= 0) { if (IMS_MANIFEST_FILE.equals(fileName)) { return IMSMetadataDocument.createDocument(leafResourceContext, leaf); } return XmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (TEXT_SUFFIX.indexOf(suffix) >= 0) { return TextDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(WORD_X_SUFFIX) >= 0) { return WordOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(EXCEL_X_SUFFIX) >= 0) { if (excelFileEnabled) { return ExcelOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xlsx) is not enabled."); } if (suffix.indexOf(POWERPOINT_X_SUFFIX) >= 0) { if (pptFileEnabled) { return PowerPointOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (pptx) is not enabled."); } if (WORD_SUFFIX.indexOf(suffix) >= 0) { return WordDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (POWERPOINT_SUFFIX.indexOf(suffix) >= 0) { if (pptFileEnabled) { return PowerPointDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (ppt) is not enabled."); } if (EXCEL_SUFFIX.indexOf(suffix) >= 0) { if (excelFileEnabled) { return ExcelDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xls) is not enabled."); } if (OD_TEXT_SUFFIX.indexOf(suffix) >= 0 || OD_SPREADSHEET_SUFFIX.indexOf(suffix) >= 0 || OD_PRESENTATION_SUFFIX.indexOf(suffix) >= 0 || OD_FORMULA_SUFFIX.indexOf(suffix) >= 0 || OD_GRAPHIC_SUFFIX.indexOf(suffix) >= 0) { return OpenDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } return UnkownDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } FileDocumentFactory(final SearchModule searchModule, MimeTypeProvider mimeTypeProvider);  FileDocumentFactory(final SearchModule searchModule); static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf); boolean isFileSupported(final VFSLeaf leaf); int getExcludedFileSizeCount(); void resetExcludedFileSizeCount(); }
FileDocumentFactory { public static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf) throws IOException, DocumentException { final String fileName = leaf.getName(); final String suffix = getSuffix(fileName); if (log.isDebugEnabled()) { log.debug("suffix=" + suffix); } if (PDF_SUFFIX.indexOf(suffix) >= 0) { return PdfDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (HTML_SUFFIX.indexOf(suffix) >= 0) { return HtmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (XML_SUFFIX.indexOf(suffix) >= 0) { if (IMS_MANIFEST_FILE.equals(fileName)) { return IMSMetadataDocument.createDocument(leafResourceContext, leaf); } return XmlDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (TEXT_SUFFIX.indexOf(suffix) >= 0) { return TextDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(WORD_X_SUFFIX) >= 0) { return WordOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (suffix.indexOf(EXCEL_X_SUFFIX) >= 0) { if (excelFileEnabled) { return ExcelOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xlsx) is not enabled."); } if (suffix.indexOf(POWERPOINT_X_SUFFIX) >= 0) { if (pptFileEnabled) { return PowerPointOOXMLDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (pptx) is not enabled."); } if (WORD_SUFFIX.indexOf(suffix) >= 0) { return WordDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } if (POWERPOINT_SUFFIX.indexOf(suffix) >= 0) { if (pptFileEnabled) { return PowerPointDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of PowerPoint files (ppt) is not enabled."); } if (EXCEL_SUFFIX.indexOf(suffix) >= 0) { if (excelFileEnabled) { return ExcelDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } throw new DocumentNotEnabledException("Indexing of Excel files (xls) is not enabled."); } if (OD_TEXT_SUFFIX.indexOf(suffix) >= 0 || OD_SPREADSHEET_SUFFIX.indexOf(suffix) >= 0 || OD_PRESENTATION_SUFFIX.indexOf(suffix) >= 0 || OD_FORMULA_SUFFIX.indexOf(suffix) >= 0 || OD_GRAPHIC_SUFFIX.indexOf(suffix) >= 0) { return OpenDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } return UnkownDocument.createDocument(leafResourceContext, leaf, mimeTypeProvider.getMimeType(suffix)); } FileDocumentFactory(final SearchModule searchModule, MimeTypeProvider mimeTypeProvider);  FileDocumentFactory(final SearchModule searchModule); static Document createDocument(final SearchResourceContext leafResourceContext, final VFSLeaf leaf); boolean isFileSupported(final VFSLeaf leaf); int getExcludedFileSizeCount(); void resetExcludedFileSizeCount();  }