This service gives you access to the Content Model Dictionary. For more information on the Content Model, see Content Model Extension Point. This dictionary provides access to content model meta-data, such as Type and Aspect descriptions. Content model metadata is organized into models where each model is given a qualified name. This means that it is safe to develop independent models and bring them together into the same Repository without name clashes (as long their namespace is different).
The DictionaryService provides access to the entire content model meta-model. The content model meta-model contains information of Types, DataTypes, Properties, Aspects, Associations and Constraints. Operations supported include:
- Getting DataTypes, Types, Associations, Properties, Constraints, Classes from a Content Model.
- Check if a class (i.e. type or aspect) is a sub-class.
- Get sub-types and sub-aspects.
Get all content model types and put in a map keyed on type name prefix string:
Collection<QName> types = serviceRegistry.getDictionaryService().getAllTypes(); Map<String, String> result = new LinkedHashMap<String, String>(types.size()); for (QName type : types) { TypeDefinition typeDef = serviceRegistry.getDictionaryService().getType(type); if (typeDef != null && typeDef.getTitle(serviceRegistry.getDictionaryService()) != null) { result.put(type.toPrefixString(), typeDef.getTitle(dictionaryService)); } }
Get a content model type and check if it has an aspect:
TypeDefinition typeDef = serviceRegistry.getDictionaryService().getType(typeQName); if (typeDef != null) { boolean hasAspect = typeDef.getDefaultAspectNames().contains("cm:titled"); }
Check if a node is of a certain type or sub-type, in this case cm:content:
QName nodeType = serviceRegistry.getNodeService().getType(nodeRef); if (serviceRegistry.getDictionaryService().isSubClass(nodeType, ContentModel.TYPE_CONTENT)) { // This is a file... }