001    /**
002     * Copyright (c) 2000-present 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.search.filter.BooleanFilter;
018    import com.liferay.portal.kernel.util.ArrayUtil;
019    import com.liferay.portal.kernel.util.StringPool;
020    
021    import java.util.Locale;
022    
023    import javax.portlet.PortletRequest;
024    import javax.portlet.PortletResponse;
025    
026    /**
027     * @author Eudaldo Alonso
028     * @author L??szl?? Csontos
029     */
030    public abstract class BaseSearcher extends BaseIndexer<Object> {
031    
032            @Override
033            public String getClassName() {
034                    return StringPool.BLANK;
035            }
036    
037            @Override
038            public IndexerPostProcessor[] getIndexerPostProcessors() {
039                    throw new UnsupportedOperationException();
040            }
041    
042            @Override
043            public void postProcessSearchQuery(
044                            BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
045                            SearchContext searchContext)
046                    throws Exception {
047    
048                    String[] classNames = getSearchClassNames();
049    
050                    if (ArrayUtil.isEmpty(classNames)) {
051                            return;
052                    }
053    
054                    for (String className : classNames) {
055                            Indexer<?> indexer = IndexerRegistryUtil.getIndexer(className);
056    
057                            if (indexer == null) {
058                                    continue;
059                            }
060    
061                            indexer.postProcessSearchQuery(
062                                    searchQuery, fullQueryBooleanFilter, searchContext);
063                    }
064            }
065    
066            @Override
067            public void registerIndexerPostProcessor(
068                    IndexerPostProcessor indexerPostProcessor) {
069    
070                    throw new UnsupportedOperationException();
071            }
072    
073            @Override
074            protected void doDelete(Object obj) throws Exception {
075                    throw new UnsupportedOperationException();
076            }
077    
078            @Override
079            protected Document doGetDocument(Object obj) throws Exception {
080                    throw new UnsupportedOperationException();
081            }
082    
083            @Override
084            protected Summary doGetSummary(
085                            Document document, Locale locale, String snippet,
086                            PortletRequest portletRequest, PortletResponse portletResponse)
087                    throws Exception {
088    
089                    throw new UnsupportedOperationException();
090            }
091    
092            /**
093             * @deprecated As of 7.0.0, added strictly to support backwards
094             *             compatibility of {@link
095             *             Indexer#postProcessSearchQuery(BooleanQuery, SearchContext)}
096             */
097            @Deprecated
098            @Override
099            protected void doPostProcessSearchQuery(
100                            Indexer<?> indexer, BooleanQuery searchQuery,
101                            SearchContext searchContext)
102                    throws Exception {
103            }
104    
105            @Override
106            protected void doReindex(Object obj) throws Exception {
107                    throw new UnsupportedOperationException();
108            }
109    
110            @Override
111            protected void doReindex(String className, long classPK) throws Exception {
112                    throw new UnsupportedOperationException();
113            }
114    
115            @Override
116            protected void doReindex(String[] ids) throws Exception {
117                    throw new UnsupportedOperationException();
118            }
119    
120    }