001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/search/documents/CmsDocumentGeneric.java,v $
003: * Date : $Date: 2008-02-27 12:05:21 $
004: * Version: $Revision: 1.10 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.search.documents;
033:
034: import org.opencms.file.CmsObject;
035: import org.opencms.file.CmsResource;
036: import org.opencms.search.CmsIndexException;
037: import org.opencms.search.CmsSearchIndex;
038: import org.opencms.search.extractors.CmsExtractionResult;
039: import org.opencms.search.extractors.I_CmsExtractionResult;
040:
041: /**
042: * Lucene document factory class for indexing data from a generic <code>{@link CmsResource}</code>.<p>
043: *
044: * Since the document type is generic, no content extraction is performed for the resource.
045: * However, meta data from the properties and attributes of the resource are indexed.<p>
046: *
047: * The class is useful for example to have images appear in the search result if the title of the image
048: * matched the search query. It's also used if no specific extraction method is available for a binary document type.<p>
049: *
050: * @author Alexander Kandzior
051: *
052: * @version $Revision: 1.10 $
053: *
054: * @since 6.0.0
055: */
056: public class CmsDocumentGeneric extends A_CmsVfsDocument {
057:
058: /**
059: * Creates a new instance of this lucene document factory.<p>
060: *
061: * @param name name of the documenttype
062: */
063: public CmsDocumentGeneric(String name) {
064:
065: super (name);
066: }
067:
068: /**
069: * Just returns an empty extraction result since the content can't be extracted form a generic resource.<p>
070: *
071: * @see org.opencms.search.documents.I_CmsSearchExtractor#extractContent(CmsObject, CmsResource, CmsSearchIndex)
072: */
073: public I_CmsExtractionResult extractContent(CmsObject cms,
074: CmsResource resource, CmsSearchIndex index)
075: throws CmsIndexException {
076:
077: if (resource == null) {
078: throw new CmsIndexException(Messages.get().container(
079: Messages.ERR_NO_RAW_CONTENT_1, index.getLocale()));
080: }
081: // just return an empty result set
082: return new CmsExtractionResult("");
083: }
084:
085: /**
086: * @see org.opencms.search.documents.I_CmsDocumentFactory#isLocaleDependend()
087: */
088: public boolean isLocaleDependend() {
089:
090: return false;
091: }
092:
093: /**
094: * @see org.opencms.search.documents.I_CmsDocumentFactory#isUsingCache()
095: */
096: public boolean isUsingCache() {
097:
098: return false;
099: }
100: }
|