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