Package org.ametys.cms.search.cocoon
Class SearchGenerator
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.xml.AbstractXMLProducer
-
- org.apache.cocoon.generation.AbstractGenerator
-
- org.apache.cocoon.generation.ServiceableGenerator
-
- org.ametys.cms.search.cocoon.SearchGenerator
-
- All Implemented Interfaces:
Poolable
,Recyclable
,Disposable
,Component
,Contextualizable
,LogEnabled
,Serviceable
,Generator
,SitemapModelComponent
,XMLProducer
- Direct Known Subclasses:
DocSearchGenerator
public class SearchGenerator extends ServiceableGenerator implements Contextualizable
Generate contents returned by theSearchAction
.
-
-
Field Summary
Fields Modifier and Type Field Description protected ColumnHelper
_columnHelper
The helper for columnsprotected ContentResultSetHelper
_contentRSH
Helper for saxing resultprotected ContentTypeExtensionPoint
_contentTypeExtensionPoint
The content type extension pointprotected Context
_context
Contextprotected ContentTypesHelper
_cTypeHelper
The content type helper.protected SearchUIModelExtensionPoint
_searchModelManager
The search model managerprotected ServerCommHelper
_serverCommHelper
The server comm helperprotected ContentValuesExtractorFactory
_valuesExtractorFactory
The content values extractor factory.static String
CONTENT_VERSION_LABEL
Constant for getting content in specific version label-
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator
manager
-
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
-
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
-
-
Constructor Summary
Constructors Constructor Description SearchGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextualize(Context context)
void
generate()
protected List<ColumnHelper.Column>
getColumnsFromParameters(Map<String,Object> jsParameters, Set<String> contentTypeIds)
Get the columns from JS parametersprotected Set<String>
getCommonContentTypeIds(Map<String,Object> jsParameters, SearchModel model, Map<String,Object> contextualParameters)
Get the common content typeprotected void
saxContent(Content content, Collection<? extends ResultField> resultFields, Locale defaultLocale)
SAX the result contentprotected void
saxContents(SearchModel model, SearchResults<Content> results, Collection<? extends ResultField> resultFields, String versionLabel, Map<String,Object> jsParameters, Locale defaultLocale, Map<String,Object> contextualParameters)
Sax a set of contentsvoid
service(ServiceManager smanager)
protected boolean
switchToLabel(Content content, String label)
Switch to the revision corresponding to the specified label.-
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose
-
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle, setup
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
-
-
-
-
Field Detail
-
CONTENT_VERSION_LABEL
public static final String CONTENT_VERSION_LABEL
Constant for getting content in specific version label- See Also:
- Constant Field Values
-
_serverCommHelper
protected ServerCommHelper _serverCommHelper
The server comm helper
-
_valuesExtractorFactory
protected ContentValuesExtractorFactory _valuesExtractorFactory
The content values extractor factory.
-
_contentRSH
protected ContentResultSetHelper _contentRSH
Helper for saxing result
-
_searchModelManager
protected SearchUIModelExtensionPoint _searchModelManager
The search model manager
-
_cTypeHelper
protected ContentTypesHelper _cTypeHelper
The content type helper.
-
_columnHelper
protected ColumnHelper _columnHelper
The helper for columns
-
_contentTypeExtensionPoint
protected ContentTypeExtensionPoint _contentTypeExtensionPoint
The content type extension point
-
-
Constructor Detail
-
SearchGenerator
public SearchGenerator()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableGenerator
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
generate
public void generate() throws IOException, SAXException, ProcessingException
- Specified by:
generate
in interfaceGenerator
- Throws:
IOException
SAXException
ProcessingException
-
saxContents
protected void saxContents(SearchModel model, SearchResults<Content> results, Collection<? extends ResultField> resultFields, String versionLabel, Map<String,Object> jsParameters, Locale defaultLocale, Map<String,Object> contextualParameters) throws SAXException, AmetysRepositoryException, IOException, ProcessingException
Sax a set of contents- Parameters:
model
- search modelresults
- contentsresultFields
- fields to retreiveversionLabel
- version labeljsParameters
- parameters of the searchdefaultLocale
- The locale to use for localized values if content's language is null.contextualParameters
- The contextual parameters- Throws:
SAXException
- if a error occurred during saxAmetysRepositoryException
- if a error occurredIOException
- if a error occurredProcessingException
- if a error occurred
-
getCommonContentTypeIds
protected Set<String> getCommonContentTypeIds(Map<String,Object> jsParameters, SearchModel model, Map<String,Object> contextualParameters)
Get the common content type- Parameters:
jsParameters
- The JS parametersmodel
- The search modelcontextualParameters
- The contextual parameters- Returns:
- The common content type
-
getColumnsFromParameters
protected List<ColumnHelper.Column> getColumnsFromParameters(Map<String,Object> jsParameters, Set<String> contentTypeIds)
Get the columns from JS parameters- Parameters:
jsParameters
- The JS parameterscontentTypeIds
- The content type identifiers- Returns:
- the requested columns
-
switchToLabel
protected boolean switchToLabel(Content content, String label)
Switch to the revision corresponding to the specified label.- Parameters:
content
- The contentlabel
- the label to switch to- Returns:
true
if a revision with this label exists and the content was switch,false
otherwise.
-
saxContent
protected void saxContent(Content content, Collection<? extends ResultField> resultFields, Locale defaultLocale) throws SAXException, AmetysRepositoryException, IOException
SAX the result content- Parameters:
content
- the resultresultFields
- the result fieldsdefaultLocale
- The locale to use for localized values if content's language is null.- Throws:
SAXException
- if a error occurred during saxAmetysRepositoryException
- if a error occurredIOException
- if a error occurred
-
-