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.backgroundtask.BackgroundTask;
018    import com.liferay.portal.kernel.util.ProxyFactory;
019    
020    import java.io.Serializable;
021    
022    import java.util.Collection;
023    import java.util.Locale;
024    import java.util.Map;
025    
026    /**
027     * @author Michael C. Han
028     */
029    public class IndexWriterHelperUtil {
030    
031            public static void addDocument(
032                            String searchEngineId, long companyId, Document document,
033                            boolean commitImmediately)
034                    throws SearchException {
035    
036                    _indexWriterHelper.addDocument(
037                            searchEngineId, companyId, document, commitImmediately);
038            }
039    
040            public static void addDocuments(
041                            String searchEngineId, long companyId,
042                            Collection<Document> documents, boolean commitImmediately)
043                    throws SearchException {
044    
045                    _indexWriterHelper.addDocuments(
046                            searchEngineId, companyId, documents, commitImmediately);
047            }
048    
049            public static void commit(String searchEngineId) throws SearchException {
050                    _indexWriterHelper.commit(searchEngineId);
051            }
052    
053            public static void commit(String searchEngineId, long companyId)
054                    throws SearchException {
055    
056                    _indexWriterHelper.commit(searchEngineId, companyId);
057            }
058    
059            public static void deleteDocument(
060                            String searchEngineId, long companyId, String uid,
061                            boolean commitImmediately)
062                    throws SearchException {
063    
064                    _indexWriterHelper.deleteDocument(
065                            searchEngineId, companyId, uid, commitImmediately);
066            }
067    
068            public static void deleteDocuments(
069                            String searchEngineId, long companyId, Collection<String> uids,
070                            boolean commitImmediately)
071                    throws SearchException {
072    
073                    _indexWriterHelper.deleteDocuments(
074                            searchEngineId, companyId, uids, commitImmediately);
075            }
076    
077            public static void deleteEntityDocuments(
078                            String searchEngineId, long companyId, String className,
079                            boolean commitImmediately)
080                    throws SearchException {
081    
082                    _indexWriterHelper.deleteEntityDocuments(
083                            searchEngineId, companyId, className, commitImmediately);
084            }
085    
086            public static int getReindexTaskCount(long groupId, boolean completed)
087                    throws SearchException {
088    
089                    return _indexWriterHelper.getReindexTaskCount(groupId, completed);
090            }
091    
092            public static void indexKeyword(
093                            long companyId, String querySuggestion, float weight,
094                            String keywordType, Locale locale)
095                    throws SearchException {
096    
097                    _indexWriterHelper.indexKeyword(
098                            companyId, querySuggestion, weight, keywordType, locale);
099            }
100    
101            public static void indexKeyword(
102                            String searchEngineId, long companyId, String querySuggestion,
103                            float weight, String keywordType, Locale locale)
104                    throws SearchException {
105    
106                    _indexWriterHelper.indexKeyword(
107                            searchEngineId, companyId, querySuggestion, weight, keywordType,
108                            locale);
109            }
110    
111            public static void indexQuerySuggestionDictionaries(long companyId)
112                    throws SearchException {
113    
114                    _indexWriterHelper.indexQuerySuggestionDictionaries(companyId);
115            }
116    
117            public static void indexQuerySuggestionDictionaries(
118                            String searchEngineId, long companyId)
119                    throws SearchException {
120    
121                    _indexWriterHelper.indexQuerySuggestionDictionaries(
122                            searchEngineId, companyId);
123            }
124    
125            public static void indexQuerySuggestionDictionary(
126                            long companyId, Locale locale)
127                    throws SearchException {
128    
129                    _indexWriterHelper.indexQuerySuggestionDictionary(companyId, locale);
130            }
131    
132            public static void indexQuerySuggestionDictionary(
133                            String searchEngineId, long companyId, Locale locale)
134                    throws SearchException {
135    
136                    _indexWriterHelper.indexQuerySuggestionDictionary(
137                            searchEngineId, companyId, locale);
138            }
139    
140            public static void indexSpellCheckerDictionaries(long companyId)
141                    throws SearchException {
142    
143                    _indexWriterHelper.indexSpellCheckerDictionaries(companyId);
144            }
145    
146            public static void indexSpellCheckerDictionaries(
147                            String searchEngineId, long companyId)
148                    throws SearchException {
149    
150                    _indexWriterHelper.indexSpellCheckerDictionaries(
151                            searchEngineId, companyId);
152            }
153    
154            public static void indexSpellCheckerDictionary(
155                            long companyId, Locale locale)
156                    throws SearchException {
157    
158                    _indexWriterHelper.indexSpellCheckerDictionary(companyId, locale);
159            }
160    
161            public static void indexSpellCheckerDictionary(
162                            String searchEngineId, long companyId, Locale locale)
163                    throws SearchException {
164    
165                    _indexWriterHelper.indexSpellCheckerDictionary(
166                            searchEngineId, companyId, locale);
167            }
168    
169            public static boolean isIndexReadOnly() {
170                    return _indexWriterHelper.isIndexReadOnly();
171            }
172    
173            public static void partiallyUpdateDocument(
174                            String searchEngineId, long companyId, Document document,
175                            boolean commitImmediately)
176                    throws SearchException {
177    
178                    _indexWriterHelper.partiallyUpdateDocument(
179                            searchEngineId, companyId, document, commitImmediately);
180            }
181    
182            public static void partiallyUpdateDocuments(
183                            String searchEngineId, long companyId,
184                            Collection<Document> documents, boolean commitImmediately)
185                    throws SearchException {
186    
187                    _indexWriterHelper.partiallyUpdateDocuments(
188                            searchEngineId, companyId, documents, commitImmediately);
189            }
190    
191            public static BackgroundTask reindex(
192                            long userId, String jobName, long[] companyIds,
193                            Map<String, Serializable> taskContextMap)
194                    throws SearchException {
195    
196                    return _indexWriterHelper.reindex(
197                            userId, jobName, companyIds, taskContextMap);
198            }
199    
200            public static BackgroundTask reindex(
201                            long userId, String jobName, long[] companyIds, String className,
202                            Map<String, Serializable> taskContextMap)
203                    throws SearchException {
204    
205                    return _indexWriterHelper.reindex(
206                            userId, jobName, companyIds, className, taskContextMap);
207            }
208    
209            public static void setIndexReadOnly(boolean indexReadOnly) {
210                    _indexWriterHelper.setIndexReadOnly(indexReadOnly);
211            }
212    
213            public static void updateDocument(
214                            String searchEngineId, long companyId, Document document,
215                            boolean commitImmediately)
216                    throws SearchException {
217    
218                    _indexWriterHelper.updateDocument(
219                            searchEngineId, companyId, document, commitImmediately);
220            }
221    
222            public static void updateDocuments(
223                            String searchEngineId, long companyId,
224                            Collection<Document> documents, boolean commitImmediately)
225                    throws SearchException {
226    
227                    _indexWriterHelper.updateDocuments(
228                            searchEngineId, companyId, documents, commitImmediately);
229            }
230    
231            public static void updatePermissionFields(String name, String primKey) {
232                    _indexWriterHelper.updatePermissionFields(name, primKey);
233            }
234    
235            private static final IndexWriterHelper _indexWriterHelper =
236                    ProxyFactory.newServiceTrackedInstance(IndexWriterHelper.class);
237    
238    }