001    /**
002     * Copyright (c) 2000-2010 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.directory.util;
016    
017    import com.liferay.portal.kernel.search.Document;
018    import com.liferay.portal.kernel.search.HitsOpenSearchImpl;
019    import com.liferay.portal.kernel.search.Indexer;
020    import com.liferay.portal.kernel.search.Summary;
021    import com.liferay.portlet.enterpriseadmin.util.UserIndexer;
022    
023    import javax.portlet.PortletURL;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class DirectoryOpenSearchImpl extends HitsOpenSearchImpl {
029    
030            public static final String SEARCH_PATH = "/c/directory/open_search";
031    
032            public static final String TITLE = "Liferay Directory Search: ";
033    
034            public String getPortletId() {
035                    return UserIndexer.PORTLET_ID;
036            }
037    
038            public String getSearchPath() {
039                    return SEARCH_PATH;
040            }
041    
042            public Summary getSummary(
043                    Indexer indexer, Document document, String snippet,
044                    PortletURL portletURL) {
045    
046                    Summary summary = super.getSummary(
047                            indexer, document, snippet, portletURL);
048    
049                    portletURL = summary.getPortletURL();
050    
051                    portletURL.setParameter("struts_action", "/directory/view_user");
052    
053                    return summary;
054            }
055    
056            public String getTitle(String keywords) {
057                    return TITLE + keywords;
058            }
059    
060    }