1 /*
2 * Copyright (C) 2003-2008 eXo Platform SAS.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Affero General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see<http://www.gnu.org/licenses/>.
16 */
17 package org.exoplatform.services.wcm.search;
18
19 import java.util.Locale;
20 import java.util.Map;
21
22 import org.exoplatform.services.jcr.ext.common.SessionProvider;
23 import org.exoplatform.services.wcm.search.base.AbstractPageList;
24
25 /**
26 * Is used in the Search portlet that allows
27 * users to find all information matching with your given keyword.
28 * <p></p>
29 * It is configured in the core/core-configuration/src/main/webapp/WEB-INF/conf/configuration.xml file as follows:<br>
30 * {@code <import>war:/conf/wcm-core/core-search-configuration.xml</import>}<br>
31 * <p></p>
32 * The component configuration maps the SiteSearchService component with its own implementation: SiteSearchServiceImpl.
33 * <p></p>
34 * <pre>
35 * <component>
36 * <key>org.exoplatform.services.wcm.search.SiteSearchService</key>
37 * <type>org.exoplatform.services.wcm.search.SiteSearchServiceImpl</type>
38 * <component-plugins>
39 * ...
40 * </component-plugins>
41 * <init-params>
42 * <value-param>
43 * <name>isEnabledFuzzySearch</name>
44 * <value>true</value>
45 * </value-param>
46 * <value-param>
47 * <name>fuzzySearchIndex</name>
48 * <value/>
49 * </value-param>
50 * </init-params>
51 * </component>
52 * </pre>
53 *
54 * @LevelAPI Experimental
55 */
56 public interface SiteSearchService {
57
58 public final static String PAGE_MODE_NONE = "none";
59 public final static String PAGE_MODE_MORE = "more";
60 public final static String PAGE_MODE_PAGINATION = "pagination";
61 public final static String PATH_PORTAL_SITES = "/production/mop:workspace/mop:portalsites";
62
63 /**
64 * Adds the exclude/include data type plugin.
65 *
66 * @param plugin The plugin to be added.
67 */
68 public void addExcludeIncludeDataTypePlugin(ExcludeIncludeDataTypePlugin plugin);
69
70 /**
71 * Searches for content nodes of a site.
72 *
73 * This method finds all nodes of a site with nodetype that is document, nt:resource or nt:file, then checks their content.
74 * If the node content has key word, it will be put into the list result.<br>
75 * This function has 3 parameters, but the most important is {@link QueryCriteria}. With this parameter, you only set
76 * 5 properties:<br>
77 * <ul>
78 * <li>SiteName: Name of the site which is searched. If the site name is "null", the search will be performed in all sites of system.</li>
79 * <li>Keyword: The key word to search.</li>
80 * <li>SearchDocument and SearchWebContent: The values of these two parameters must be set to "true" or "false".</li>
81 * <li>SearchWebpage: Searches for content of nodes which are added to one or more pages.</li>
82 * </ul>
83 *
84 * @param sessionProvider The session provider.
85 * @param queryCriteria The query criteria.
86 * @param pageSize The page size.
87 * @param isSearchContent If "true", search is performed by content. If "false", search is performed by page.
88 * @return The list of paginated content based on the query.
89 * @throws Exception The exception
90 */
91 public AbstractPageList<ResultNode> searchSiteContents(SessionProvider sessionProvider,
92 QueryCriteria queryCriteria,
93 Locale locale,
94 int pageSize,
95 boolean isSearchContent) throws Exception;
96
97 /**
98 * Searches for pages.
99 *
100 * @param sessionProvider The session provider.
101 * @param queryCriteria The query criteria.
102 * @param pageSize The page size.
103 * @return The list of pages.
104 * @throws Exception The exception
105 */
106 public AbstractPageList<ResultNode> searchPageContents(SessionProvider sessionProvider,
107 QueryCriteria queryCriteria,
108 Locale locale,
109 int pageSize,
110 boolean isSearchContent) throws Exception;
111
112 /**
113 * Gets map containing list of found nodes
114 * @param userId user name
115 * @param queryStatement the query statement
116 * @return
117 */
118 public Map<?, Integer> getFoundNodes(String userId, String queryStatement);
119
120 /**
121 * Gets map containing list of dropped nodes
122 * @param userId user name
123 * @param queryStatement the query statement
124 * @return
125 */
126 public Map<Integer, Integer> getDropNodes(String userId, String queryStatement);
127
128 public void clearCache(String userId, String queryStatement);
129
130 }