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.portlet.asset.util;
016    
017    import com.liferay.portal.kernel.search.BaseIndexer;
018    import com.liferay.portal.kernel.search.BooleanQuery;
019    import com.liferay.portal.kernel.search.Document;
020    import com.liferay.portal.kernel.search.Field;
021    import com.liferay.portal.kernel.search.SearchContext;
022    import com.liferay.portal.kernel.search.Summary;
023    import com.liferay.portal.kernel.search.filter.BooleanFilter;
024    import com.liferay.portal.kernel.spring.osgi.OSGiBeanProperties;
025    import com.liferay.portlet.asset.model.AssetEntry;
026    
027    import java.util.Locale;
028    
029    import javax.portlet.PortletRequest;
030    import javax.portlet.PortletResponse;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     * @author Julio Camarero
035     */
036    @OSGiBeanProperties
037    public class AssetEntryIndexer extends BaseIndexer<AssetEntry> {
038    
039            public static final String CLASS_NAME = AssetEntry.class.getName();
040    
041            public AssetEntryIndexer() {
042                    setDefaultSelectedFieldNames(
043                            Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
044            }
045    
046            @Override
047            public String getClassName() {
048                    return CLASS_NAME;
049            }
050    
051            @Override
052            public void postProcessSearchQuery(
053                            BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
054                            SearchContext searchContext)
055                    throws Exception {
056    
057                    if (searchContext.getAttributes() == null) {
058                            return;
059                    }
060    
061                    addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
062                    addSearchTerm(searchQuery, searchContext, Field.TITLE, false);
063                    addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false);
064            }
065    
066            @Override
067            protected void doDelete(AssetEntry assetEntry) {
068            }
069    
070            @Override
071            protected Document doGetDocument(AssetEntry assetEntry) {
072                    return null;
073            }
074    
075            @Override
076            protected Summary doGetSummary(
077                    Document document, Locale locale, String snippet,
078                    PortletRequest portletRequest, PortletResponse portletResponse) {
079    
080                    return null;
081            }
082    
083            @Override
084            protected void doReindex(AssetEntry assetEntry) {
085            }
086    
087            @Override
088            protected void doReindex(String className, long classPK) {
089            }
090    
091            @Override
092            protected void doReindex(String[] ids) {
093            }
094    
095    }