001    /**
002     * Copyright (c) 2000-2013 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            @Override
041            public String[] getClassNames() {
042                    return CLASS_NAMES;
043            }
044    
045            @Override
046            public String getPortletId() {
047                    return PORTLET_ID;
048            }
049    
050            @Override
051            public void postProcessSearchQuery(
052                            BooleanQuery searchQuery, SearchContext searchContext)
053                    throws Exception {
054    
055                    if (searchContext.getAttributes() == null) {
056                            return;
057                    }
058    
059                    addSearchTerm(searchQuery, searchContext, Field.DESCRIPTION, false);
060                    addSearchTerm(searchQuery, searchContext, Field.TITLE, false);
061                    addSearchTerm(searchQuery, searchContext, Field.USER_NAME, false);
062            }
063    
064            @Override
065            protected void doDelete(Object obj) {
066            }
067    
068            @Override
069            protected Document doGetDocument(Object obj) {
070                    return null;
071            }
072    
073            @Override
074            protected Summary doGetSummary(
075                    Document document, Locale locale, String snippet,
076                    PortletURL portletURL) {
077    
078                    return null;
079            }
080    
081            @Override
082            protected void doReindex(Object obj) {
083            }
084    
085            @Override
086            protected void doReindex(String className, long classPK) {
087            }
088    
089            @Override
090            protected void doReindex(String[] ids) {
091            }
092    
093            @Override
094            protected String getPortletId(SearchContext searchContext) {
095                    return PORTLET_ID;
096            }
097    
098    }