/** * Returns a lucene document factory for given resource type and MIME type.<p> * * The type of the document factory is selected according to the configuration * in <code>opencms-search.xml</code>.<p> * * @param resourceType the resource type name * @param mimeType the MIME type * * @return a lucene document factory or null in case no matching factory was found */ public I_CmsDocumentFactory getDocumentFactory(String resourceType, String mimeType) { I_CmsDocumentFactory result = null; if (resourceType != null) { // create the factory lookup key for the document String documentTypeKey = A_CmsVfsDocument.getDocumentKey(resourceType, mimeType); // check if a setting is available for this specific MIME type result = m_documentTypes.get(documentTypeKey); if (result == null) { // no setting is available, try to use a generic setting without MIME type result = m_documentTypes.get(A_CmsVfsDocument.getDocumentKey(resourceType, null)); // please note: the result may still be null } } return result; }
/** * @see org.opencms.search.documents.I_CmsDocumentFactory#getDocumentKeys(java.util.List, java.util.List) */ public List<String> getDocumentKeys(List<String> resourceTypes, List<String> mimeTypes) throws CmsException { List<String> keys = new ArrayList<String>(); if (resourceTypes.contains("*")) { List<String> allTypes = new ArrayList<String>(); for (Iterator<I_CmsResourceType> i = OpenCms.getResourceManager().getResourceTypes().iterator(); i.hasNext();) { I_CmsResourceType resourceType = i.next(); allTypes.add(resourceType.getTypeName()); } resourceTypes = allTypes; } try { for (Iterator<String> i = resourceTypes.iterator(); i.hasNext();) { String typeName = i.next(); for (Iterator<String> j = mimeTypes.iterator(); j.hasNext();) { keys.add(getDocumentKey(typeName, j.next())); } if (mimeTypes.isEmpty()) { keys.add(getDocumentKey(typeName, null)); } } } catch (Exception exc) { throw new CmsException(Messages.get().container(Messages.ERR_CREATE_DOC_KEY_0), exc); } return keys; }
/** * @see org.opencms.search.documents.I_CmsDocumentFactory#getDocumentKeys(java.util.List, java.util.List) */ public List<String> getDocumentKeys(List<String> resourceTypes, List<String> mimeTypes) throws CmsException { List<String> keys = new ArrayList<String>(); if (resourceTypes.contains("*")) { List<String> allTypes = new ArrayList<String>(); for (Iterator<I_CmsResourceType> i = OpenCms.getResourceManager().getResourceTypes().iterator(); i.hasNext();) { I_CmsResourceType resourceType = i.next(); allTypes.add(resourceType.getTypeName()); } resourceTypes = allTypes; } try { for (Iterator<String> i = resourceTypes.iterator(); i.hasNext();) { String typeName = OpenCms.getResourceManager().getResourceType(i.next()).getTypeName(); for (Iterator<String> j = mimeTypes.iterator(); j.hasNext();) { keys.add(getDocumentKey(typeName, j.next())); } if (mimeTypes.isEmpty()) { keys.add(getDocumentKey(typeName, null)); } } } catch (Exception exc) { throw new CmsException(Messages.get().container(Messages.ERR_CREATE_DOC_KEY_0), exc); } return keys; }
String documentTypeKey = A_CmsVfsDocument.getDocumentKey(typeName, mimeType); result = m_documentTypes.get(A_CmsVfsDocument.getDocumentKey(typeName, null));