001    /**
002     * Copyright (c) 2000-2012 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.portlet.bookmarks.model.BookmarksFolder;
018    import com.liferay.portlet.documentlibrary.model.DLFolder;
019    import com.liferay.portlet.journal.model.JournalFolder;
020    
021    import java.util.Locale;
022    
023    import javax.portlet.PortletURL;
024    
025    /**
026     * @author Eduardo Garcia
027     */
028    public class FolderSearcher extends BaseIndexer {
029    
030            public static final String[] CLASS_NAMES = {
031                    BookmarksFolder.class.getName(), DLFolder.class.getName(),
032                    JournalFolder.class.getName()
033            };
034    
035            public static Indexer getInstance() {
036                    return new FolderSearcher();
037            }
038    
039            public FolderSearcher() {
040                    setFilterSearch(true);
041                    setPermissionAware(true);
042            }
043    
044            public String[] getClassNames() {
045                    return CLASS_NAMES;
046            }
047    
048            @Override
049            public IndexerPostProcessor[] getIndexerPostProcessors() {
050                    throw new UnsupportedOperationException();
051            }
052    
053            public String getPortletId() {
054                    return null;
055            }
056    
057            @Override
058            public void registerIndexerPostProcessor(
059                    IndexerPostProcessor indexerPostProcessor) {
060    
061                    throw new UnsupportedOperationException();
062            }
063    
064            @Override
065            protected BooleanQuery createFullQuery(
066                            BooleanQuery contextQuery, SearchContext searchContext)
067                    throws Exception {
068    
069                    long[] folderIds = searchContext.getFolderIds();
070    
071                    BooleanQuery entryClassPKQuery = BooleanQueryFactoryUtil.create(
072                            searchContext);
073    
074                    for (long folderId : folderIds) {
075                            entryClassPKQuery.addTerm(Field.ENTRY_CLASS_PK, folderId);
076                    }
077    
078                    contextQuery.add(entryClassPKQuery, BooleanClauseOccur.MUST);
079    
080                    return super.createFullQuery(contextQuery, searchContext);
081            }
082    
083            @Override
084            protected void doDelete(Object obj) throws Exception {
085                    throw new UnsupportedOperationException();
086            }
087    
088            @Override
089            protected Document doGetDocument(Object obj) throws Exception {
090                    throw new UnsupportedOperationException();
091            }
092    
093            @Override
094            protected Summary doGetSummary(
095                            Document document, Locale locale, String snippet,
096                            PortletURL portletURL)
097                    throws Exception {
098    
099                    throw new UnsupportedOperationException();
100            }
101    
102            @Override
103            protected void doReindex(Object obj) throws Exception {
104                    throw new UnsupportedOperationException();
105            }
106    
107            @Override
108            protected void doReindex(String className, long classPK) throws Exception {
109                    throw new UnsupportedOperationException();
110            }
111    
112            @Override
113            protected void doReindex(String[] ids) throws Exception {
114                    throw new UnsupportedOperationException();
115            }
116    
117            @Override
118            protected String getPortletId(SearchContext searchContext) {
119                    return null;
120            }
121    
122    }