public class DefaultContentType extends AbstractContentTypeDescriptor implements ContentType, Contextualizable, ThreadSafe, Disposable
It used a configuration file with the following format:
<restrict-to>
[<right type="read|write" id="RIGHT_ID"/>]*
<!-- logical OR between several right id of the same type -->
[<workflow type="read|write" step="3"/>]*
<!-- logical OR between several workflow step of the same type -->
[<cannot type="read|write"/>]*
</restrict-to>
Modifier and Type | Class and Description |
---|---|
protected static interface |
DefaultContentType.AnnotableDefinition
Definition with semantic annotations
|
protected class |
DefaultContentType.MetadataAndRepeaterDefinitionParser
|
protected static interface |
DefaultContentType.RestrictedDefinition
Restricted definition.
|
protected static class |
DefaultContentType.RestrictedMetadataDefinition
Internal
MetadataDefinition storage contains instances of this class. |
protected static class |
DefaultContentType.RestrictedRepeaterDefinition
Internal
RepeaterDefinition storage contains instances of this class. |
protected static class |
DefaultContentType.RestrictedRichTextDefinition
Internal
MetadataDefinition storage contains instances of this class. |
protected static class |
DefaultContentType.Restrictions
Restrictions provided with a metadata definition.
|
_allMetadataSetsForEdition, _allMetadataSetsForView, _category, _contentTypesHelper, _cssFiles, _cTypeEP, _dcProvider, _defaultTitle, _description, _iconDecorator, _iconGlyph, _id, _label, _largeIcon, _mediumIcon, _metadataSetsForEdition, _metadataSetsForView, _pluginName, _smallIcon, _srcResolver, _superTypeIds
TAG_MIXIN, TAG_PRIVATE, TAG_REFERENCE_TABLE, TAG_RENDERABLE_FERENCE_TABLE
Constructor and Description |
---|
DefaultContentType() |
Modifier and Type | Method and Description |
---|---|
protected void |
_addSemanticAnnotations(Configuration indexConf,
MetadataDefinitionHolder holder)
Add semantic annotations as indexing fields to the indexing model.
|
protected void |
_checkContentMetadata(MetadataDefinition metadataDef,
String metadataPath)
Recursively check that content and sub-content metadatas reference a valid content-type.
|
protected void |
_checkContentMetadatas()
Check that content and sub-content metadatas reference a valid content-type.
|
protected void |
_checkContentMutualReferences()
Check content type mutual reference declarations.
|
protected void |
_checkContentMutualReferences(MetadataDefinition metadataDef,
String metadataPath,
int repeaterLevel)
Recursively check a content type mutual reference declarations.
|
protected boolean |
_checkMetadataDefinition(MetadataDefinition metadataDefinition)
Check the medatata definition to determines if this content type is multilingual and/or simple
All medatata of a simple content-type have to be a simple type (string, long, date, ..)
A multilingual content type should contain at least a metadata of type MULTILINGUAL_STRING
|
protected void |
_checkMetadataTypes(Configuration metadataConf1,
Configuration metadataConf2)
Check if all metadata's types defined in first configuration are equals to those defined in second configuration
|
protected void |
_checkMetadataTypes(MetadataDefinition metaDef1,
MetadataDefinition metaDef2)
Check if all metadata's types defined in first metadata definition are equals to those defined in second metadata definition
|
protected void |
_computeIndexingModelReferences()
Browse the indexing model and compute indexing field references.
|
protected void |
_configureCustomIndexingFields(Configuration indexConf)
Configure the custom indexing fields.
|
protected void |
_configureCustomMetadataIndexingFields(Configuration indexConf)
Configure the custom metadata indexing fields.
|
protected void |
_configureGlobalValidators(Configuration config)
Configure the global validators for content type
|
protected void |
_configureIndexingModel(Configuration config)
Configure the indexing model
|
protected void |
_configureMetadataDefinitions(Configuration mainConfig)
Configure metadata definitions
|
protected void |
_configureMetadataIndexingFields(Configuration indexConf)
Configure the metadata indexing fields.
|
protected void |
_configureParentContentType(Configuration mainConfig)
Configures the "parent" content type.
|
protected void |
_getApplicableMetadata(Configuration config,
Map<String,Configuration> metadataConfigurations,
boolean allowOverride)
Fill a map of the applicable metadata configurations.
|
protected DefaultContentType.Restrictions |
_getRestrictionsForPath(MetadataDefinition metadataDef)
Retrieves the restrictions for a given path.
|
protected void |
_getSemanticAnnotations(MetadataDefinitionHolder holder,
Multimap<SemanticAnnotation,String> annotations,
String prefix)
Get the semantic annotations and their paths from the given metadata definition holder's sub-tree.
|
protected boolean |
_hasRights(Content content,
Set<String> rightLimitations)
Check if current user has the given rights.
|
protected boolean |
_isInWorkflowStep(WorkflowAwareContent content,
Set<Integer> workflowLimitations)
Check if the workflow of the content is in a given current step.
|
protected void |
_parseAllMetadatas(Map<String,Configuration> metadataConfigurations,
DefaultContentType.MetadataAndRepeaterDefinitionParser defParser)
Parse all metadata configurations.
|
protected void |
_parseDublinCoreMetadata(DefaultContentType.MetadataAndRepeaterDefinitionParser defParser)
Parse DublinCore metadata
|
protected MetadataDefinition |
_parseMetadata(Configuration metadataConfiguration,
DefaultContentType.MetadataAndRepeaterDefinitionParser defParser)
Parse a metadata configuration.
|
protected Set<String> |
_parseTags(Configuration configuration)
Parse the tags
|
boolean |
canRead(Content content,
MetadataDefinition metadataDef)
Determine whether a metadata can be read at this time.
|
boolean |
canWrite(Content content,
MetadataDefinition metadataDef)
Determine whether a metadata can be written at this time.
|
void |
configure(Configuration configuration) |
void |
contextualize(Context context) |
void |
dispose() |
Map<String,Object> |
getAdditionalData(Content content)
Get the additional data relative to its
ContentType . |
List<ContentValidator> |
getGlobalValidators()
Retrieves the potential global validators.
|
protected List<MetadataDefinition> |
getIndexingFieldDefinitions(ContentType initialContentType,
String metadataPath)
Get the list of metadata definitions "traversed" from the initial content type to the given metadata.
|
IndexingModel |
getIndexingModel()
Get the indexing model
|
MetadataDefinition |
getMetadataDefinition(String metadataName)
Retrieves the definition of a given metadata.
|
MetadataDefinition |
getMetadataDefinitionByPath(String metadataPath)
Retrieves the definition of a given metadata by its path.
|
Set<String> |
getMetadataNames()
Retrieves the metadata names.
|
protected Configuration |
getOverridenConfiguration()
Get the overridden configuration
|
MetadataDefinition |
getParentMetadata()
Gets the metadata holding the "parent" of the contents of this content type.
|
RichTextUpdater |
getRichTextUpdater()
Retrieves the RichText updater
|
String |
getRight()
Get the right needed to create a content of this type.
|
protected Configuration |
getRootConfiguration(Configuration configuration)
Get the root configuration
|
Set<String> |
getTags()
Get the registered tags for this content types
|
boolean |
hasMetadataDefinition(String metadataName)
Determines if the definition of a given metadata exists.
|
boolean |
hasTag(String tagName)
Determines if the content type has the given tag
|
boolean |
isAbstract()
Get whether the content type is abstract, i.e.
|
boolean |
isMixin()
Get whether the content type is a mixin, i.e.
|
boolean |
isMultilingual()
Get whether the content type is multilingual
|
boolean |
isPrivate()
Get whether the content type is private, i.e.
|
boolean |
isReferenceTable()
Get whether the content type is a reference table
|
boolean |
isSimple()
Get whether the content type is simple, i.e.
|
void |
postInitialize()
Called by the extension point when the content type hierarchy has been computed.
|
void |
saxContentTypeAdditionalData(ContentHandler contentHandler,
Content content)
SAX the additional content data linked to its
ContentType
These additional data will be available in content view |
void |
service(ServiceManager manager) |
String |
toString() |
_configureCSSFiles, _configureIcons, _configureLabels, _configureMetadataSets, _configureSuperTypes, _fillMetadataSetDublinCore, _fillMetadataSetElement, _getApplicableMetadataSets, _getDefaultCatalogue, _getIconPath, _parseI18nizableText, _parseI18nizableText, _parseIcon, _parseIcon, _parseIconGlyph, _parseMetadataSet, _parseMetadataSets, getCategory, getCSSFiles, getDefaultTitle, getDescription, getEditionMetadataSetNames, getIconDecorator, getIconGlyph, getId, getLabel, getLargeIcon, getMediumIcon, getMetadataSetForEdition, getMetadataSetForView, getPluginName, getSmallIcon, getSupertypeIds, getViewMetadataSetNames, setPluginInfo
getLogger, setLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCategory, getCSSFiles, getDefaultTitle, getDescription, getEditionMetadataSetNames, getIconDecorator, getIconGlyph, getId, getLabel, getLargeIcon, getMediumIcon, getMetadataSetForEdition, getMetadataSetForView, getPluginName, getSmallIcon, getSupertypeIds, getViewMetadataSetNames
protected static final String __GLOBAL_VALIDATOR_ROLE_PREFIX
static Pattern __annotationNamePattern
protected Map<String,MetadataDefinition> _metadata
protected String _right
protected boolean _abstract
protected String _parentMetadataName
protected ServiceManager _manager
protected Context _cocoonContext
protected WorkflowProvider _workflowProvider
protected RightManager _rightManager
protected CurrentUserProvider _currentUserProvider
protected RichTextTransformer _richTextTransformer
protected RichTextOutgoingReferencesExtractor _richTextOutgoingReferencesExtractor
protected List<ContentValidator> _globalValidators
protected RichTextUpdater _richTextUpdater
protected IndexingModel _indexingModel
protected HierarchicalReferenceTablesHelper _hierarchicalSimpleContentsHelper
private ThreadSafeComponentManager<Validator> _validatorManager
private ThreadSafeComponentManager<ContentValidator> _globalValidatorsManager
private ThreadSafeComponentManager<Enumerator> _enumeratorManager
private ThreadSafeComponentManager<CustomIndexingField> _customFieldManager
private ThreadSafeComponentManager<CustomMetadataIndexingField> _customMetadataIndexingFieldManager
private boolean _isSimple
private boolean _isMultilingual
public DefaultContentType()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
service
in class AbstractContentTypeDescriptor
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void dispose()
dispose
in interface Disposable
protected Configuration getRootConfiguration(Configuration configuration)
AbstractContentTypeDescriptor
getRootConfiguration
in class AbstractContentTypeDescriptor
configuration
- The configurationprotected Configuration getOverridenConfiguration() throws ConfigurationException
AbstractContentTypeDescriptor
getOverridenConfiguration
in class AbstractContentTypeDescriptor
ConfigurationException
- if an error occurredpublic void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
configure
in class AbstractContentTypeDescriptor
ConfigurationException
protected void _configureMetadataDefinitions(Configuration mainConfig) throws ConfigurationException
mainConfig
- The content type configurationConfigurationException
- if an error occurredprotected void _configureParentContentType(Configuration mainConfig) throws ConfigurationException
AbstractContentTypeDescriptor._configureSuperTypes(Configuration)
)mainConfig
- The main configurationConfigurationException
- if an error occuredprotected void _configureGlobalValidators(Configuration config) throws ConfigurationException
config
- The content type configurationConfigurationException
- if an error occuredprotected void _getApplicableMetadata(Configuration config, Map<String,Configuration> metadataConfigurations, boolean allowOverride) throws ConfigurationException
config
- the content type configuration.metadataConfigurations
- the Map of metadata Configuration
, indexed by name.allowOverride
- if true, encountering a metadata which has already been declared (based on its name) will replace it. Otherwise, an exception will be thrown.ConfigurationException
- if an error occurs.protected void _parseAllMetadatas(Map<String,Configuration> metadataConfigurations, DefaultContentType.MetadataAndRepeaterDefinitionParser defParser) throws ConfigurationException
metadataConfigurations
- the metadata configurations.defParser
- the metadata definition parser.ConfigurationException
- if the configuration is invalid.protected MetadataDefinition _parseMetadata(Configuration metadataConfiguration, DefaultContentType.MetadataAndRepeaterDefinitionParser defParser) throws ConfigurationException
metadataConfiguration
- the metadata configuration.defParser
- the metadata definition parser.ConfigurationException
- if the configuration is invalidprotected void _checkMetadataTypes(MetadataDefinition metaDef1, MetadataDefinition metaDef2) throws ConfigurationException
metaDef1
- The first metadata definition to comparemetaDef2
- The second metadata definition to compareConfigurationException
- if the types are not equalsprotected void _checkMetadataTypes(Configuration metadataConf1, Configuration metadataConf2) throws ConfigurationException
metadataConf1
- The first configuration to comparemetadataConf2
- The second configuration to compareConfigurationException
- if the types are not equalsprotected boolean _checkMetadataDefinition(MetadataDefinition metadataDefinition)
metadataDefinition
- The metadata definitionprotected void _parseDublinCoreMetadata(DefaultContentType.MetadataAndRepeaterDefinitionParser defParser) throws ConfigurationException
defParser
- The parser definitionConfigurationException
- if the configuration is invalidprotected void _configureIndexingModel(Configuration config) throws ConfigurationException
config
- The main configurationConfigurationException
- if an error occurredprotected void _addSemanticAnnotations(Configuration indexConf, MetadataDefinitionHolder holder)
indexConf
- the indexing model configuration.holder
- the metadata holder (ContentType or MetadataDefinition) to scan for annotable metadata.protected void _getSemanticAnnotations(MetadataDefinitionHolder holder, Multimap<SemanticAnnotation,String> annotations, String prefix)
holder
- The current metadata definition holder.annotations
- The map of semantic annotations and the corresponding metadata paths.prefix
- The current prefix in the metadata tree (with a trailing slash, if applicable).protected void _configureMetadataIndexingFields(Configuration indexConf) throws ConfigurationException
indexConf
- the indexing model configuration.ConfigurationException
- if an error occurs.protected void _configureCustomIndexingFields(Configuration indexConf) throws ConfigurationException
indexConf
- the indexing model configuration.ConfigurationException
- if an error occurs.protected void _configureCustomMetadataIndexingFields(Configuration indexConf) throws ConfigurationException
indexConf
- the indexing model configuration.ConfigurationException
- if an error occurs.protected Set<String> _parseTags(Configuration configuration) throws ConfigurationException
configuration
- the configuration to useConfigurationException
- if the configuration is not valid.public void postInitialize() throws Exception
ContentType
postInitialize
in interface ContentType
Exception
- if an error occurs of if an additional check fails.protected void _checkContentMetadatas() throws ConfigurationException
ConfigurationException
- if a content (or sub-content) metadata references an invalid or non-existing content type.protected void _checkContentMetadata(MetadataDefinition metadataDef, String metadataPath) throws ConfigurationException
metadataDef
- the metadata definition.metadataPath
- the metadata path.ConfigurationException
- if a content (or sub-content) metadata references an invalid or non-existing content type.protected void _checkContentMutualReferences() throws ConfigurationException
ConfigurationException
- if there is a problem with mutual reference declarations.protected void _checkContentMutualReferences(MetadataDefinition metadataDef, String metadataPath, int repeaterLevel) throws ConfigurationException
metadataDef
- the metadata definition.metadataPath
- the metadata path.repeaterLevel
- the current nested level of repeaters, 0 if the current metadata isn't in a repeater.ConfigurationException
- if there is a problem with mutual reference declarations.protected void _computeIndexingModelReferences()
protected List<MetadataDefinition> getIndexingFieldDefinitions(ContentType initialContentType, String metadataPath)
initialContentType
- the initial content type.metadataPath
- the compound metadata path.public List<ContentValidator> getGlobalValidators()
ContentType
getGlobalValidators
in interface ContentType
public RichTextUpdater getRichTextUpdater()
ContentType
getRichTextUpdater
in interface ContentType
null
if none.public Set<String> getMetadataNames()
MetadataDefinitionHolder
getMetadataNames
in interface MetadataDefinitionHolder
public MetadataDefinition getMetadataDefinition(String metadataName)
MetadataDefinitionHolder
getMetadataDefinition
in interface MetadataDefinitionHolder
metadataName
- the metadata name.public boolean hasMetadataDefinition(String metadataName)
ContentType
hasMetadataDefinition
in interface ContentType
metadataName
- the metadata name.true
if the metadata definition existspublic MetadataDefinition getMetadataDefinitionByPath(String metadataPath)
ContentType
getMetadataDefinitionByPath
in interface ContentType
metadataPath
- the metadata path, separated by '/'null
if not foundpublic IndexingModel getIndexingModel()
ContentType
getIndexingModel
in interface ContentType
public boolean canRead(Content content, MetadataDefinition metadataDef) throws AmetysRepositoryException
ContentType
canRead
in interface ContentType
content
- The content where metadata is to be read on. Can be null, on content creation.metadataDef
- the metadata definitiontrue
if the current user is allowed to read the metadata of this content.AmetysRepositoryException
- if an error occurs while accessing the content.public boolean canWrite(Content content, MetadataDefinition metadataDef) throws AmetysRepositoryException
ContentType
canWrite
in interface ContentType
content
- The content where metadata is to be written on. Can be null, on content creation.metadataDef
- the metadata definitiontrue
if the current user is allowed to write the metadata of this content.AmetysRepositoryException
- if an error occurs while accessing the content.public Set<String> getTags()
ContentType
getTags
in interface ContentType
public boolean hasTag(String tagName)
ContentType
hasTag
in interface ContentType
tagName
- The tag namepublic boolean isPrivate()
ContentType
isPrivate
in interface ContentType
public boolean isAbstract()
ContentType
isAbstract
in interface ContentType
public boolean isSimple()
ContentType
isSimple
in interface ContentType
public boolean isReferenceTable()
ContentType
isReferenceTable
in interface ContentType
public boolean isMultilingual()
ContentType
isMultilingual
in interface ContentType
public boolean isMixin()
ContentType
isMixin
in interface ContentType
public String getRight()
ContentType
getRight
in interface ContentType
public void saxContentTypeAdditionalData(ContentHandler contentHandler, Content content) throws AmetysRepositoryException, SAXException
ContentType
ContentType
These additional data will be available in content viewsaxContentTypeAdditionalData
in interface ContentType
contentHandler
- The handler to SAX intocontent
- The contentAmetysRepositoryException
- if an error occurs while accessing the content.SAXException
- if an error occurs while SAXingpublic Map<String,Object> getAdditionalData(Content content)
ContentType
ContentType
.
These additional data are delivered to client side.getAdditionalData
in interface ContentType
content
- The contentprotected DefaultContentType.Restrictions _getRestrictionsForPath(MetadataDefinition metadataDef)
metadataDef
- the metadata definition.null
if not found.protected boolean _hasRights(Content content, Set<String> rightLimitations)
rightLimitations
- the right limitations.content
- the content.true
if it is on at least one step,
false
otherwise.protected boolean _isInWorkflowStep(WorkflowAwareContent content, Set<Integer> workflowLimitations) throws AmetysRepositoryException
workflowLimitations
- the workflow limitations.content
- the content.true
if it is on at least one step,
false
otherwise.AmetysRepositoryException
- if an error occurs.public MetadataDefinition getParentMetadata()
ContentType
MetadataType.CONTENT
and must reference a private and simple content type.getParentMetadata
in interface ContentType