I_CmsDocumentFactory result = OpenCms.getSearchManager().getDocumentFactory(res); if (result != null) {
/** * @see org.opencms.search.CmsSearchIndex#getDocumentFactory(org.opencms.file.CmsResource) */ @Override public I_CmsDocumentFactory getDocumentFactory(CmsResource res) { if (isIndexing(res)) { if (OpenCms.getResourceManager().getResourceType(res) instanceof CmsResourceTypeXmlContainerPage) { return OpenCms.getSearchManager().getDocumentFactory( CmsSolrDocumentContainerPage.TYPE_CONTAINERPAGE_SOLR, "text/html"); } if (CmsResourceTypeXmlContent.isXmlContent(res)) { return OpenCms.getSearchManager().getDocumentFactory( CmsSolrDocumentXmlContent.TYPE_XMLCONTENT_SOLR, "text/html"); } else { return super.getDocumentFactory(res); } } return null; }
/** * Returns a lucene document factory for given resource.<p> * * The type of the document factory is selected by the type of the resource * and the MIME type of the resource content, according to the configuration in <code>opencms-search.xml</code>.<p> * * @param resource a cms resource * @return a lucene document factory or null */ public I_CmsDocumentFactory getDocumentFactory(CmsResource resource) { // first get the MIME type of the resource String mimeType = OpenCms.getResourceManager().getMimeType(resource.getRootPath(), null, "unknown"); String resourceType = null; try { resourceType = OpenCms.getResourceManager().getResourceType(resource.getTypeId()).getTypeName(); } catch (CmsLoaderException e) { // ignore, unknown resource type, resource can not be indexed LOG.info(e.getLocalizedMessage(), e); } return getDocumentFactory(resourceType, mimeType); }
/** * Checks if the given resource should be indexed by this index or not.<p> * * @param res the resource candidate * * @return <code>true</code> if the given resource should be indexed or <code>false</code> if not */ protected boolean isIndexing(CmsResource res) { if ((res != null) && (getSources() != null)) { I_CmsDocumentFactory result = OpenCms.getSearchManager().getDocumentFactory(res); for (CmsSearchIndexSource source : getSources()) { if (source.isIndexing(res.getRootPath(), CmsSolrDocumentContainerPage.TYPE_CONTAINERPAGE_SOLR) || source.isIndexing(res.getRootPath(), CmsSolrDocumentXmlContent.TYPE_XMLCONTENT_SOLR) || source.isIndexing(res.getRootPath(), result.getName())) { return true; } } } return false; }
I_CmsDocumentFactory result = OpenCms.getSearchManager().getDocumentFactory(res); if (result != null) {