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.assetpublisher.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.util.PortletKeys;
024    import com.liferay.portlet.asset.model.AssetEntry;
025    
026    import java.util.Locale;
027    
028    import javax.portlet.PortletRequest;
029    import javax.portlet.PortletResponse;
030    import javax.portlet.PortletURL;
031    
032    /**
033     * @author Brian Wing Shun Chan
034     * @author Julio Camarero
035     */
036    public class AssetIndexer extends BaseIndexer {
037    
038            public static final String[] CLASS_NAMES = {AssetEntry.class.getName()};
039    
040            public static final String PORTLET_ID = PortletKeys.ASSET_PUBLISHER;
041    
042            public AssetIndexer() {
043                    setDefaultSelectedFieldNames(
044                            Field.ENTRY_CLASS_NAME, Field.ENTRY_CLASS_PK, Field.UID);
045            }
046    
047            @Override
048            public String[] getClassNames() {
049                    return CLASS_NAMES;
050            }
051    
052            @Override
053            public String getPortletId() {
054                    return PORTLET_ID;
055            }
056    
057            @Override
058            public void postProcessSearchQuery(
059                            BooleanQuery searchQuery, SearchContext searchContext)
060                    throws Exception {
061    
062                    if (searchContext.getAttributes() == null) {
063                            return;
064                    }
065    
066                    addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
067                    addSearchTerm(searchQuery, searchContext, Field.TITLE, false);
068                    addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false);
069            }
070    
071            @Override
072            protected void doDelete(Object obj) {
073            }
074    
075            @Override
076            protected Document doGetDocument(Object obj) {
077                    return null;
078            }
079    
080            @Override
081            protected Summary doGetSummary(
082                    Document document, Locale locale, String snippet, PortletURL portletURL,
083                    PortletRequest portletRequest, PortletResponse portletResponse) {
084    
085                    return null;
086            }
087    
088            @Override
089            protected void doReindex(Object obj) {
090            }
091    
092            @Override
093            protected void doReindex(String className, long classPK) {
094            }
095    
096            @Override
097            protected void doReindex(String[] ids) {
098            }
099    
100            @Override
101            protected String getPortletId(SearchContext searchContext) {
102                    return PORTLET_ID;
103            }
104    
105    }