Package org.ametys.cms.contenttype
Class DefaultContentType
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.cms.contenttype.AbstractContentTypeDescriptor
-
- org.ametys.cms.contenttype.DefaultContentType
-
- All Implemented Interfaces:
ContentType
,ContentTypeDescriptor
,MetadataDefinitionHolder
,Model
,ModelItemAccessor
,ModelItemContainer
,LogEnabled
,PluginAware
,Disposable
,Configurable
,Contextualizable
,Serviceable
,ThreadSafe
- Direct Known Subclasses:
AutomaticContentType
,HTMLContentType
,ODFContentType
,WebContentType
public class DefaultContentType extends AbstractContentTypeDescriptor implements ContentType, Contextualizable, ThreadSafe, Disposable
Type of content which is retrieved from a XML configuration. TODO document xml configuration ... Provides access based on rights and current workflow steps.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>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
DefaultContentType.AnnotableDefinition
Definition with semantic annotationsprotected class
DefaultContentType.MetadataAndRepeaterDefinitionParser
Deprecated.UseContentAttributeDefinitionParser
insteadprotected static interface
DefaultContentType.RestrictedDefinition
Deprecated.useRestrictedModelItem
insteadprotected static class
DefaultContentType.RestrictedMetadataDefinition
Deprecated.UseAttributeDefinition
insteadprotected static class
DefaultContentType.RestrictedRepeaterDefinition
Deprecated.UseContentRestrictedRepeaterDefinition
insteadprotected static class
DefaultContentType.RestrictedRichTextDefinition
Deprecated.UseRichTextAttributeDefinition
instead
-
Field Summary
-
Fields inherited from class org.ametys.cms.contenttype.AbstractContentTypeDescriptor
_allMetadataSets, _category, _contentTypesHelper, _contentTypesParserHelper, _cssFiles, _cTypeEP, _dcProvider, _defaultTitle, _description, _iconDecorator, _iconGlyph, _id, _label, _largeIcon, _mediumIcon, _metadataSets, _pluginName, _smallIcon, _srcResolver, _superTypeIds
-
Fields inherited from interface org.ametys.cms.contenttype.ContentType
TAG_MIXIN, TAG_PRIVATE, TAG_REFERENCE_TABLE, TAG_RENDERABLE_FERENCE_TABLE
-
-
Constructor Summary
Constructors Constructor Description DefaultContentType()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
_addSemanticAnnotations(Configuration indexConf, MetadataDefinitionHolder holder)
Add semantic annotations as indexing fields to the indexing model.protected void
_checkAttributeTypes(ModelItem item1, ModelItem item2)
Check if all attribute types defined in first model item are equals to those defined in second model itemprotected void
_checkAttributeTypes(Configuration metadataConf1, Configuration metadataConf2)
Check if all metadata's types defined in first configuration are equals to those defined in second configurationprotected void
_checkContentAttributes(ModelItemContainer modelItemContainer, int repeaterLevel)
Check for each content attribute: the content type id, the mutual references and the default valuesprotected void
_checkContentTypeId(ContentAttributeDefinition definition)
Check the content type id of the given content attribute definitionprotected void
_checkContentTypeSimplicity(ModelItem modelItem)
Checks the given model item to determine if this content type is multilingual and/or simple All items of a simple content-type have to be a simple type (string, long, date, ..) A multilingual content type should contain at least an attribute of type MULTILINGUAL-STRINGprivate void
_checkForReservedAttributeName()
protected boolean
_checkMetadataDefinition(MetadataDefinition metadataDefinition)
Deprecated.Use_checkContentTypeSimplicity(ModelItem)
insteadprotected void
_checkMetadataTypes(MetadataDefinition metaDef1, MetadataDefinition metaDef2)
Deprecated.Use_checkAttributeTypes(ModelItem, ModelItem)
insteadprotected void
_checkMutualReferences(ContentAttributeDefinition definition, int repeaterLevel)
Check the mutual reference declaration of the given content attribute definitionprivate void
_checkTitleAttribute()
protected void
_computeIndexingModelReferences()
Browse the indexing model and compute indexing field references.protected void
_configureAttributeDefinitions(Configuration mainConfig)
Configure attribute definitionsprotected void
_configureCustomIndexingFields(Configuration indexConf)
Configure the custom indexing fields.protected void
_configureCustomMetadataIndexingFields(Configuration indexConf)
Configure the custom metadata indexing fields.protected void
_configureDefaultWorkflowName(Configuration mainConfig)
Configure the default workflow name from the XML configuration.protected void
_configureGlobalValidators(Configuration config)
Configure the global validators for content typeprotected void
_configureIndexingModel(Configuration config)
Configure the indexing modelprotected void
_configureMetadataIndexingFields(Configuration indexConf)
Configure the metadata indexing fields.protected void
_configureParentContentType(Configuration mainConfig)
Configures the "parent" content type.protected void
_configureViews(Configuration mainConfig)
Configure the content type viewsprivate boolean
_containsOneOfTheModelItems(ViewItemContainer viewItemContainer, Collection<? extends ModelItem> modelItems)
private void
_copyAndReplaceOverriddenAttributes(ViewItemContainer sourceContainer, ViewItemContainer destinationContainer, Collection<? extends ModelItem> overriddenItems, boolean includeOnlyOverriddenAttributes)
protected void
_getApplicableAttributes(Configuration config, Map<String,Configuration> attributeConfigurations, boolean allowOverride)
Fill a map of the applicable attribute configurations.protected Map<String,Configuration>
_getApplicableViews(Configuration configuration, String viewTagName, boolean allowOverride)
Compute the applicable views from their configurations.protected ContentTypeReservedAttributeNameExtensionPoint
_getContentTypeReservedAttributeNameExtensionPoint()
Get the ContentTypeReservedAttributeNameExtensionPoint instanceprivate Optional<String>
_getDefaultWorkflowNameFromSupertypes()
private Optional<ModelItem>
_getModelItem(Collection<? extends ModelItem> modelItems, String name)
protected 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.private Optional<View>
_getViewWithOverriddenAttributes(View originalView)
protected void
_parseAllAttributes(Map<String,Configuration> attributeConfigurations)
Parse all attribute configurations.protected void
_parseAllMetadatas(Map<String,Configuration> metadataConfigurations, DefaultContentType.MetadataAndRepeaterDefinitionParser defParser)
Deprecated.use_parseAllAttributes(Map)
insteadprotected void
_parseDublinCoreAttributes()
Parse DublinCore attributesprotected void
_parseDublinCoreMetadata(DefaultContentType.MetadataAndRepeaterDefinitionParser defParser)
Deprecated.Use_parseDublinCoreAttributes()
insteadprotected List<String>
_parseGlobalValidators(Configuration config, boolean includeSuperTypeValidators)
Parse the global validatorsprotected MetadataDefinition
_parseMetadata(Configuration metadataConfiguration, DefaultContentType.MetadataAndRepeaterDefinitionParser defParser)
Deprecated.use_parseModelItem(Configuration, ModelItemGroup)
insteadprotected ModelItem
_parseModelItem(Configuration itemConfiguration, ModelItemGroup parent)
Parses a model itemprotected Set<String>
_parseTags(Configuration configuration)
Parse the tagsprotected Map<String,View>
_parseViews(Collection<Configuration> viewConfigurations)
Parses the own content type's viewsprotected void
_resolveViewReferences()
Resolve the temporary view referencesprotected void
_resolveViewReferences(ViewItemAccessor viewItemAccessor, String currentViewName)
Resolve the temporary view references in the givenViewItemAccessor
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 itsContentType
.Optional<String>
getDefaultWorkflowName()
Get the default workflow name.String
getFamilyId()
Retrieves the Family Id (for example the extension point) Each model Id have to be unique in it's family IdList<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 modelMetadataDefinition
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.Collection<ModelItem>
getModelItems()
Retrieves all the model items of this accessorList<String>
getOverriddenAttributes()
Get the overridden attributes listList<String>
getOverriddenViews()
Get the overridden views listprotected Configuration
getOverridenConfiguration()
Get the overridden configurationOptional<ContentAttributeDefinition>
getParentAttributeDefinition()
Gets the attribute holding the "parent" of the contents of this content type.RichTextUpdater
getRichTextUpdater()
Retrieves the RichText updaterString
getRight()
Get the right needed to create a content of this type.protected Configuration
getRootConfiguration(Configuration configuration)
Get the root configurationSet<String>
getTags()
Get the registered tags for this content typesView
getView(String viewName)
Retrieves the view with the given nameSet<String>
getViewNames(boolean includeInternals)
Retrieves the names of all the content type's viewboolean
hasMetadataDefinition(String metadataName)
Determines if the definition of a given metadata exists.boolean
hasTag(String tagName)
Determines if the content type has the given tagboolean
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 multilingualboolean
isPrivate()
Get whether the content type is private, i.e.boolean
isReferenceTable()
Get whether the content type is a reference tableboolean
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 itsContentType
These additional data will be available in content viewvoid
service(ServiceManager manager)
String
toString()
-
Methods inherited from class org.ametys.cms.contenttype.AbstractContentTypeDescriptor
_configureCSSFiles, _configureIcons, _configureLabels, _configureMetadataSets, _configureSuperTypes, _fillMetadataSetDublinCore, _fillMetadataSetElement, _getApplicableMetadataSets, _parseMetadataSet, _parseMetadataSets, getCategory, getCSSFiles, getDefaultTitle, getDescription, getEditionMetadataSetNames, getIconDecorator, getIconGlyph, getId, getLabel, getLargeIcon, getMediumIcon, getMetadataSetForEdition, getMetadataSetForView, getPluginName, getSmallIcon, getSupertypeIds, getViewMetadataSetNames, setPluginInfo
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.ametys.cms.contenttype.ContentType
canRead, canWrite, getViewNames
-
Methods inherited from interface org.ametys.cms.contenttype.ContentTypeDescriptor
getCategory, getCSSFiles, getDefaultCatalog, getDefaultTitle, getDescription, getEditionMetadataSetNames, getIconDecorator, getIconGlyph, getIconPath, getId, getLabel, getLargeIcon, getMediumIcon, getMetadataSetForEdition, getMetadataSetForView, getPluginName, getSmallIcon, getSupertypeIds, getViewMetadataSetNames
-
Methods inherited from interface org.ametys.runtime.model.ModelItemAccessor
getChild, getModelItem, hasModelItem
-
-
-
-
Field Detail
-
__GLOBAL_VALIDATOR_ROLE_PREFIX
protected static final String __GLOBAL_VALIDATOR_ROLE_PREFIX
Suffix for global validator role.- See Also:
- Constant Field Values
-
__annotationNamePattern
static Pattern __annotationNamePattern
-
__VIEW_TAG_NAME_WITH_NEW_ATTRIBUTE_API_SYNTAX
private static final String __VIEW_TAG_NAME_WITH_NEW_ATTRIBUTE_API_SYNTAX
- See Also:
- Constant Field Values
-
__VIEW_TAG_NAME_WITH_OLD_METADATA_API_SYNTAX
private static final String __VIEW_TAG_NAME_WITH_OLD_METADATA_API_SYNTAX
- See Also:
- Constant Field Values
-
__GROUP_TAG_NAME_WITH_OLD_METADATA_API_SYNTAX
private static final String __GROUP_TAG_NAME_WITH_OLD_METADATA_API_SYNTAX
- See Also:
- Constant Field Values
-
__ATTRIBUTE_REF_TAG_NAME_WITH_OLD_METADATA_API_SYNTAX
private static final String __ATTRIBUTE_REF_TAG_NAME_WITH_OLD_METADATA_API_SYNTAX
- See Also:
- Constant Field Values
-
_metadata
@Deprecated protected Map<String,MetadataDefinition> _metadata
Deprecated.Metadata definitions.
-
_modelItems
protected Map<String,ModelItem> _modelItems
Model items
-
_right
protected String _right
The right needed to create a content of this type, or null if no right is needed.
-
_abstract
protected boolean _abstract
The abstract property
-
_defaultWorkflowName
protected Optional<String> _defaultWorkflowName
Default workflow name.
-
_parentAttributeDefinition
protected ContentAttributeDefinition _parentAttributeDefinition
The parent attribute definition
-
_manager
protected ServiceManager _manager
Service manager.
-
_cocoonContext
protected Context _cocoonContext
Cocoon Context
-
_restrictedModelItemHelper
protected ContentRestrictedModelItemHelper _restrictedModelItemHelper
The restrictions helper
-
_richTextTransformer
protected RichTextTransformer _richTextTransformer
Default rich text transformer.
-
_richTextOutgoingReferencesExtractor
protected RichTextOutgoingReferencesExtractor _richTextOutgoingReferencesExtractor
Docbook (rich text) outgoing references extractor.
-
_globalValidators
protected List<ContentValidator> _globalValidators
Potential global validators.
-
_richTextUpdater
protected RichTextUpdater _richTextUpdater
Potentiel richtext updater
-
_indexingModel
protected IndexingModel _indexingModel
Indexing model
-
_hierarchicalSimpleContentsHelper
protected HierarchicalReferenceTablesHelper _hierarchicalSimpleContentsHelper
The helper component for hierarchical simple contents
-
_overriddenAttributes
protected List<String> _overriddenAttributes
List of overridden attributes
-
_overriddenViews
protected List<String> _overriddenViews
List of overridden views
-
_attributeDefinitionParser
protected ContentAttributeDefinitionParser _attributeDefinitionParser
The parser for content attribute's definitions
-
_compositeDefinitionParser
protected ContentRestrictedCompositeDefinitionParser _compositeDefinitionParser
The parser for content compisite's definitions
-
_repeaterDefinitionParser
protected ContentRestrictedRepeaterDefinitionParser _repeaterDefinitionParser
The parser for content repeater's definitions
-
_dublinCoreAttributeDefinitionParser
protected DublinCoreAttributeDefinitionParser _dublinCoreAttributeDefinitionParser
The parser for dublin core attribute's definitions
-
_oldValidatorManager
@Deprecated private ThreadSafeComponentManager<Validator> _oldValidatorManager
Deprecated.use_validatorManager
insteadComponentManager pour les Validator
-
_validatorManager
private ThreadSafeComponentManager<Validator> _validatorManager
-
_globalValidatorsManager
private ThreadSafeComponentManager<ContentValidator> _globalValidatorsManager
-
_contentTypeReservedAttributeNameExtensionPoint
private ContentTypeReservedAttributeNameExtensionPoint _contentTypeReservedAttributeNameExtensionPoint
-
_oldEnumeratorManager
@Deprecated private ThreadSafeComponentManager<Enumerator> _oldEnumeratorManager
Deprecated.use_enumeratorManager
insteadComponentManager pour les Enumerator
-
_enumeratorManager
private ThreadSafeComponentManager<Enumerator> _enumeratorManager
-
_customFieldManager
private ThreadSafeComponentManager<CustomIndexingField> _customFieldManager
-
_customMetadataIndexingFieldManager
private ThreadSafeComponentManager<CustomMetadataIndexingField> _customMetadataIndexingFieldManager
-
_contentAttributeTypeExtensionPoint
private ContentAttributeTypeExtensionPoint _contentAttributeTypeExtensionPoint
-
_isSimple
private boolean _isSimple
-
_isMultilingual
private boolean _isMultilingual
-
-
Constructor Detail
-
DefaultContentType
public DefaultContentType()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractContentTypeDescriptor
- Throws:
ServiceException
-
_getContentTypeReservedAttributeNameExtensionPoint
protected ContentTypeReservedAttributeNameExtensionPoint _getContentTypeReservedAttributeNameExtensionPoint()
Get the ContentTypeReservedAttributeNameExtensionPoint instance- Returns:
- the instance
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
getRootConfiguration
protected Configuration getRootConfiguration(Configuration configuration)
Description copied from class:AbstractContentTypeDescriptor
Get the root configuration- Specified by:
getRootConfiguration
in classAbstractContentTypeDescriptor
- Parameters:
configuration
- The configuration- Returns:
- The main configuration
-
getOverridenConfiguration
protected Configuration getOverridenConfiguration() throws ConfigurationException
Description copied from class:AbstractContentTypeDescriptor
Get the overridden configuration- Specified by:
getOverridenConfiguration
in classAbstractContentTypeDescriptor
- Returns:
- the overridden configuration or null
- Throws:
ConfigurationException
- if an error occurred TODO NEWATTRIBUTEAPI_CONTENT: Remove this abstract method whenAbstractContentTypeDescriptor._configureMetadataSets(Configuration)
is removed. This method will now only be used inDefaultContentType
to configure attributes and views
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classAbstractContentTypeDescriptor
- Throws:
ConfigurationException
-
_checkForReservedAttributeName
private void _checkForReservedAttributeName() throws ConfigurationException
- Throws:
ConfigurationException
-
_configureAttributeDefinitions
protected void _configureAttributeDefinitions(Configuration mainConfig) throws ConfigurationException
Configure attribute definitions- Parameters:
mainConfig
- The content type configuration- Throws:
ConfigurationException
- if an error occurred
-
_getApplicableAttributes
protected void _getApplicableAttributes(Configuration config, Map<String,Configuration> attributeConfigurations, boolean allowOverride) throws ConfigurationException
Fill a map of the applicable attribute configurations.- Parameters:
config
- the content type configuration.attributeConfigurations
- the Map of attributesConfiguration
, indexed by name.allowOverride
- if true, encountering an attribute which has already been declared (based on its name) will replace it. Otherwise, an exception will be thrown.- Throws:
ConfigurationException
- if an error occurs.
-
getOverriddenAttributes
public List<String> getOverriddenAttributes()
Get the overridden attributes list- Specified by:
getOverriddenAttributes
in interfaceContentType
- Returns:
- the overridden attributes list
-
_checkAttributeTypes
protected void _checkAttributeTypes(Configuration metadataConf1, Configuration metadataConf2) throws ConfigurationException
Check if all metadata's types defined in first configuration are equals to those defined in second configuration- Parameters:
metadataConf1
- The first configuration to comparemetadataConf2
- The second configuration to compare- Throws:
ConfigurationException
- if the types are not equals
-
_parseAllAttributes
protected void _parseAllAttributes(Map<String,Configuration> attributeConfigurations) throws ConfigurationException
Parse all attribute configurations.- Parameters:
attributeConfigurations
- the attribute configurations.- Throws:
ConfigurationException
- if the configuration is invalid.
-
_parseModelItem
protected ModelItem _parseModelItem(Configuration itemConfiguration, ModelItemGroup parent) throws ConfigurationException
Parses a model item- Parameters:
itemConfiguration
- configuration of the model item to parseparent
- the parent of the model item to parse. Can benull
if the item has no parent.- Returns:
- the parsed model item
- Throws:
ConfigurationException
- if an error occurs while the model item is parsed
-
_checkAttributeTypes
protected void _checkAttributeTypes(ModelItem item1, ModelItem item2) throws ConfigurationException
Check if all attribute types defined in first model item are equals to those defined in second model item- Parameters:
item1
- The first item to compareitem2
- The second item to compare- Throws:
ConfigurationException
- if the types are not equals
-
_checkContentTypeSimplicity
protected void _checkContentTypeSimplicity(ModelItem modelItem)
Checks the given model item to determine if this content type is multilingual and/or simple All items of a simple content-type have to be a simple type (string, long, date, ..) A multilingual content type should contain at least an attribute of type MULTILINGUAL-STRING- Parameters:
modelItem
- The model item to check
-
_parseDublinCoreAttributes
protected void _parseDublinCoreAttributes() throws ConfigurationException
Parse DublinCore attributes- Throws:
ConfigurationException
- if the configuration is invalid
-
_parseAllMetadatas
@Deprecated protected void _parseAllMetadatas(Map<String,Configuration> metadataConfigurations, DefaultContentType.MetadataAndRepeaterDefinitionParser defParser) throws ConfigurationException
Deprecated.use_parseAllAttributes(Map)
insteadParse all metadata configurations.- Parameters:
metadataConfigurations
- the metadata configurations.defParser
- the metadata definition parser.- Throws:
ConfigurationException
- if the configuration is invalid.
-
_parseMetadata
@Deprecated protected MetadataDefinition _parseMetadata(Configuration metadataConfiguration, DefaultContentType.MetadataAndRepeaterDefinitionParser defParser) throws ConfigurationException
Deprecated.use_parseModelItem(Configuration, ModelItemGroup)
insteadParse a metadata configuration.- Parameters:
metadataConfiguration
- the metadata configuration.defParser
- the metadata definition parser.- Returns:
- the created MetadataDefinition.
- Throws:
ConfigurationException
- if the configuration is invalid
-
_checkMetadataTypes
@Deprecated protected void _checkMetadataTypes(MetadataDefinition metaDef1, MetadataDefinition metaDef2) throws ConfigurationException
Deprecated.Use_checkAttributeTypes(ModelItem, ModelItem)
insteadCheck if all metadata's types defined in first metadata definition are equals to those defined in second metadata definition- Parameters:
metaDef1
- The first metadata definition to comparemetaDef2
- The second metadata definition to compare- Throws:
ConfigurationException
- if the types are not equals
-
_checkMetadataDefinition
@Deprecated protected boolean _checkMetadataDefinition(MetadataDefinition metadataDefinition)
Deprecated.Use_checkContentTypeSimplicity(ModelItem)
insteadCheck 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- Parameters:
metadataDefinition
- The metadata definition- Returns:
- false if the medatata definition is not a valid medatata definition for a simple content-type
-
_parseDublinCoreMetadata
@Deprecated protected void _parseDublinCoreMetadata(DefaultContentType.MetadataAndRepeaterDefinitionParser defParser) throws ConfigurationException
Deprecated.Use_parseDublinCoreAttributes()
insteadParse DublinCore metadata- Parameters:
defParser
- The parser definition- Throws:
ConfigurationException
- if the configuration is invalid
-
_configureDefaultWorkflowName
protected void _configureDefaultWorkflowName(Configuration mainConfig) throws ConfigurationException
Configure the default workflow name from the XML configuration. - From the overriden configuration - If not, from the current configuration - If not, from the supertypes - If it cannot be determined and the content type is a reference table, then "reference-table" - Otherwise "content"- Parameters:
mainConfig
- The configuration- Throws:
ConfigurationException
- if an exception occurs
-
_getDefaultWorkflowNameFromSupertypes
private Optional<String> _getDefaultWorkflowNameFromSupertypes()
-
_configureParentContentType
protected void _configureParentContentType(Configuration mainConfig) throws ConfigurationException
Configures the "parent" content type. This must not be confounded with the super types. (SeeAbstractContentTypeDescriptor._configureSuperTypes(Configuration)
)- Parameters:
mainConfig
- The main configuration- Throws:
ConfigurationException
- if an error occurred
-
_configureViews
protected void _configureViews(Configuration mainConfig) throws ConfigurationException
Configure the content type views- Parameters:
mainConfig
- The content type configuration- Throws:
ConfigurationException
- if an error occurred
-
_getViewWithOverriddenAttributes
private Optional<View> _getViewWithOverriddenAttributes(View originalView)
-
_copyAndReplaceOverriddenAttributes
private void _copyAndReplaceOverriddenAttributes(ViewItemContainer sourceContainer, ViewItemContainer destinationContainer, Collection<? extends ModelItem> overriddenItems, boolean includeOnlyOverriddenAttributes)
-
_getModelItem
private Optional<ModelItem> _getModelItem(Collection<? extends ModelItem> modelItems, String name)
-
_containsOneOfTheModelItems
private boolean _containsOneOfTheModelItems(ViewItemContainer viewItemContainer, Collection<? extends ModelItem> modelItems)
-
getOverriddenViews
public List<String> getOverriddenViews()
Get the overridden views list- Specified by:
getOverriddenViews
in interfaceContentType
- Returns:
- the overridden views list
-
_getApplicableViews
protected Map<String,Configuration> _getApplicableViews(Configuration configuration, String viewTagName, boolean allowOverride) throws ConfigurationException
Compute the applicable views from their configurations.- Parameters:
configuration
- The content type configurationviewTagName
- The name of the tag containing the viewallowOverride
- iftrue
, encountering a view which has already been declared (based on its name) will replace it. Otherwise, an exception will be thrown.- Returns:
- the applicable views, indexed by their names. For each view, indicates if the view is configured
- Throws:
ConfigurationException
- if the configuration is invalid
-
_parseViews
protected Map<String,View> _parseViews(Collection<Configuration> viewConfigurations) throws ConfigurationException
Parses the own content type's views- Parameters:
viewConfigurations
- the configuration that contains the views- Returns:
- the views as a
Map
with a boolean that determines if the view is internal or not - Throws:
ConfigurationException
- if the configuration is invalid
-
_configureGlobalValidators
protected void _configureGlobalValidators(Configuration config) throws ConfigurationException
Configure the global validators for content type- Parameters:
config
- The content type configuration- Throws:
ConfigurationException
- if an error occurs
-
_parseGlobalValidators
protected List<String> _parseGlobalValidators(Configuration config, boolean includeSuperTypeValidators) throws ConfigurationException
Parse the global validators- Parameters:
config
- the configurationincludeSuperTypeValidators
- true to include validators of super types- Returns:
- the role of global validators to be lookuped
- Throws:
ConfigurationException
- if configuration is incorrect
-
_configureIndexingModel
protected void _configureIndexingModel(Configuration config) throws ConfigurationException
Configure the indexing model- Parameters:
config
- The main configuration- Throws:
ConfigurationException
- if an error occurred
-
_addSemanticAnnotations
protected void _addSemanticAnnotations(Configuration indexConf, MetadataDefinitionHolder holder)
Add semantic annotations as indexing fields to the indexing model.- Parameters:
indexConf
- the indexing model configuration.holder
- the metadata holder (ContentType or MetadataDefinition) to scan for annotable metadata.
-
_getSemanticAnnotations
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.- Parameters:
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).
-
_configureMetadataIndexingFields
protected void _configureMetadataIndexingFields(Configuration indexConf) throws ConfigurationException
Configure the metadata indexing fields.- Parameters:
indexConf
- the indexing model configuration.- Throws:
ConfigurationException
- if an error occurs.
-
_configureCustomIndexingFields
protected void _configureCustomIndexingFields(Configuration indexConf) throws ConfigurationException
Configure the custom indexing fields.- Parameters:
indexConf
- the indexing model configuration.- Throws:
ConfigurationException
- if an error occurs.
-
_configureCustomMetadataIndexingFields
protected void _configureCustomMetadataIndexingFields(Configuration indexConf) throws ConfigurationException
Configure the custom metadata indexing fields.- Parameters:
indexConf
- the indexing model configuration.- Throws:
ConfigurationException
- if an error occurs.
-
_parseTags
protected Set<String> _parseTags(Configuration configuration) throws ConfigurationException
Parse the tags- Parameters:
configuration
- the configuration to use- Returns:
- the tags
- Throws:
ConfigurationException
- if the configuration is not valid.
-
postInitialize
public void postInitialize() throws Exception
Description copied from interface:ContentType
Called by the extension point when the content type hierarchy has been computed. Can be used to do more initialization, checks, ...- Specified by:
postInitialize
in interfaceContentType
- Throws:
Exception
- if an error occurs of if an additional check fails.
-
_checkTitleAttribute
private void _checkTitleAttribute() throws ConfigurationException
- Throws:
ConfigurationException
-
_checkContentAttributes
protected void _checkContentAttributes(ModelItemContainer modelItemContainer, int repeaterLevel) throws ConfigurationException
Check for each content attribute: the content type id, the mutual references and the default values- Parameters:
modelItemContainer
- theModelItemContainer
to checkrepeaterLevel
- the current nested level of repeaters, 0 if the current attribute isn't in a repeater.- Throws:
ConfigurationException
- if a content attribute has an invalid configuration
-
_checkContentTypeId
protected void _checkContentTypeId(ContentAttributeDefinition definition) throws ConfigurationException
Check the content type id of the given content attribute definition- Parameters:
definition
- the definition to check- Throws:
ConfigurationException
- if the given content attribute references an invalid or non-existing content type.
-
_checkMutualReferences
protected void _checkMutualReferences(ContentAttributeDefinition definition, int repeaterLevel) throws ConfigurationException
Check the mutual reference declaration of the given content attribute definition- Parameters:
definition
- the definition to checkrepeaterLevel
- the current nested level of repeaters, 0 if the current attribute isn't in a repeater.- Throws:
ConfigurationException
- if there is a problem with mutual reference declaration
-
_resolveViewReferences
protected void _resolveViewReferences() throws ConfigurationException
Resolve the temporary view references- Throws:
ConfigurationException
- if a view reference has a configuration error (the content attribute nesting the reference does not specify any content type, the view does not exist, ...)
-
_resolveViewReferences
protected void _resolveViewReferences(ViewItemAccessor viewItemAccessor, String currentViewName) throws ConfigurationException
Resolve the temporary view references in the givenViewItemAccessor
- Parameters:
viewItemAccessor
- theViewItemAccessor
currentViewName
- the name of the current view (to avoid views referencing themselves)- Throws:
ConfigurationException
- if a view reference has a configuration error (the content attribute nesting the reference does not specify any content type, the view does not exist, ...)
-
_computeIndexingModelReferences
protected void _computeIndexingModelReferences()
Browse the indexing model and compute indexing field references.
-
getIndexingFieldDefinitions
protected List<MetadataDefinition> getIndexingFieldDefinitions(ContentType initialContentType, String metadataPath)
Get the list of metadata definitions "traversed" from the initial content type to the given metadata.- Parameters:
initialContentType
- the initial content type.metadataPath
- the compound metadata path.- Returns:
- the list of metadata definitions.
-
getGlobalValidators
public List<ContentValidator> getGlobalValidators()
Description copied from interface:ContentType
Retrieves the potential global validators.- Specified by:
getGlobalValidators
in interfaceContentType
- Returns:
- the global validators or an empty List if none.
-
getRichTextUpdater
public RichTextUpdater getRichTextUpdater()
Description copied from interface:ContentType
Retrieves the RichText updater- Specified by:
getRichTextUpdater
in interfaceContentType
- Returns:
- the RichText updater or
null
if none.
-
getMetadataNames
public Set<String> getMetadataNames()
Description copied from interface:MetadataDefinitionHolder
Retrieves the metadata names.- Specified by:
getMetadataNames
in interfaceMetadataDefinitionHolder
- Returns:
- the metadata names.
-
getMetadataDefinition
public MetadataDefinition getMetadataDefinition(String metadataName)
Description copied from interface:MetadataDefinitionHolder
Retrieves the definition of a given metadata.- Specified by:
getMetadataDefinition
in interfaceMetadataDefinitionHolder
- Parameters:
metadataName
- the metadata name.- Returns:
- the metadata definition.
-
hasMetadataDefinition
public boolean hasMetadataDefinition(String metadataName)
Description copied from interface:ContentType
Determines if the definition of a given metadata exists.- Specified by:
hasMetadataDefinition
in interfaceContentType
- Parameters:
metadataName
- the metadata name.- Returns:
true
if the metadata definition exists
-
getMetadataDefinitionByPath
public MetadataDefinition getMetadataDefinitionByPath(String metadataPath)
Description copied from interface:ContentType
Retrieves the definition of a given metadata by its path.- Specified by:
getMetadataDefinitionByPath
in interfaceContentType
- Parameters:
metadataPath
- the metadata path, separated by '/'- Returns:
- the metadata definition or
null
if not found
-
getIndexingModel
public IndexingModel getIndexingModel()
Description copied from interface:ContentType
Get the indexing model- Specified by:
getIndexingModel
in interfaceContentType
- Returns:
- the indexing model
-
canRead
public boolean canRead(Content content, MetadataDefinition metadataDef) throws AmetysRepositoryException
Description copied from interface:ContentType
Determine whether a metadata can be read at this time.- Specified by:
canRead
in interfaceContentType
- Parameters:
content
- The content where metadata is to be read on. Can be null, on content creation.metadataDef
- the metadata definition- Returns:
true
if the current user is allowed to read the metadata of this content.- Throws:
AmetysRepositoryException
- if an error occurs while accessing the content.
-
canWrite
public boolean canWrite(Content content, MetadataDefinition metadataDef) throws AmetysRepositoryException
Description copied from interface:ContentType
Determine whether a metadata can be written at this time.- Specified by:
canWrite
in interfaceContentType
- Parameters:
content
- The content where metadata is to be written on. Can be null, on content creation.metadataDef
- the metadata definition- Returns:
true
if the current user is allowed to write the metadata of this content.- Throws:
AmetysRepositoryException
- if an error occurs while accessing the content.
-
getTags
public Set<String> getTags()
Description copied from interface:ContentType
Get the registered tags for this content types- Specified by:
getTags
in interfaceContentType
- Returns:
- the tags
-
hasTag
public boolean hasTag(String tagName)
Description copied from interface:ContentType
Determines if the content type has the given tag- Specified by:
hasTag
in interfaceContentType
- Parameters:
tagName
- The tag name- Returns:
- true if the content type is tagged with the given tag name
-
isPrivate
public boolean isPrivate()
Description copied from interface:ContentType
Get whether the content type is private, i.e. should not be created by the regular content interface.- Specified by:
isPrivate
in interfaceContentType
- Returns:
- true if the content is private, false if it is public.
-
isAbstract
public boolean isAbstract()
Description copied from interface:ContentType
Get whether the content type is abstract, i.e. should not be created by the regular content interface.- Specified by:
isAbstract
in interfaceContentType
- Returns:
- true if the content is abstract, false otherwise.
-
isSimple
public boolean isSimple()
Description copied from interface:ContentType
Get whether the content type is simple, i.e. should contains only simple metadata type to be edited in a grid.- Specified by:
isSimple
in interfaceContentType
- Returns:
- true if the content is simple, false otherwise
-
isReferenceTable
public boolean isReferenceTable()
Description copied from interface:ContentType
Get whether the content type is a reference table- Specified by:
isReferenceTable
in interfaceContentType
- Returns:
- true if the content type is a reference table
-
isMultilingual
public boolean isMultilingual()
Description copied from interface:ContentType
Get whether the content type is multilingual- Specified by:
isMultilingual
in interfaceContentType
- Returns:
- true if the content is multilingual, false otherwise
-
isMixin
public boolean isMixin()
Description copied from interface:ContentType
Get whether the content type is a mixin, i.e. should used to add metadata to a existing content.- Specified by:
isMixin
in interfaceContentType
- Returns:
- true if the content is mixin, false otherwise.
-
getDefaultWorkflowName
public Optional<String> getDefaultWorkflowName()
Description copied from interface:ContentType
Get the default workflow name.- Specified by:
getDefaultWorkflowName
in interfaceContentType
- Returns:
- The default workflow name
-
getRight
public String getRight()
Description copied from interface:ContentType
Get the right needed to create a content of this type.- Specified by:
getRight
in interfaceContentType
- Returns:
- the right needed to create a content of this type. If null is returned, no right is needed.
-
saxContentTypeAdditionalData
public void saxContentTypeAdditionalData(ContentHandler contentHandler, Content content) throws AmetysRepositoryException, SAXException
Description copied from interface:ContentType
SAX the additional content data linked to itsContentType
These additional data will be available in content view- Specified by:
saxContentTypeAdditionalData
in interfaceContentType
- Parameters:
contentHandler
- The handler to SAX intocontent
- The content- Throws:
AmetysRepositoryException
- if an error occurs while accessing the content.SAXException
- if an error occurs while SAXing
-
getAdditionalData
public Map<String,Object> getAdditionalData(Content content)
Description copied from interface:ContentType
Get the additional data relative to itsContentType
. These additional data are delivered to client side.- Specified by:
getAdditionalData
in interfaceContentType
- Parameters:
content
- The content- Returns:
- the additional properties in a Map
-
_getRestrictionsForPath
protected Restrictions _getRestrictionsForPath(MetadataDefinition metadataDef)
Retrieves the restrictions for a given path.- Parameters:
metadataDef
- the metadata definition.- Returns:
- the restrictions or
null
if not found.
-
getParentAttributeDefinition
public Optional<ContentAttributeDefinition> getParentAttributeDefinition()
Description copied from interface:ContentType
Gets the attribute holding the "parent" of the contents of this content type. Must be of typeModelItemTypeConstants.CONTENT_ELEMENT_TYPE_ID
and must reference a private and simple content type.- Specified by:
getParentAttributeDefinition
in interfaceContentType
- Returns:
- the attribute holding the "parent" of the contents of this content type
-
getModelItems
public Collection<ModelItem> getModelItems()
Description copied from interface:ModelItemAccessor
Retrieves all the model items of this accessor- Specified by:
getModelItems
in interfaceModelItemAccessor
- Returns:
- the model items
-
getViewNames
public Set<String> getViewNames(boolean includeInternals)
Description copied from interface:ContentType
Retrieves the names of all the content type's view- Specified by:
getViewNames
in interfaceContentType
- Parameters:
includeInternals
- if the result should include internal views.- Returns:
- the views' names
-
getView
public View getView(String viewName)
Description copied from interface:ContentType
Retrieves the view with the given name- Specified by:
getView
in interfaceContentType
- Parameters:
viewName
- the name of the view to retrieve- Returns:
- the view
-
getFamilyId
public String getFamilyId()
Description copied from interface:Model
Retrieves the Family Id (for example the extension point) Each model Id have to be unique in it's family Id- Specified by:
getFamilyId
in interfaceModel
- Returns:
- content point (for example "org.ametys.cms.contenttype.ContentTypeExtensionPoint" for a content)
-
-