Package org.ametys.cms.search.cocoon
Class ContentResultSetHelper
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.plugins.repository.metadata.MetadataSaxer
-
- org.ametys.cms.contenttype.MetadataManager
-
- org.ametys.cms.search.cocoon.ContentResultSetHelper
-
- All Implemented Interfaces:
Component
,Contextualizable
,LogEnabled
,Serviceable
public class ContentResultSetHelper extends MetadataManager
Helper to SAX result of a search based on the requested result fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
ContentResultSetHelper.ResultFieldContentHandler
class
ContentResultSetHelper.SearchResultFieldSet
Inner class representing a set of result fields.class
ContentResultSetHelper.SearchResultFieldSetElement
Inner class representing a element of aContentResultSetHelper.SearchResultFieldSet
This can contains sub elements.-
Nested classes/interfaces inherited from class org.ametys.cms.contenttype.MetadataManager
MetadataManager.RepeaterEntryComparator
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__RESULT_FIELD_PATH_ATTRIBUTE
private SystemPropertyExtensionPoint
_systemPropEP
static String
ROLE
Avalon Role.-
Fields inherited from class org.ametys.cms.contenttype.MetadataManager
_contentTypeExtensionPoint, _contentTypesHelper, _externalizableMetadataProviderEP, REPEATER_ENTRY_COMPARATOR
-
Fields inherited from class org.ametys.plugins.repository.metadata.MetadataSaxer
_context, _jsonUtils, _resolver, _userManager
-
-
Constructor Summary
Constructors Constructor Description ContentResultSetHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private MetadataDefinition
_getMetadataDefinition(String metadataName, MetadataDefinition parentMetadataDef, Content content)
protected void
_saxCompositeMetadata(ContentHandler contentHandler, Content content, CompositeMetadata metadata, MetadataDefinition metadataDefinition, String metadataName, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale, String prefix, boolean checkRead)
SAX a composite metadata.protected void
_saxContent(ContentHandler contentHandler, Content content, Locale defaultLocale, String metadataName, ContentResultSetHelper.SearchResultFieldSet resultSet, String prefix, boolean checkRead)
SAX a content (referenced or sub-content) in view mode.protected void
_saxContentReferenceMetadata(ContentHandler contentHandler, Content content, CompositeMetadata metadatas, MetadataDefinition metadataDefinition, String metadataName, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale, String prefix, boolean checkRead)
SAX a "content" metadata.protected void
_saxMetadata(ContentHandler contentHandler, Content content, CompositeMetadata metadata, ContentResultSetHelper.SearchResultFieldSet resultSet, MetadataDefinition metadataDefinition, Locale defaultLocale, String prefix, boolean checkRead)
SAX a metadataprivate void
_saxResultSet(ContentHandler contentHandler, Content content, CompositeMetadata metadata, ContentResultSetHelper.SearchResultFieldSet resultSetElement, MetadataDefinition parentMetadataDef, Locale defaultLocale, String prefix, boolean checkRead)
ContentResultSetHelper.SearchResultFieldSet
buildResultSet(Collection<? extends ResultField> fields, Content content)
Build a result set from result fieldsvoid
saxReadableResultFields(ContentHandler contentHandler, Content content, Collection<? extends ResultField> fields, Locale defaultLocale)
SAXes the result fields of a content.void
saxReadableResultSet(ContentHandler contentHandler, Content content, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale)
SAX a content metadata set that are readable.void
saxResultFields(ContentHandler contentHandler, Content content, Collection<? extends ResultField> fields, Locale defaultLocale)
SAXes the result fields of a content.void
saxResultSet(ContentHandler contentHandler, Content content, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale)
SAXes a content result set.void
saxSystemProperty(ContentHandler contentHandler, String systemPropertyId, Content content)
SAX a system propertyvoid
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.cms.contenttype.MetadataManager
_binaryAsJson, _canRead, _contentAsJson, _geocodeAsJson, _multilingualStringAsJson, _referenceAsJson, _resourceAsJson, _richTextAsString, _saxBinaryMetadata, _saxBinaryMetadataAsJson, _saxCompositeMetadata, _saxContentReferenceMetadata, _saxExternalisableBinaryMetadata, _saxExternalisableFileMetadata, _saxExternalisableGeocodeMetadata, _saxExternalisableMetadata, _saxExternalisableMultilingualStringMetadata, _saxExternalisableObjectCollectionMetadata, _saxExternalisableReferenceMetadata, _saxExternalisableResourceFileMetadata, _saxExternalisableRichTextMetadata, _saxExternalisableUserMetadata, _saxExternalizableBooleanMetadata, _saxExternalizableContentReferenceMetadata, _saxExternalizableDateMetadata, _saxExternalizableDoubleMetadata, _saxExternalizableLongMetadata, _saxExternalizableStringMetadata, _saxExternalizableValuesAsJson, _saxFileMetadata, _saxGeocodeMetadata, _saxMetadata, _saxMetadataComments, _saxMultilingualStringAsJson, _saxMultilingualStringMetadata, _saxNoExternalisableMetadata, _saxNonEditionRenderingContent, _saxReferenceMetadata, _saxResourceFileMetadata, _saxResourceFileMetadata, _saxResourceFileMetadataAsJson, _saxRichTextMetadata, _saxSingleDateMetadata, _saxSingleGeocodeMetadata, _saxSingleGeocodeMetadataAsJson, _saxSingleReferenceMetadata, _saxSingleReferenceMetadataAsJson, _saxStringMetadata, _saxSubContentMetadata, _saxUserMetadata, getExternalizableMetadata, saxMetadata, saxMetadata, saxMetadata, saxMetadataComments, saxReadableMetadata, saxReadableMetadata
-
Methods inherited from class org.ametys.plugins.repository.metadata.MetadataSaxer
_binaryAsJson, _getRefAmetysObjectIds, _saxAllMetadata, _saxBinaryMetadata, _saxDateMetadata, _saxEnumeratedStringMetadata, _saxMetadata, _saxMultilingualStringMetadata, _saxMultipleUserMetadataAsJson, _saxObject, _saxRichTextMetadata, _saxSingleUserMetadataAsJson, _saxStringMetadata, _saxUserMetadata, _userAsJson, contextualize, saxMetadata, saxMetadata
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
__RESULT_FIELD_PATH_ATTRIBUTE
private static final String __RESULT_FIELD_PATH_ATTRIBUTE
- See Also:
- Constant Field Values
-
_systemPropEP
private SystemPropertyExtensionPoint _systemPropEP
-
-
Constructor Detail
-
ContentResultSetHelper
public ContentResultSetHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classMetadataManager
- Throws:
ServiceException
-
saxResultFields
public void saxResultFields(ContentHandler contentHandler, Content content, Collection<? extends ResultField> fields, Locale defaultLocale) throws AmetysRepositoryException, SAXException, IOException
SAXes the result fields of a content. This method does not check rights.- Parameters:
contentHandler
- the content handler where to SAX into.content
- the content.fields
- the result fields.defaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string. Only to be valued if initial content's language is null, otherwise set this parameter to null.- Throws:
AmetysRepositoryException
- if an error occurs.SAXException
- if an error occurs.IOException
- if an error occurs.
-
saxReadableResultFields
public void saxReadableResultFields(ContentHandler contentHandler, Content content, Collection<? extends ResultField> fields, Locale defaultLocale) throws AmetysRepositoryException, SAXException, IOException
SAXes the result fields of a content. This method returns only readable fields (user rights are checked)- Parameters:
contentHandler
- the content handler where to SAX into.content
- the content.fields
- the result fields.defaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string. Only to be valued if initial content's language is null, otherwise set this parameter to null.- Throws:
AmetysRepositoryException
- if an error occurs.SAXException
- if an error occurs.IOException
- if an error occurs.
-
saxResultSet
public void saxResultSet(ContentHandler contentHandler, Content content, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale) throws AmetysRepositoryException, SAXException, IOException
SAXes a content result set. This method does not check rights.- Parameters:
contentHandler
- the content handler where to SAX into.content
- the content.resultSet
- the set of result fields to SAXdefaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string. Only use if initial content's language is not null. Can be null.- Throws:
AmetysRepositoryException
- if an error occurs.SAXException
- if an error occurs.IOException
- if an error occurs.
-
saxReadableResultSet
public void saxReadableResultSet(ContentHandler contentHandler, Content content, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale) throws AmetysRepositoryException, SAXException, IOException
SAX a content metadata set that are readable.- Parameters:
contentHandler
- the content handler where to SAX into.content
- the content.resultSet
- the set of result fields to SAXdefaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string. Only to be valued if initial content's language is null, otherwise set this parameter to null.- Throws:
AmetysRepositoryException
- if an error occurs.SAXException
- if an error occurs.IOException
- if an error occurs.
-
_saxResultSet
private void _saxResultSet(ContentHandler contentHandler, Content content, CompositeMetadata metadata, ContentResultSetHelper.SearchResultFieldSet resultSetElement, MetadataDefinition parentMetadataDef, Locale defaultLocale, String prefix, boolean checkRead) throws AmetysRepositoryException, SAXException, IOException
-
_saxMetadata
protected void _saxMetadata(ContentHandler contentHandler, Content content, CompositeMetadata metadata, ContentResultSetHelper.SearchResultFieldSet resultSet, MetadataDefinition metadataDefinition, Locale defaultLocale, String prefix, boolean checkRead) throws AmetysRepositoryException, SAXException, IOException
SAX a metadata- Parameters:
contentHandler
- The content handler where to SAX into.content
- The contentmetadata
- The parent composite metadata.resultSet
- the set of remaining result fields to SAXmetadataDefinition
- The metadata definitiondefaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string. Only use if initial content's language is not null. Can be null.prefix
- the metadata path prefix.checkRead
- true if need to check read right- Throws:
AmetysRepositoryException
- if an error occurredSAXException
- if an error occurred while SAXingIOException
- if an error occurred
-
_saxCompositeMetadata
protected void _saxCompositeMetadata(ContentHandler contentHandler, Content content, CompositeMetadata metadata, MetadataDefinition metadataDefinition, String metadataName, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale, String prefix, boolean checkRead) throws SAXException, IOException
SAX a composite metadata.- Parameters:
contentHandler
- the content handler to SAX into.content
- the content.metadata
- the parent metadata holder.metadataDefinition
- the metadata definition.metadataName
- The name of the metadata to saxresultSet
- the set of result fields to SAX for this compositedefaultLocale
- The locale to use to sax localized values such as multilingual content or multilingual string. Only use if initial content's language is not null. Can be null.prefix
- the metadata path prefix.checkRead
- true if need to check read right.- Throws:
SAXException
- if an error occurs.IOException
- if an error occurs.
-
_saxContentReferenceMetadata
protected void _saxContentReferenceMetadata(ContentHandler contentHandler, Content content, CompositeMetadata metadatas, MetadataDefinition metadataDefinition, String metadataName, ContentResultSetHelper.SearchResultFieldSet resultSet, Locale defaultLocale, String prefix, boolean checkRead) throws SAXException, IOException
SAX a "content" metadata.- Parameters:
contentHandler
- the content handler to SAX into.content
- The currently saxed content.metadatas
- the parent composite metadata.metadataDefinition
- the metadata definition.metadataName
- the metadata name.resultSet
- the set of result fields to SAX for the referenced contentsdefaultLocale
- The locale to use to resolve localized values of referenced content. Only use if initial content's language is not null.prefix
- the metadata path prefix.checkRead
- true if need to check read right.- Throws:
SAXException
- if an error occurs.IOException
- if an error occurs.
-
_saxContent
protected void _saxContent(ContentHandler contentHandler, Content content, Locale defaultLocale, String metadataName, ContentResultSetHelper.SearchResultFieldSet resultSet, String prefix, boolean checkRead) throws SAXException, IOException
SAX a content (referenced or sub-content) in view mode.- Parameters:
contentHandler
- the content handler to SAX into.content
- The referenced or sub-content to SAX.defaultLocale
- The locale to use to sax the referenced content's localized values. Only use if initial content 's language is null.metadataName
- the metadata name.resultSet
- the set of result fields to SAX for this contentprefix
- the metadata path prefix.checkRead
- true if need to check read right.- Throws:
SAXException
- if an error occurs.IOException
- if an error occurs.
-
saxSystemProperty
public void saxSystemProperty(ContentHandler contentHandler, String systemPropertyId, Content content) throws SAXException
SAX a system property- Parameters:
contentHandler
- the content handler to SAX into.systemPropertyId
- The id of system propertycontent
- The content- Throws:
SAXException
- if an error occurs.
-
buildResultSet
public ContentResultSetHelper.SearchResultFieldSet buildResultSet(Collection<? extends ResultField> fields, Content content)
Build a result set from result fields- Parameters:
fields
- The result fieldscontent
- The result content- Returns:
- The result set
-
_getMetadataDefinition
private MetadataDefinition _getMetadataDefinition(String metadataName, MetadataDefinition parentMetadataDef, Content content)
-
-