Package org.ametys.cms.search.cocoon
Class SearchAction
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.acting.AbstractAction
-
- org.apache.cocoon.acting.ServiceableAction
-
- org.ametys.cms.search.cocoon.SearchAction
-
- All Implemented Interfaces:
Component,Contextualizable,LogEnabled,Serviceable,Action
- Direct Known Subclasses:
GetSolrSearchModelAction,SelectContentSearchAction,SolrQuerySearchAction
public class SearchAction extends ServiceableAction implements Contextualizable
Search contents and put a result object in the request (to be serialized in JSON).
-
-
Field Summary
Fields Modifier and Type Field Description protected ContentTypeExtensionPoint_contentTypeExtensionPointThe ContentType Managerprotected Context_contextThe avalon contextprotected GetQueryFromJSONHelper_getQueryFromJSONHelperthe helper to get query infos from JSONprotected QueryBuilder_queryBuilderThe query builderprotected ContentSearcherFactory_searcherFactoryThe searcher factory.protected SearchUIModelExtensionPoint_searchModelManagerThe search model managerprotected ServerCommHelper_serverCommHelperThe server comm helperstatic StringQUERY_ERRORName of request attribute for storing the query error, if any.static StringSEARCH_CONTENTSName of request attribute for storing contents' idsstatic StringSEARCH_LOCALEName of request attribute for storing the language of searchstatic StringSEARCH_MODELName of request attribute for storing the search modelstatic StringSEARCH_RESULTSName of request attribute for storing search results-
Fields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
-
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
-
Constructor Summary
Constructors Constructor Description SearchAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mapact(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters)voidcontextualize(Context context)protected voiddoSearch(Request request, SearchUIModel model, int offset, int maxResults, Map<String,Object> jsParameters, Map<String,Object> contextualParameters)Do the search and set the results in request attributes.protected intgetMaxResults(SearchUIModel uiModel, Map<String,Object> jsParameters, Map<String,Object> contextualParameters)Get the max number of resultsprotected intgetOffset(Map<String,Object> jsParameters)Get the index of searchprotected SearchUIModelgetSearchUIModel(Map<String,Object> jsParameters, Map<String,Object> contextualParameters)Get the search UI modelprotected List<Sort>getSort(String sortString, String groupString)Get the sort criteria from a sort string.voidservice(ServiceManager smanager)-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
SEARCH_CONTENTS
public static final String SEARCH_CONTENTS
Name of request attribute for storing contents' ids
-
SEARCH_RESULTS
public static final String SEARCH_RESULTS
Name of request attribute for storing search results
-
SEARCH_LOCALE
public static final String SEARCH_LOCALE
Name of request attribute for storing the language of search
-
SEARCH_MODEL
public static final String SEARCH_MODEL
Name of request attribute for storing the search model
-
QUERY_ERROR
public static final String QUERY_ERROR
Name of request attribute for storing the query error, if any.
-
_searchModelManager
protected SearchUIModelExtensionPoint _searchModelManager
The search model manager
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The ContentType Manager
-
_serverCommHelper
protected ServerCommHelper _serverCommHelper
The server comm helper
-
_searcherFactory
protected ContentSearcherFactory _searcherFactory
The searcher factory.
-
_getQueryFromJSONHelper
protected GetQueryFromJSONHelper _getQueryFromJSONHelper
the helper to get query infos from JSON
-
_queryBuilder
protected QueryBuilder _queryBuilder
The query builder
-
-
Constructor Detail
-
SearchAction
public SearchAction()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Overrides:
servicein classServiceableAction- Throws:
ServiceException
-
act
public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception
-
doSearch
protected void doSearch(Request request, SearchUIModel model, int offset, int maxResults, Map<String,Object> jsParameters, Map<String,Object> contextualParameters) throws Exception
Do the search and set the results in request attributes.- Parameters:
request- The request. The results or contents' id have to be set in request attributesmodel- The search UI modeloffset- The index of searchmaxResults- The max resultsjsParameters- The JS parameterscontextualParameters- The contextual parameters- Throws:
Exception- if the search failed
-
getSearchUIModel
protected SearchUIModel getSearchUIModel(Map<String,Object> jsParameters, Map<String,Object> contextualParameters)
Get the search UI model- Parameters:
jsParameters- The JS parameterscontextualParameters- The contextual parameters- Returns:
- the search UI model
-
getOffset
protected int getOffset(Map<String,Object> jsParameters)
Get the index of search- Parameters:
jsParameters- The JS parameters- Returns:
- The offset
-
getMaxResults
protected int getMaxResults(SearchUIModel uiModel, Map<String,Object> jsParameters, Map<String,Object> contextualParameters)
Get the max number of results- Parameters:
uiModel- The search UI modeljsParameters- The JS parameterscontextualParameters- The contextual parameters- Returns:
- The max number of results
-
getSort
protected List<Sort> getSort(String sortString, String groupString)
Get the sort criteria from a sort string.- Parameters:
sortString- The sort criteria as a JSON-encoded string.groupString- The group criteria as a JSON-encoded string (for server-side grouping feature). Can be null.- Returns:
- the sort criteria as a List of
Sort.
-
-