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