001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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 indexQuerySuggestionDictionaries(SearchContext searchContext)
057                    throws SearchException {
058    
059                    if (_spellCheckIndexWriter == null) {
060                            if (_log.isDebugEnabled()) {
061                                    _log.debug("No spell check index writer configured");
062                            }
063                    }
064    
065                    _spellCheckIndexWriter.indexQuerySuggestionDictionaries(searchContext);
066            }
067    
068            @Override
069            public void indexQuerySuggestionDictionary(SearchContext searchContext)
070                    throws SearchException {
071    
072                    if (_spellCheckIndexWriter == null) {
073                            if (_log.isDebugEnabled()) {
074                                    _log.debug("No spell check index writer configured");
075                            }
076                    }
077    
078                    _spellCheckIndexWriter.indexQuerySuggestionDictionary(searchContext);
079            }
080    
081            @Override
082            public void indexSpellCheckerDictionaries(SearchContext searchContext)
083                    throws SearchException {
084    
085                    if (_spellCheckIndexWriter == null) {
086                            if (_log.isDebugEnabled()) {
087                                    _log.debug("No spell check index writer configured");
088                            }
089                    }
090    
091                    _spellCheckIndexWriter.indexSpellCheckerDictionaries(searchContext);
092            }
093    
094            @Override
095            public void indexSpellCheckerDictionary(SearchContext searchContext)
096                    throws SearchException {
097    
098                    if (_spellCheckIndexWriter == null) {
099                            if (_log.isDebugEnabled()) {
100                                    _log.debug("No spell check index writer configured");
101                            }
102                    }
103    
104                    _spellCheckIndexWriter.indexSpellCheckerDictionary(searchContext);
105            }
106    
107            public void setSpellCheckIndexWriter(
108                    SpellCheckIndexWriter spellCheckIndexWriter) {
109    
110                    _spellCheckIndexWriter = spellCheckIndexWriter;
111            }
112    
113            private static Log _log = LogFactoryUtil.getLog(BaseIndexWriter.class);
114    
115            private SpellCheckIndexWriter _spellCheckIndexWriter;
116    
117    }