Package org.ametys.cms.contenttype
Class ContentTypesHelper
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.ametys.cms.contenttype.ContentTypesHelper
-
- All Implemented Interfaces:
Disposable
,Initializable
,Component
,LogEnabled
,Serviceable
,ThreadSafe
public class ContentTypesHelper extends AbstractLogEnabled implements Component, Serviceable, ThreadSafe, Disposable, Initializable
Helper for manipulatingContentType
s
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ContentTypesHelper.CacheKey
(package private) class
ContentTypesHelper.ContentTypeComparator
-
Field Summary
Fields Modifier and Type Field Description private static String
__EDITION_METADATASET
private static String
__VIEW_CACHE
private static String
__VIEW_METADATASET
private AbstractCacheManager
_cacheManager
protected ContentAttributeTypeExtensionPoint
_contentAttributeTypeExtensionPoint
The extension point with the available types for contentsprotected ContentTypeExtensionPoint
_cTypeEP
The content types extension pointprivate DynamicContentTypeDescriptorExtentionPoint
_dynamicCTDescriptorEP
protected RightManager
_rightManager
The rights managerprotected RootContentHelper
_rootContentHelper
Helper for root contentprivate ServiceManager
_smanager
protected CurrentUserProvider
_userProvider
The current user providerstatic String
ARCHIVED_CONTENT_TYPE
Archived content typestatic String
ROLE
The Avalon role
-
Constructor Summary
Constructors Constructor Description ContentTypesHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private void
_addIfNotPresent(Collection<String> collection, String value)
private List<Set<String>>
_buildReverseHierarchies(String contentTypeId, Set<String> hierarchy)
private MetadataSet
_computeMetadataSetForEdition(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.private MetadataSet
_computeMetadataSetForView(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.private View
_computeView(String viewName, String[] contentTypeIds, String[] mixinIds)
private boolean
_containsContentType(String[] cTypesId, String cTypeId)
private void
_copyMetadataSetElementsIfNotExist(AbstractMetadataSetElement src, AbstractMetadataSetElement dest, AbstractMetadataSetElement reference)
Deprecated.UseView.includeView(View)
insteadprotected void
_createCaches()
Creates the cachesprivate Map<String,Object>
_dispatchContentTypes(boolean checkRights, boolean includePrivate, boolean includeMixins, boolean includeAbstract, Collection<String> allContentTypesIds)
private Cache<ContentTypesHelper.CacheKey,MetadataSet>
_getCacheForEdition()
Deprecated.private Cache<ContentTypesHelper.CacheKey,MetadataSet>
_getCacheForView()
Deprecated.protected ContentTypeExtensionPoint
_getContentTypeEP()
Lazy lookup ofContentTypeExtensionPoint
private DynamicContentTypeDescriptorExtentionPoint
_getDynamicContentTypeDescriptorExtentionPoint()
private List<MetadataDefinition>
_getMetadataDefinitionPath(String metadataPath, String[] cTypes, String[] mixins)
Deprecated.UsegetModelItemPath(String, Content)
insteadprotected MetadataSet
_getMetadataSet(ContentType contentType, String metadataSetName, boolean isEdition)
Deprecated.UseAttributeDefinition
API insteadprivate Cache<ContentTypesHelper.CacheKey,View>
_getViewCache()
protected boolean
_hasRight(ContentType contentType)
Test if the current user has the right needed by the content type to create a content.protected void
_populateModelItemsAccumulator(Map<String,ModelItem> internalAcc, ViewItemContainer viewItemContainer, String prefix)
Populates the accumulator with the model itemsList<Set<String>>
buildReverseHierarchies(String contentTypeId)
Builds the reverse hierarchies of ancestors of a content typeboolean
canRead(Content content, MetadataDefinition metadataDef)
Deprecated.UseAttributeDefinition.canRead(Content)
insteadboolean
canWrite(Content content, MetadataDefinition metadataDef)
Deprecated.UseAttributeDefinition.canWrite(Content)
insteadvoid
copyMetadataSetElementsIfNotExist(AbstractMetadataSetElement src, AbstractMetadataSetElement dest)
Deprecated.UseView.includeView(View)
insteadvoid
dispose()
Set<String>
getAncestors(String contentTypeId)
Get all ancestors for the given content typeSet<String>
getCommonAncestors(Collection<String> contentTypeIds)
Get the identifiers of the content types common ancestorsMap<String,ModelItem>
getCommonModelItems(Collection<String> contentTypeIds, String viewName)
Retrieves the common model items for a list of content typesI18nizableText
getContentTypeCategory(Content content)
Retrieves the category of the content type.I18nizableText
getContentTypeDefaultTitle(Content content)
Retrieves the default title of the content type.I18nizableText
getContentTypeDescription(Content content)
Retrieves the description of the content type.String
getContentTypeIdForRendering(Content content)
Get the id of content type to use for renderingI18nizableText
getContentTypeLabel(Content content)
Retrieves the label of the content type.String
getContentTypePluginForRendering(Content content)
Get the plugin name of content type to use for renderingMap<String,Object>
getContentTypeProperties(ContentType contentType)
Get the content type propertiesSet<Map<String,Object>>
getContentTypesInformations()
Get information on content types.Set<Map<String,Object>>
getContentTypesInformations(List<String> contentTypeIds, boolean withRight)
Get the content types information as JSONMap<String,Object>
getContentTypesList(List<String> ids, boolean inherited, boolean checkRights, boolean includePrivate, boolean includeMixins, boolean includeAbstract)
Get information on content types.String
getDynamicContentTypeId(String[] contentTypes, String[] mixinTypes)
Get the id of the dynamic content type matching to given onesString
getDynamicContentTypePlugin(String[] contentTypes, String[] mixinTypes)
Get the plugin name of the dynamic content type matching to given onesContentType
getFirstContentType(Content content)
Get the content type which determines the content icons and renderingString
getIconDecorator(Content content)
Retrieves the CSS class to use as decorator above the main iconString
getIconGlyph(Content content)
Retrieves the CSS class to use as glyph icon of the contentIndexingModel
getIndexingModel(String[] cTypes, String[] mixins)
Get the indexing model resulting of the concatenation of indexing models of given content types and mixins.IndexingModel
getIndexingModel(Content content)
Get the indexing model resulting of the concatenation of indexing models of given content types and mixins.String
getLargeIcon(Content content)
Retrieves the URL of the icon without the context path.String
getMediumIcon(Content content)
Retrieves the URL of the icon without the context path.MetadataDefinition
getMetadataDefinition(String metadataPath, String[] cTypes, String[] mixins)
Deprecated.UsegetModelItem(String, String[], String[])
insteadMetadataDefinition
getMetadataDefinition(String metadataPath, ContentType initialContentType)
Deprecated.UseModelItemAccessor.getModelItem(String)
insteadMetadataDefinition
getMetadataDefinition(String metadataPath, Content content)
Deprecated.UseModelAwareDataAwareAmetysObject.getDefinition(String)
API insteadMetadataDefinition
getMetadataDefinitionByMetadataValuePath(String metadataValuePath, String[] cTypes, String[] mixins)
Deprecated.private MetadataDefinition
getMetadataDefinitionByMetadataValuePath(String metadataValuePath, MetadataDefinitionHolder metadataDefHolder)
Deprecated.UseModelItemAccessor.getModelItem(String)
insteadMetadataDefinition
getMetadataDefinitionByMetadataValuePath(String metadataValuePath, Content content)
Deprecated.List<MetadataDefinition>
getMetadataDefinitionPath(String metadataPath, ContentType initialContentType)
Deprecated.UsegetModelItemPath(String, ContentType)
insteadList<MetadataDefinition>
getMetadataDefinitionPath(String metadataPath, Content content)
Deprecated.UsegetModelItemPath(String, Content)
insteadMap<String,MetadataDefinition>
getMetadataDefinitions(String[] cTypes)
Deprecated.UsegetModelItems(String[])
insteadMap<String,MetadataDefinition>
getMetadataDefinitions(Set<String> metadataPaths, String[] cTypes, String[] mixins)
Deprecated.UseAttributeDefinition
API insteadMap<String,MetadataDefinition>
getMetadataDefinitions(Set<String> metadataPaths, ContentType initialContentType)
Deprecated.UseAttributeDefinition
API insteadMap<String,MetadataDefinition>
getMetadataDefinitions(Set<String> metadataPaths, Content content)
Deprecated.UseAttributeDefinition
API insteadMap<String,MetadataDefinition>
getMetadataDefinitions(MetadataDefinitionHolder metaDefHolder, Predicate<MetadataDefinition> predicate)
Deprecated.UseAttributeDefinition
API insteadMap<String,MetadataDefinition>
getMetadataDefinitions(MetadataSet metadataSet, String[] cTypes, String[] mixins)
Deprecated.UseViewHelper.getModelItemsFromView(View)
insteadMap<String,MetadataDefinition>
getMetadataDefinitions(MetadataSet metadataSet, ContentType initialContentType)
Deprecated.UseViewHelper.getModelItemsFromView(View)
insteadMap<String,MetadataDefinition>
getMetadataDefinitions(MetadataSet metadataSet, Content content)
Deprecated.UseViewHelper.getModelItemsFromView(View)
insteadSet<String>
getMetadataNames(String[] cTypes, String[] mixins)
Deprecated.UseModelItemAccessor.getModelItems()
insteadSet<String>
getMetadataNames(Content content)
Deprecated.UseModelItemAccessor.getModelItems()
insteadprotected Set<String>
getMetadataPaths(AbstractMetadataSetElement metadataSet, String prefix)
Deprecated.UseViewHelper.getModelItemsPathsFromView(View)
insteadSet<String>
getMetadataPaths(MetadataSet metadataSet)
Deprecated.UseViewHelper.getModelItemsPathsFromView(View)
insteadMetadataSet
getMetadataSetForEdition(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.UsegetView(String, String[], String[])
insteadMetadataSet
getMetadataSetForView(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.UsegetView(String, String[], String[])
insteadMap<String,MetadataSet>
getMetadataSetsForEdition(String[] cTypes, String[] mixins, boolean includeInternal)
Deprecated.UsegetViews(String[], String[])
insteadMap<String,MetadataSet>
getMetadataSetsForView(String[] cTypes, String[] mixins, boolean includeInternal)
Deprecated.UsegetViews(String[], String[])
insteadMetadataSet
getMetadataSetWithFallback(String metadataSetName, String fallbackMetadataSetName, String[] cTypes, String[] mixins, boolean isEditionMetadataSet)
Deprecated.ModelItem
getModelItem(String path, String[] cTypes, String[] mixins)
Retrieves the model item at the given pathList<ModelItem>
getModelItemPath(String path, ContentType contentType)
Retrieve the list of successive model items represented by the given path.List<ModelItem>
getModelItemPath(String path, Content content)
Retrieve the list of successive model items represented by the given path.Map<String,ModelItem>
getModelItems(String[] contentTypes)
Retrieves all model items of given content types.Map<String,List<ModelItem>>
getModelItemsPaths(Set<String> paths, ContentType contentType)
Retrieve the list of successive model items represented by the given paths, indexed by path.Map<String,List<ModelItem>>
getModelItemsPaths(Set<String> paths, Content content)
Retrieve the list of successive model items represented by the given paths, indexed by path.String
getPluginName(String contentTypeId)
Get plugin name for the given content typeString
getSmallIcon(Content content)
Retrieves the URL of the icon without the context path.Pair<String[],String[]>
getSupertypeIds(String contentTypeId)
Get super type's ids for the given content type The first entry contains super content types, the second one contains super mixin typesAttributeDefinition<String>
getTitleAttributeDefinition()
Retrieves the definition for the standard "title" attribute.static MetadataDefinition
getTitleMetadataDefinition()
Deprecated.UsegetTitleAttributeDefinition()
insteadMap<String,Object>
getTitleViewAsJSON(String contentTypeId, boolean isEdition)
Converts the title view in a JSON MapView
getView(String viewName, String[] contentTypeIds, String[] mixinIds)
Get the view for view resulting of the concatenation of views of the given content types and mixins.Map<String,Object>
getViewAsJSON(String contentTypeId, String viewName, boolean isEdition)
Converts the view with the given name in a JSON MapMap<String,View>
getViews(String[] contentTypeIds, String[] mixinIds)
Get all views resulting of the concatenation of views of given content types and mixins.Map<String,View>
getViews(String[] contentTypeIds, String[] mixinIds, Set<String> viewNamesToAvoid)
Get all views resulting of the concatenation of views of given content types and mixins.List<Map<String,Object>>
getViewsInfo(String contentTypeId, boolean includeInternals)
Get the views of a content typeView
getViewWithFallback(String viewName, String fallbackViewName, String[] contentTypeIds, String[] mixinIds)
Get the view for view resulting of the concatenation of views of the given content types and mixins.void
initialize()
Initializeboolean
isArchivedContentType(String cTypeId)
Determines if the content type is an archived content typeboolean
isCompatibleContentType(Content content, String cTypeId)
Determines if the given content type can be added to contentboolean
isInstanceOf(Content content, String cTypeId)
Determines if a content is a instance of given content type idprotected Set<String>
removeAncestors(Set<String> contentTypes)
Remove all content types in the set that are ancestors of other content types in the set.void
service(ServiceManager smanager)
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
-
-
-
Field Detail
-
ARCHIVED_CONTENT_TYPE
public static final String ARCHIVED_CONTENT_TYPE
Archived content type- See Also:
- Constant Field Values
-
__VIEW_METADATASET
private static final String __VIEW_METADATASET
-
__EDITION_METADATASET
private static final String __EDITION_METADATASET
-
__VIEW_CACHE
private static final String __VIEW_CACHE
-
_cTypeEP
protected ContentTypeExtensionPoint _cTypeEP
The content types extension point
-
_userProvider
protected CurrentUserProvider _userProvider
The current user provider
-
_rightManager
protected RightManager _rightManager
The rights manager
-
_rootContentHelper
protected RootContentHelper _rootContentHelper
Helper for root content
-
_contentAttributeTypeExtensionPoint
protected ContentAttributeTypeExtensionPoint _contentAttributeTypeExtensionPoint
The extension point with the available types for contents
-
_dynamicCTDescriptorEP
private DynamicContentTypeDescriptorExtentionPoint _dynamicCTDescriptorEP
-
_smanager
private ServiceManager _smanager
-
_cacheManager
private AbstractCacheManager _cacheManager
-
-
Constructor Detail
-
ContentTypesHelper
public ContentTypesHelper()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize()
Initialize- Specified by:
initialize
in interfaceInitializable
-
_createCaches
protected void _createCaches()
Creates the caches
-
_getDynamicContentTypeDescriptorExtentionPoint
private DynamicContentTypeDescriptorExtentionPoint _getDynamicContentTypeDescriptorExtentionPoint()
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
_getContentTypeEP
protected ContentTypeExtensionPoint _getContentTypeEP()
Lazy lookup ofContentTypeExtensionPoint
- Returns:
- the content type extension point
-
isInstanceOf
public boolean isInstanceOf(Content content, String cTypeId)
Determines if a content is a instance of given content type id- Parameters:
content
- The contentcTypeId
- The id of content type or mixin- Returns:
true
if the content is an instance of content type
-
_containsContentType
private boolean _containsContentType(String[] cTypesId, String cTypeId)
-
getCommonAncestors
public Set<String> getCommonAncestors(Collection<String> contentTypeIds)
Get the identifiers of the content types common ancestors- Parameters:
contentTypeIds
- The identifiers of the content types to compare- Returns:
- The identifiers of common ancestors
-
removeAncestors
protected Set<String> removeAncestors(Set<String> contentTypes)
Remove all content types in the set that are ancestors of other content types in the set.- Parameters:
contentTypes
- a Set of content type IDs.- Returns:
- a Set of content type IDs without ancestors.
-
getAncestors
public Set<String> getAncestors(String contentTypeId)
Get all ancestors for the given content type- Parameters:
contentTypeId
- The content type id to test- Returns:
- A non-null set of all ancestors. Does not contains the contentTypeId itself.
- Throws:
IllegalArgumentException
- if the content type does not exist.
-
getSupertypeIds
public Pair<String[],String[]> getSupertypeIds(String contentTypeId)
Get super type's ids for the given content type The first entry contains super content types, the second one contains super mixin types- Parameters:
contentTypeId
- The content type id to test- Returns:
- An array of super type's ids.
- Throws:
IllegalArgumentException
- if the content type does not exist.
-
getPluginName
public String getPluginName(String contentTypeId)
Get plugin name for the given content type- Parameters:
contentTypeId
- The content type id to test- Returns:
- the plugin name
- Throws:
IllegalArgumentException
- if the content type does not exist.
-
buildReverseHierarchies
public List<Set<String>> buildReverseHierarchies(String contentTypeId)
Builds the reverse hierarchies of ancestors of a content type- Parameters:
contentTypeId
- The content type's id- Returns:
- the reverse hierarchies with ancestors
-
_buildReverseHierarchies
private List<Set<String>> _buildReverseHierarchies(String contentTypeId, Set<String> hierarchy)
-
getMetadataNames
@Deprecated public Set<String> getMetadataNames(Content content)
Deprecated.UseModelItemAccessor.getModelItems()
insteadRetrieves the root metadata names of a content.- Parameters:
content
- The content.- Returns:
- the metadata names.
-
getMetadataNames
@Deprecated public Set<String> getMetadataNames(String[] cTypes, String[] mixins)
Deprecated.UseModelItemAccessor.getModelItems()
insteadRetrieves the metadata names resulting of the union of metadata names of given content types and mixins- Parameters:
cTypes
- The id of content typesmixins
- The id of mixins- Returns:
- the metadata names.
-
getViews
public Map<String,View> getViews(String[] contentTypeIds, String[] mixinIds)
Get all views resulting of the concatenation of views of given content types and mixins.- Parameters:
contentTypeIds
- the identifiers of the content typesmixinIds
- the identifiers of the mixins- Returns:
- The views
-
getViews
public Map<String,View> getViews(String[] contentTypeIds, String[] mixinIds, Set<String> viewNamesToAvoid)
Get all views resulting of the concatenation of views of given content types and mixins.- Parameters:
contentTypeIds
- the identifiers of the content typesmixinIds
- the identifiers of the mixinsviewNamesToAvoid
- names of views that should not be managed- Returns:
- The views
-
getView
public View getView(String viewName, String[] contentTypeIds, String[] mixinIds)
Get the view for view resulting of the concatenation of views of the given content types and mixins.- Parameters:
viewName
- the name of the view to retrievecontentTypeIds
- the identifiers of the content typesmixinIds
- the identifiers of the mixins- Returns:
- The view or null if none matches.
-
getViewWithFallback
public View getViewWithFallback(String viewName, String fallbackViewName, String[] contentTypeIds, String[] mixinIds)
Get the view for view resulting of the concatenation of views of the given content types and mixins.- Parameters:
viewName
- the name of the view to retrievefallbackViewName
- the name of the view to retrieve if the initial was not found. Can be null.contentTypeIds
- the identifiers of the content typesmixinIds
- the identifiers of the mixins- Returns:
- The view or null if none matches.
-
getViewAsJSON
public Map<String,Object> getViewAsJSON(String contentTypeId, String viewName, boolean isEdition) throws ProcessingException
Converts the view with the given name in a JSON Map- Parameters:
contentTypeId
- the content type identifierviewName
- the name of the view to convertisEdition
-true
if the JSON result is used for edition purposes (configure a form panel, ...)false
otherwise- Returns:
- the view as a JSON Map
- Throws:
ProcessingException
- if an error occurs when converting the view
-
getTitleViewAsJSON
public Map<String,Object> getTitleViewAsJSON(String contentTypeId, boolean isEdition) throws ProcessingException
Converts the title view in a JSON Map- Parameters:
contentTypeId
- the content type identifierisEdition
-true
if the JSON result is used for edition purposes (configure a form panel, ...)false
otherwise- Returns:
- the view as a JSON Map
- Throws:
ProcessingException
- if an error occurs when converting the view
-
_computeView
private View _computeView(String viewName, String[] contentTypeIds, String[] mixinIds)
-
getMetadataSetsForView
@Deprecated public Map<String,MetadataSet> getMetadataSetsForView(String[] cTypes, String[] mixins, boolean includeInternal)
Deprecated.UsegetViews(String[], String[])
insteadGet all metadata sets for view resulting of the concatenation of metadata sets of given content types and mixins.- Parameters:
cTypes
- The id of content typesmixins
- The id of mixinsincludeInternal
-true
True to include internal metadata sets- Returns:
- The metadata sets
-
getMetadataSetsForEdition
@Deprecated public Map<String,MetadataSet> getMetadataSetsForEdition(String[] cTypes, String[] mixins, boolean includeInternal)
Deprecated.UsegetViews(String[], String[])
insteadGet all metadata sets for edition resulting of the concatenation of metadata sets of given content types and mixins.- Parameters:
cTypes
- The id of content typesmixins
- The id of mixinsincludeInternal
-true
True to include internal metadata sets- Returns:
- The metadata sets
-
getMetadataSetForView
@Deprecated public MetadataSet getMetadataSetForView(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.UsegetView(String, String[], String[])
insteadGet the metadata set for view resulting of the concatenation of metadata sets of given content types and mixins.- Parameters:
metadataSetName
- the name of metadata set to retrievecTypes
- The id of content typesmixins
- The id of mixins- Returns:
- The list of metadata set names.
-
_computeMetadataSetForView
@Deprecated private MetadataSet _computeMetadataSetForView(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.
-
getMetadataSetWithFallback
@Deprecated public MetadataSet getMetadataSetWithFallback(String metadataSetName, String fallbackMetadataSetName, String[] cTypes, String[] mixins, boolean isEditionMetadataSet) throws IllegalArgumentException
Deprecated.Get the metadata set with a fallback metadata set if not found. The return metadata set is the concatenation of metadata sets of given content types and mixins.- Parameters:
metadataSetName
- The initial requested metadata setfallbackMetadataSetName
- The fallback metadata set if the initial was not found. Can be null.cTypes
- the id of content typesmixins
- the id of mixinsisEditionMetadataSet
- true if the requested metadata set is for edition- Returns:
- the metadata set
- Throws:
IllegalArgumentException
- if no metadata set, nor fallback metadata set, was found
-
getMetadataSetForEdition
@Deprecated public MetadataSet getMetadataSetForEdition(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.UsegetView(String, String[], String[])
insteadGet the metadata set for edition resulting of the concatenation of metadata sets of given content types and mixins.- Parameters:
metadataSetName
- the name of metadata set to retrievecTypes
- The id of content typesmixins
- The id of mixins- Returns:
- The metadata set
-
_computeMetadataSetForEdition
@Deprecated private MetadataSet _computeMetadataSetForEdition(String metadataSetName, String[] cTypes, String[] mixins)
Deprecated.
-
getViewsInfo
public List<Map<String,Object>> getViewsInfo(String contentTypeId, boolean includeInternals)
Get the views of a content type- Parameters:
contentTypeId
- the content type idincludeInternals
- Set to true to include internal views.- Returns:
- the views' info
-
getIndexingModel
public IndexingModel getIndexingModel(Content content)
Get the indexing model resulting of the concatenation of indexing models of given content types and mixins.- Parameters:
content
- The content.- Returns:
- The indexing model
-
getIndexingModel
public IndexingModel getIndexingModel(String[] cTypes, String[] mixins)
Get the indexing model resulting of the concatenation of indexing models of given content types and mixins.- Parameters:
cTypes
- The id of content typesmixins
- The id of mixins- Returns:
- The indexing model
-
copyMetadataSetElementsIfNotExist
@Deprecated public void copyMetadataSetElementsIfNotExist(AbstractMetadataSetElement src, AbstractMetadataSetElement dest)
Deprecated.UseView.includeView(View)
insteadCopy the elements of metadata set into a metadata set of destination, only if the elements are not already presents- Parameters:
src
- The metadata set to copydest
- The metadata of destination
-
_copyMetadataSetElementsIfNotExist
@Deprecated private void _copyMetadataSetElementsIfNotExist(AbstractMetadataSetElement src, AbstractMetadataSetElement dest, AbstractMetadataSetElement reference)
Deprecated.UseView.includeView(View)
insteadCopy the elements of the source to the destination if they do not exist in the reference- Parameters:
src
- the sourcedest
- the destinationreference
- the reference
-
getMetadataDefinitionByMetadataValuePath
@Deprecated public MetadataDefinition getMetadataDefinitionByMetadataValuePath(String metadataValuePath, Content content)
Deprecated.Retrieve the definition of a given content metadata value path.- Parameters:
metadataValuePath
- the metadata value path: it is separated by slashes and repeaters are valued: eg: "mycomposite/myrepeater[3]/mymetadata".content
- the content.- Returns:
- the metadata definition or
null
if not found
-
getMetadataDefinitionByMetadataValuePath
@Deprecated public MetadataDefinition getMetadataDefinitionByMetadataValuePath(String metadataValuePath, String[] cTypes, String[] mixins)
Deprecated.Retrieve the definition of a given content metadata value path.- Parameters:
metadataValuePath
- the metadata value path: it is separated by slashes and repeaters are valued: eg: "mycomposite.myrepeater[3].mymetadata".cTypes
- The id of content typesmixins
- The id of mixins- Returns:
- the metadata definition or
null
if not found
-
getMetadataDefinitionByMetadataValuePath
@Deprecated private MetadataDefinition getMetadataDefinitionByMetadataValuePath(String metadataValuePath, MetadataDefinitionHolder metadataDefHolder)
Deprecated.UseModelItemAccessor.getModelItem(String)
insteadRetrieve the definition of a given content metadata value path.- Parameters:
metadataValuePath
- the metadata value path: it is separated by slashes and repeaters are valued: eg: "mycomposite/myrepeater[3]/mymetadata".metadataDefHolder
- The metadata def holder (such as the content type)- Returns:
- the metadata definition or
null
if not found
-
getMetadataPaths
@Deprecated public Set<String> getMetadataPaths(MetadataSet metadataSet)
Deprecated.UseViewHelper.getModelItemsPathsFromView(View)
insteadGet a flat map of MetadataDefinition corresponding to a metadataset of a content- Parameters:
metadataSet
- The metadataset to get- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataPaths
@Deprecated protected Set<String> getMetadataPaths(AbstractMetadataSetElement metadataSet, String prefix)
Deprecated.UseViewHelper.getModelItemsPathsFromView(View)
insteadGet a flat map of metadatadefinition corresponding to a metadataset of a content- Parameters:
metadataSet
- The metadataset to getprefix
- The metadata path of the parent- Returns:
- The flat map of metadatapath and metadatadefinition
-
getMetadataDefinition
@Deprecated public MetadataDefinition getMetadataDefinition(String metadataPath, Content content)
Deprecated.UseModelAwareDataAwareAmetysObject.getDefinition(String)
API insteadRetrieve the metadata definition represented by the given path. The path can represent a metadata on another content.- Parameters:
metadataPath
- the metadata path separated by '/'content
- The content.- Returns:
- the metadata definition or null.
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(Set<String> metadataPaths, Content content)
Deprecated.UseAttributeDefinition
API insteadGet a flat map of MetadataDefinition corresponding to a set of metadata paths- Parameters:
metadataPaths
- A set of metadata path to analysecontent
- The content associated- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(MetadataSet metadataSet, Content content)
Deprecated.UseViewHelper.getModelItemsFromView(View)
insteadGet a flat map of MetadataDefinition corresponding to a metadataSet- Parameters:
metadataSet
- A metadataSet to analysecontent
- The content associated- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataDefinitionPath
@Deprecated public List<MetadataDefinition> getMetadataDefinitionPath(String metadataPath, Content content)
Deprecated.UsegetModelItemPath(String, Content)
insteadRetrieve the list of successive metadata definitions represented by the given path. The path can represent a metadata on another content.- Parameters:
metadataPath
- the metadata path separated by '/'content
- The content.- Returns:
- the list of metadata definitions, one by path element.
-
getMetadataDefinition
@Deprecated public MetadataDefinition getMetadataDefinition(String metadataPath, String[] cTypes, String[] mixins)
Deprecated.UsegetModelItem(String, String[], String[])
insteadRetrieve the metadata definition represented by the given path. The path can represent a metadata on another content.- Parameters:
metadataPath
- the metadata path separated by '/'cTypes
- The content types.mixins
- The content mixins types.- Returns:
- the metadata definition or null.
-
getModelItem
public ModelItem getModelItem(String path, String[] cTypes, String[] mixins) throws IllegalArgumentException, UndefinedItemPathException
Retrieves the model item at the given path- Parameters:
path
- path of the model item to retrieve. No matter if it is a definition or data path (with repeater entry positions)cTypes
- identifiers of the content types where to search the model itemmixins
- identifiers of the mixins where to search the model item- Returns:
- the model item
- Throws:
IllegalArgumentException
- if the given path is null or emptyUndefinedItemPathException
- if there is no item defined at the given path in given item containers
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(Set<String> metadataPaths, String[] cTypes, String[] mixins)
Deprecated.UseAttributeDefinition
API insteadGet a flat map of MetadataDefinition corresponding to a set of metadata paths- Parameters:
metadataPaths
- A set of metadata path to analysecTypes
- The content types.mixins
- The content mixins types.- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(MetadataSet metadataSet, String[] cTypes, String[] mixins)
Deprecated.UseViewHelper.getModelItemsFromView(View)
insteadGet a flat map of MetadataDefinition corresponding to a metadataset- Parameters:
metadataSet
- A metadataset to analysecTypes
- The content types.mixins
- The content mixins types.- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(MetadataDefinitionHolder metaDefHolder, Predicate<MetadataDefinition> predicate)
Deprecated.UseAttributeDefinition
API insteadGet a flat map of MetadataDefinition corresponding to the required predicate (boolean-valued function) For example, to get all metadata definitions of type CONTENT, we can do: getMetadataDefinitions(contentType, m -> m.getType() == MetadataType.CONTENT)- Parameters:
metaDefHolder
- The metadata definition holderpredicate
- The predicate (ex. m -> m.getType() == MetadataType.CONTENT)- Returns:
- The flat map of metadata's path and their definition
-
_getMetadataDefinitionPath
@Deprecated private List<MetadataDefinition> _getMetadataDefinitionPath(String metadataPath, String[] cTypes, String[] mixins)
Deprecated.UsegetModelItemPath(String, Content)
insteadRetrieve the list of successive metadata definitions represented by the given path. The path can represent a metadata on another content.- Parameters:
metadataPath
- the metadata path separated by '/'cTypes
- The id of content typesmixins
- The id of mixins- Returns:
- the metadata definition or
null
if not found
-
getMetadataDefinition
@Deprecated public MetadataDefinition getMetadataDefinition(String metadataPath, ContentType initialContentType)
Deprecated.UseModelItemAccessor.getModelItem(String)
insteadRetrieves a metadata definition from a path. The metadata can be defined in a referenced or sub content.- Parameters:
metadataPath
- the metadata path separated by '/'initialContentType
- The initial content type to start the search- Returns:
- the metadata definition or
null
if not found
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(Set<String> metadataPaths, ContentType initialContentType)
Deprecated.UseAttributeDefinition
API insteadGet a flat map of MetadataDefinition corresponding to a set of metadata paths- Parameters:
metadataPaths
- A set of metadata path to analyseinitialContentType
- The initial content type to start the search- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(MetadataSet metadataSet, ContentType initialContentType)
Deprecated.UseViewHelper.getModelItemsFromView(View)
insteadGet a flat map of MetadataDefinition corresponding to a metadataset- Parameters:
metadataSet
- A metadataset to analyseinitialContentType
- The initial content type to start the search- Returns:
- The flat map of metadatapath and MetadataDefinition
-
getMetadataDefinitionPath
@Deprecated public List<MetadataDefinition> getMetadataDefinitionPath(String metadataPath, ContentType initialContentType)
Deprecated.UsegetModelItemPath(String, ContentType)
insteadRetrieve the list of successive metadata definitions represented by the given path. The path can represent a metadata on another content.- Parameters:
initialContentType
- The initial content type to start the searchmetadataPath
- the metadata path separated by '/'- Returns:
- the list of metadata definitions, one by path element.
-
getModelItemsPaths
public Map<String,List<ModelItem>> getModelItemsPaths(Set<String> paths, Content content)
Retrieve the list of successive model items represented by the given paths, indexed by path.- Parameters:
paths
- paths of the model items to retrieve. These paths are relative to the given containers. No matter if they are definition or data paths (with repeater entry positions)content
- the content- Returns:
- the list of successive model items, indexed by path
- Throws:
IllegalArgumentException
- if one of the given paths is null or emptyUndefinedItemPathException
- if there is no item defined at one of the given paths in given item containers
-
getModelItemPath
public List<ModelItem> getModelItemPath(String path, Content content) throws IllegalArgumentException, UndefinedItemPathException
Retrieve the list of successive model items represented by the given path.- Parameters:
path
- path of the model items to retrieve. This path is relative to the given containers. No matter if it is a definition or data path (with repeater entry positions)content
- the content- Returns:
- the list of successive model items
- Throws:
IllegalArgumentException
- if the given path is null or emptyUndefinedItemPathException
- if there is no item defined at the given path in given item containers
-
getModelItemsPaths
public Map<String,List<ModelItem>> getModelItemsPaths(Set<String> paths, ContentType contentType)
Retrieve the list of successive model items represented by the given paths, indexed by path.- Parameters:
paths
- paths of the model items to retrieve. These paths are relative to the given containers. No matter if they are definition or data paths (with repeater entry positions)contentType
- the content type- Returns:
- the list of successive model items, indexed by path
- Throws:
IllegalArgumentException
- if one of the given paths is null or emptyUndefinedItemPathException
- if there is no item defined at one of the given paths in given item containers
-
getModelItemPath
public List<ModelItem> getModelItemPath(String path, ContentType contentType)
Retrieve the list of successive model items represented by the given path.- Parameters:
path
- path of the model items to retrieve. This path is relative to the given containers. No matter if it is a definition or data path (with repeater entry positions)contentType
- the content type- Returns:
- the list of successive model items
- Throws:
IllegalArgumentException
- if the given path is null or emptyUndefinedItemPathException
- if there is no item defined at the given path in given item containers
-
isCompatibleContentType
public boolean isCompatibleContentType(Content content, String cTypeId)
Determines if the given content type can be added to content- Parameters:
content
- The contentcTypeId
- The id of content type- Returns:
true
if the content type is compatible with content
-
getMetadataDefinitions
@Deprecated public Map<String,MetadataDefinition> getMetadataDefinitions(String[] cTypes) throws ConfigurationException
Deprecated.UsegetModelItems(String[])
insteadRetrieves all definitions of a metadata resulting of the concatenation of metadata of given content types.- Parameters:
cTypes
- The id of content types- Returns:
- the metadata definitions
- Throws:
ConfigurationException
- if an error occurred
-
getModelItems
public Map<String,ModelItem> getModelItems(String[] contentTypes) throws ConfigurationException
Retrieves all model items of given content types.- Parameters:
contentTypes
- The identifier of the content types- Returns:
- the model items
- Throws:
ConfigurationException
- if an error occurred
-
getCommonModelItems
public Map<String,ModelItem> getCommonModelItems(Collection<String> contentTypeIds, String viewName)
Retrieves the common model items for a list of content types- Parameters:
contentTypeIds
- The list of content types to considerviewName
- The view name to list model items- Returns:
- The map of model items. Key are the model item's path in the content type
-
_populateModelItemsAccumulator
protected void _populateModelItemsAccumulator(Map<String,ModelItem> internalAcc, ViewItemContainer viewItemContainer, String prefix)
Populates the accumulator with the model items- Parameters:
internalAcc
- the accumulator of model itemsviewItemContainer
- the view item container of the contentprefix
- the view item accessor path prefix
-
_getMetadataSet
@Deprecated protected MetadataSet _getMetadataSet(ContentType contentType, String metadataSetName, boolean isEdition)
Deprecated.UseAttributeDefinition
API insteadGet the metadataset of a content given the parameters- Parameters:
contentType
- The content type to considermetadataSetName
- The metadata set to get (that list the metadata to consider)isEdition
- Is the metadata set for edition (or for view)- Returns:
- The metadataset
-
getContentTypesInformations
public Set<Map<String,Object>> getContentTypesInformations()
Get information on content types.- Returns:
- A Map with content types
-
getContentTypesInformations
public Set<Map<String,Object>> getContentTypesInformations(List<String> contentTypeIds, boolean withRight)
Get the content types information as JSON- Parameters:
contentTypeIds
- the list of content type idswithRight
- true to add rights to results- Returns:
- the list of content types information as JSON
-
getContentTypesList
public Map<String,Object> getContentTypesList(List<String> ids, boolean inherited, boolean checkRights, boolean includePrivate, boolean includeMixins, boolean includeAbstract)
Get information on content types.- Parameters:
ids
- The id of content types to retrieveinherited
- If true, the sub-types will be also returned.checkRights
- If true, only content types allowed for creation will be returnedincludePrivate
- If true, the list will include the private content types. By default the list is restricted to the public content types.includeMixins
- If true the list will include the mixins content types.includeAbstract
- If true the list will include the abstract content types.- Returns:
- A Map with retrieved, unknown, not-allowed and private content types
-
_dispatchContentTypes
private Map<String,Object> _dispatchContentTypes(boolean checkRights, boolean includePrivate, boolean includeMixins, boolean includeAbstract, Collection<String> allContentTypesIds)
-
getContentTypeProperties
public Map<String,Object> getContentTypeProperties(ContentType contentType)
Get the content type properties- Parameters:
contentType
- The content type- Returns:
- The content type properties
-
_hasRight
protected boolean _hasRight(ContentType contentType)
Test if the current user has the right needed by the content type to create a content.- Parameters:
contentType
- The content type- Returns:
- true if the user has the right needed, false otherwise.
-
_addIfNotPresent
private void _addIfNotPresent(Collection<String> collection, String value)
-
canRead
@Deprecated public boolean canRead(Content content, MetadataDefinition metadataDef)
Deprecated.UseAttributeDefinition.canRead(Content)
insteadDetermine whether a metadata can be read at this time.- Parameters:
metadataDef
- the metadata definitioncontent
- The content where metadata is to be read on.- 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
@Deprecated public boolean canWrite(Content content, MetadataDefinition metadataDef)
Deprecated.UseAttributeDefinition.canWrite(Content)
insteadDetermine whether a metadata can be read at this time.- Parameters:
metadataDef
- the metadata definitioncontent
- The content where metadata is to be read on.- 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.
-
getContentTypeIdForRendering
public String getContentTypeIdForRendering(Content content)
Get the id of content type to use for rendering- Parameters:
content
- The content- Returns:
- the id of dynamic or standard content type
-
getDynamicContentTypeId
public String getDynamicContentTypeId(String[] contentTypes, String[] mixinTypes)
Get the id of the dynamic content type matching to given ones- Parameters:
contentTypes
- The content typesmixinTypes
- The mixins- Returns:
- the id of dynamic content type or null if no dynamic content type was found
-
getContentTypePluginForRendering
public String getContentTypePluginForRendering(Content content)
Get the plugin name of content type to use for rendering- Parameters:
content
- The content- Returns:
- the plugin name of dynamic or standard content type
-
getDynamicContentTypePlugin
public String getDynamicContentTypePlugin(String[] contentTypes, String[] mixinTypes)
Get the plugin name of the dynamic content type matching to given ones- Parameters:
contentTypes
- The content typesmixinTypes
- The mixins- Returns:
- the plugin name of dynamic content type or null if no dynamic content type was found
-
getContentTypeLabel
public I18nizableText getContentTypeLabel(Content content)
Retrieves the label of the content type.- Parameters:
content
- The content- Returns:
- the label.
-
getContentTypeDescription
public I18nizableText getContentTypeDescription(Content content)
Retrieves the description of the content type.- Parameters:
content
- The content- Returns:
- the label.
-
getContentTypeDefaultTitle
public I18nizableText getContentTypeDefaultTitle(Content content)
Retrieves the default title of the content type.- Parameters:
content
- The content- Returns:
- the label.
-
getContentTypeCategory
public I18nizableText getContentTypeCategory(Content content)
Retrieves the category of the content type.- Parameters:
content
- The content- Returns:
- the label.
-
getIconGlyph
public String getIconGlyph(Content content)
Retrieves the CSS class to use as glyph icon of the content- Parameters:
content
- The content- Returns:
- the glyph
-
getIconDecorator
public String getIconDecorator(Content content)
Retrieves the CSS class to use as decorator above the main icon- Parameters:
content
- The content- Returns:
- the decorator CSS class name
-
getSmallIcon
public String getSmallIcon(Content content)
Retrieves the URL of the icon without the context path.- Parameters:
content
- The content- Returns:
- the icon URL for the small image 16x16.
-
getMediumIcon
public String getMediumIcon(Content content)
Retrieves the URL of the icon without the context path.- Parameters:
content
- The content- Returns:
- the icon URL for the medium image 32x32.
-
getLargeIcon
public String getLargeIcon(Content content)
Retrieves the URL of the icon without the context path.- Parameters:
content
- The content- Returns:
- the icon URL for the large image 48x48.
-
getFirstContentType
public ContentType getFirstContentType(Content content)
Get the content type which determines the content icons and rendering- Parameters:
content
- The content- Returns:
- The main content type
-
getTitleMetadataDefinition
@Deprecated public static MetadataDefinition getTitleMetadataDefinition()
Deprecated.UsegetTitleAttributeDefinition()
insteadGet the metadata definition for the "title" standard metadata.- Returns:
- The standard title metadata definition.
-
getTitleAttributeDefinition
public AttributeDefinition<String> getTitleAttributeDefinition()
Retrieves the definition for the standard "title" attribute.- Returns:
- the standard "title" attribute.
-
isArchivedContentType
public boolean isArchivedContentType(String cTypeId)
Determines if the content type is an archived content type- Parameters:
cTypeId
- The id of content type- Returns:
- true if the content type is an org.ametys.cms.ArchivedContent
-
_getCacheForView
@Deprecated private Cache<ContentTypesHelper.CacheKey,MetadataSet> _getCacheForView()
Deprecated.
-
_getCacheForEdition
@Deprecated private Cache<ContentTypesHelper.CacheKey,MetadataSet> _getCacheForEdition()
Deprecated.
-
_getViewCache
private Cache<ContentTypesHelper.CacheKey,View> _getViewCache()
-
-