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