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
Search contents and put a result object in the request (to be serialized in JSON).
-
Field Summary
Modifier and TypeFieldDescriptionprotected ContentTypeExtensionPoint
The ContentType Managerprotected Context
The avalon contextprotected GetQueryFromJSONHelper
the helper to get query infos from JSONprotected QueryBuilder
The query builderprotected ContentSearcherFactory
The searcher factory.protected SearchUIModelExtensionPoint
The search model managerprotected ServerCommHelper
The server comm helperstatic final String
Name of request attribute for storing the query error, if any.static final String
Name of request attribute for storing contents' idsstatic final String
Name of request attribute for storing the language of searchstatic final String
Name of request attribute for storing the search modelstatic final String
Name of request attribute for storing search resultsFields inherited from class org.apache.cocoon.acting.ServiceableAction
manager
Fields inherited from class org.apache.cocoon.acting.AbstractAction
EMPTY_MAP
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionact
(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) void
contextualize
(Context context) protected void
doSearch
(Request request, SearchModel model, int offset, int maxResults, Map<String, Object> jsParameters, Map<String, Object> contextualParameters) Do the search and set the results in request attributes.protected int
getMaxResults
(SearchModel model, Map<String, Object> jsParameters, Map<String, Object> contextualParameters) Get the max number of resultsprotected int
Get the index of searchprotected SearchModel
Get the search UI modelGet the sort criteria from a sort string.void
service
(ServiceManager smanager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
SEARCH_CONTENTS
Name of request attribute for storing contents' ids -
SEARCH_RESULTS
Name of request attribute for storing search results -
SEARCH_LOCALE
Name of request attribute for storing the language of search -
SEARCH_MODEL
Name of request attribute for storing the search model -
QUERY_ERROR
Name of request attribute for storing the query error, if any. -
_searchModelManager
The search model manager -
_contentTypeExtensionPoint
The ContentType Manager -
_serverCommHelper
The server comm helper -
_context
The avalon context -
_searcherFactory
The searcher factory. -
_getQueryFromJSONHelper
the helper to get query infos from JSON -
_queryBuilder
The query builder
-
-
Constructor Details
-
SearchAction
public SearchAction()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in 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, SearchModel model, int offset, int maxResults, Map<String, Object> jsParameters, Map<String, throws ExceptionObject> contextualParameters) 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 modeloffset
- The index of searchmaxResults
- The max resultsjsParameters
- The JS parameterscontextualParameters
- The contextual parameters- Throws:
Exception
- if the search failed
-
getSearchModel
protected SearchModel getSearchModel(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
Get the index of search- Parameters:
jsParameters
- The JS parameters- Returns:
- The offset
-
getMaxResults
protected int getMaxResults(SearchModel model, Map<String, Object> jsParameters, Map<String, Object> contextualParameters) Get the max number of results- Parameters:
model
- The search modeljsParameters
- The JS parameterscontextualParameters
- The contextual parameters- Returns:
- The max number of results
-
getSort
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
.
-