001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.search;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    
020    /**
021     * @author Michael C. Han
022     */
023    public abstract class BaseIndexWriter
024            implements IndexWriter, SpellCheckIndexWriter {
025    
026            @Override
027            public void clearQuerySuggestionDictionaryIndexes(
028                            SearchContext searchContext)
029                    throws SearchException {
030    
031                    if (_spellCheckIndexWriter == null) {
032                            if (_log.isDebugEnabled()) {
033                                    _log.debug("No spell check index writer configured");
034                            }
035                    }
036    
037                    _spellCheckIndexWriter.clearQuerySuggestionDictionaryIndexes(
038                            searchContext);
039            }
040    
041            @Override
042            public void clearSpellCheckerDictionaryIndexes(SearchContext searchContext)
043                    throws SearchException {
044    
045                    if (_spellCheckIndexWriter == null) {
046                            if (_log.isDebugEnabled()) {
047                                    _log.debug("No spell check index writer configured");
048                            }
049                    }
050    
051                    _spellCheckIndexWriter.clearSpellCheckerDictionaryIndexes(
052                            searchContext);
053            }
054    
055            @Override
056            public void indexKeyword(
057                            SearchContext searchContext, float weight, String keywordType)
058                    throws SearchException {
059    
060                    if (_spellCheckIndexWriter == null) {
061                            if (_log.isDebugEnabled()) {
062                                    _log.debug("No spell check index writer configured");
063                            }
064                    }
065    
066                    _spellCheckIndexWriter.indexKeyword(searchContext, weight, keywordType);
067            }
068    
069            @Override
070            public void indexQuerySuggestionDictionaries(SearchContext searchContext)
071                    throws SearchException {
072    
073                    if (_spellCheckIndexWriter == null) {
074                            if (_log.isDebugEnabled()) {
075                                    _log.debug("No spell check index writer configured");
076                            }
077                    }
078    
079                    _spellCheckIndexWriter.indexQuerySuggestionDictionaries(searchContext);
080            }
081    
082            @Override
083            public void indexQuerySuggestionDictionary(SearchContext searchContext)
084                    throws SearchException {
085    
086                    if (_spellCheckIndexWriter == null) {
087                            if (_log.isDebugEnabled()) {
088                                    _log.debug("No spell check index writer configured");
089                            }
090                    }
091    
092                    _spellCheckIndexWriter.indexQuerySuggestionDictionary(searchContext);
093            }
094    
095            @Override
096            public void indexSpellCheckerDictionaries(SearchContext searchContext)
097                    throws SearchException {
098    
099                    if (_spellCheckIndexWriter == null) {
100                            if (_log.isDebugEnabled()) {
101                                    _log.debug("No spell check index writer configured");
102                            }
103                    }
104    
105                    _spellCheckIndexWriter.indexSpellCheckerDictionaries(searchContext);
106            }
107    
108            @Override
109            public void indexSpellCheckerDictionary(SearchContext searchContext)
110                    throws SearchException {
111    
112                    if (_spellCheckIndexWriter == null) {
113                            if (_log.isDebugEnabled()) {
114                                    _log.debug("No spell check index writer configured");
115                            }
116                    }
117    
118                    _spellCheckIndexWriter.indexSpellCheckerDictionary(searchContext);
119            }
120    
121            public void setSpellCheckIndexWriter(
122                    SpellCheckIndexWriter spellCheckIndexWriter) {
123    
124                    _spellCheckIndexWriter = spellCheckIndexWriter;
125            }
126    
127            private static Log _log = LogFactoryUtil.getLog(BaseIndexWriter.class);
128    
129            private SpellCheckIndexWriter _spellCheckIndexWriter;
130    
131    }