Package org.nuxeo.ecm.core.schema
Class SchemaManagerImpl
- java.lang.Object
-
- org.nuxeo.ecm.core.schema.SchemaManagerImpl
-
- All Implemented Interfaces:
PropertyCharacteristicHandler,SchemaManager,TypeProvider
public class SchemaManagerImpl extends Object implements SchemaManager
Schema Manager implementation.Holds basic types (String, Integer, etc.), schemas, document types and facets.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<TypeConfiguration>allConfigurationsAll the registered configurations (prefetch).protected List<DocumentTypeDescriptor>allDocumentTypesAll the registered document types.protected List<FacetDescriptor>allFacetsAll the registered facets.protected booleanallowVersionWriteForDublinCoreEffective allowVersionWriteForDublinCore flag.protected List<ProxiesDescriptor>allProxiesAll the registered proxy descriptors.protected List<SchemaBindingDescriptor>allSchemasAll the registered schemas.static booleanCLEAR_COMPLEX_PROP_BEFORE_SET_DEFAULTDefault used for clearComplexPropertyBeforeSet if there is no XML configuration found.booleanclearComplexPropertyBeforeSetEffective clearComplexPropertyBeforeSet flag.protected Map<String,Map<String,String>>deprecatedPropertiesDeprecated.since 11.1, usepropertyCharacteristicsinsteadprotected booleandirtyWhether there have been changes to the registered schemas, facets or document types that require recomputation of the effective ones.protected Set<String>disabledFacetsprotected Set<String>disabledSchemasprotected Set<String>disabledTypesprotected Map<String,DocumentTypeImpl>documentTypesEffective document types.protected Map<String,Set<String>>documentTypesExtendingprotected Map<String,Set<String>>documentTypesForFacetMap<String,CompositeType>facetsEffective facets.protected Set<String>noPerDocumentQueryFacetsprotected PrefetchInfoprefetchInfoEffective prefetch info.protected Map<String,Schema>prefixToSchemaprotected Map<String,Map<String,PropertyDescriptor>>propertyCharacteristicsMap holding property characteristics with: schema -> path -> characteristic.protected Set<String>proxySchemaNamesEffective proxy schema names.protected List<Schema>proxySchemasEffective proxy schemas.protected List<Runnable>recomputeCallbacksprotected Map<String,Map<String,String>>removedPropertiesDeprecated.since 11.1, usepropertyCharacteristicsinsteadprotected Map<String,Schema>schemasEffective schemas.static StringSCHEMAS_DIR_NAMEprotected Set<String>specialDocumentTypesprotected Map<String,Type>typesBasic type registry.-
Fields inherited from interface org.nuxeo.ecm.core.schema.SchemaManager
PATH_INDEX_PATTERN
-
-
Constructor Summary
Constructors Constructor Description SchemaManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidcheckDirty()Checks if something has to be recomputed if a dynamic register/unregister happened.protected booleancheckPropertyCharacteristic(String schema, String path, Predicate<PropertyDescriptor> predicate)protected StringcleanPath(String path)Deprecated.since 2021.32 useSchemaManager.normalizePath(String)instead.protected voidclearPropertyCharacteristics()protected voidclearSchemaDir()protected voidcopySchema(SchemaBindingDescriptor sd)protected voidexecuteRecomputeCallbacks()voidflushPendingsRegistration()Set<String>getAllowedSubTypes(String typeName)Returns the types of the children that can be created inside a giventypetype.booleangetAllowVersionWriteForDublinCore()Whether we allow to write the dublincore schema on a version.booleangetClearComplexPropertyBeforeSet()Whether or not to ignore any previous values when setting complex properties.PropertyDeprecationHandlergetDeprecatedProperties()Deprecated.since 11.1, usePropertyCharacteristicHandlermethods insteadSet<String>getDeprecatedProperties(String schema)The returned paths are not Nuxeo xpath as they don't have the schema prefix.DocumentTypegetDocumentType(String name)Gets a document type.DocumentTypeDescriptorgetDocumentTypeDescriptor(String name)Set<String>getDocumentTypeNamesExtending(String docTypeName)Return the names of all document types extending the given one, which is included.Set<String>getDocumentTypeNamesForFacet(String facet)Returns the names of all document types that have given facet.DocumentType[]getDocumentTypes()Gets the list of document types.intgetDocumentTypesCount()CompositeTypegetFacet(String name)Gets a facet.FacetDescriptorgetFacetDescriptor(String name)CompositeType[]getFacets()Gets the list of facets.Optional<String>getFallback(String schema, String path)Returns the fallback associated to this property if exist.FieldgetField(String xpath)Returns the field with given xpath, or null if not found.FieldgetField(Field parent, String subFieldName)Returns the field with given parent field and sub name, or null if not found.protected FieldgetField(Field parent, String subFieldName, boolean finalCall)List<PropertyIndexOrder>getIndexedProperties(String schema)Returns the indexed property paths.Set<String>getNoPerDocumentQueryFacets()Finds which facets are configured as no-per-instance-query.protected <R> Set<R>getPropertyCharacteristics(String schema, Predicate<PropertyDescriptor> predicate, Function<PropertyDescriptor,R> function)List<Schema>getProxySchemas(String docType)Gets the schemas on a proxy for a document of the given type.PropertyDeprecationHandlergetRemovedProperties()Deprecated.since 11.1, usePropertyCharacteristicHandlermethods insteadSet<String>getRemovedProperties(String schema)The returned paths are not Nuxeo xpath as they don't have the schema prefix.Set<String>getRetainableProperties()The returned paths are not Nuxeo xpath as they don't have the schema prefix.Set<String>getRetainableProperties(String schema)The returned paths are not Nuxeo xpath as they don't have the schema prefix.SchemagetSchema(String name)Gets a schema.SchemagetSchemaFromPrefix(String schemaPrefix)SchemagetSchemaFromURI(String schemaURI)Deprecated.since 11.1, seems unusedSchema[]getSchemas()Gets the list of schemas.FilegetSchemasDir()Set<String>getSpecialDocumentTypes()Gets the list of document types excluded from copy.protected TypegetType(String name)protected Collection<Type>getTypes()StringgetXPathSchemaName(String xpath, Set<String> docSchemas)Finds within the schemas the first matching schema having a property with the same name as the first path segment of the xpath.booleanhasSuperType(String docType, String superType)Returns true ifdocTypeis or extendssuperType, false otherwise.booleanisDeprecated(String schema, String path)Checks if the property represented by the givenschemaandpathis deprecated.booleanisProxySchema(String schema, String docType)Checks if a schema is on a proxy for a document of the given type.booleanisRemoved(String schema, String path)Checks if the property represented by the givenschemaandpathis removed.booleanisSecured(String schema, String path)Checks if the property represented by the givenschemaandpathis secured.protected voidloadSchema(SchemaBindingDescriptor sd)protected DocumentTypeDescriptormergeDocumentTypeDescriptors(DocumentTypeDescriptor src, DocumentTypeDescriptor dst)protected voidrecompute()Recomputes effective registries for schemas, facets and document types.protected voidrecomputeConfiguration()protected DocumentTyperecomputeDocumentType(String name, Set<String> stack, Map<String,DocumentTypeDescriptor> dtds)protected DocumentTyperecomputeDocumentType(String name, DocumentTypeDescriptor dtd, DocumentType parent)protected voidrecomputeDocumentTypes()voidrecomputeDynamicFacets()protected voidrecomputeFacet(FacetDescriptor fd)protected voidrecomputeFacets()protected voidrecomputeProxies()protected voidrecomputeSchemas()protected voidregisterBuiltinTypes()voidregisterConfiguration(TypeConfiguration config)voidregisterDocumentType(DocumentTypeDescriptor dtd)protected voidregisterDocumentType(DocumentTypeImpl docType)protected CompositeTyperegisterFacet(String name, Set<String> schemaNames)voidregisterFacet(FacetDescriptor fd)protected voidregisterPropertyCharacteristics(List<PropertyDescriptor> descriptors)voidregisterProxies(ProxiesDescriptor pd)voidregisterRecomputeCallback(Runnable callback)voidregisterSchema(SchemaBindingDescriptor sd)protected voidregisterSchema(Schema schema)protected voidregisterType(Type type)protected FieldresolveSubField(ListType listType, String subName, boolean fallbackOnSubElement)voidunregisterConfiguration(TypeConfiguration config)voidunregisterDocumentType(DocumentTypeDescriptor dtd)voidunregisterFacet(FacetDescriptor fd)voidunregisterProxies(ProxiesDescriptor pd)voidunregisterRecomputeCallback(Runnable callback)voidunregisterSchema(SchemaBindingDescriptor sd)
-
-
-
Field Detail
-
dirty
protected volatile boolean dirty
Whether there have been changes to the registered schemas, facets or document types that require recomputation of the effective ones.
-
allConfigurations
protected List<TypeConfiguration> allConfigurations
All the registered configurations (prefetch).
-
allSchemas
protected List<SchemaBindingDescriptor> allSchemas
All the registered schemas.
-
allFacets
protected List<FacetDescriptor> allFacets
All the registered facets.
-
allDocumentTypes
protected List<DocumentTypeDescriptor> allDocumentTypes
All the registered document types.
-
allProxies
protected List<ProxiesDescriptor> allProxies
All the registered proxy descriptors.
-
prefetchInfo
protected PrefetchInfo prefetchInfo
Effective prefetch info.
-
clearComplexPropertyBeforeSet
public boolean clearComplexPropertyBeforeSet
Effective clearComplexPropertyBeforeSet flag.
-
allowVersionWriteForDublinCore
protected boolean allowVersionWriteForDublinCore
Effective allowVersionWriteForDublinCore flag.
-
facets
public Map<String,CompositeType> facets
Effective facets.
-
documentTypes
protected Map<String,DocumentTypeImpl> documentTypes
Effective document types.
-
SCHEMAS_DIR_NAME
public static final String SCHEMAS_DIR_NAME
- See Also:
- Constant Field Values
-
CLEAR_COMPLEX_PROP_BEFORE_SET_DEFAULT
public static final boolean CLEAR_COMPLEX_PROP_BEFORE_SET_DEFAULT
Default used for clearComplexPropertyBeforeSet if there is no XML configuration found.- Since:
- 9.3
- See Also:
- Constant Field Values
-
deprecatedProperties
@Deprecated(since="11.1") protected Map<String,Map<String,String>> deprecatedProperties
Deprecated.since 11.1, usepropertyCharacteristicsinstead- Since:
- 9.2
-
removedProperties
@Deprecated(since="11.1") protected Map<String,Map<String,String>> removedProperties
Deprecated.since 11.1, usepropertyCharacteristicsinstead- Since:
- 9.2
-
propertyCharacteristics
protected Map<String,Map<String,PropertyDescriptor>> propertyCharacteristics
Map holding property characteristics with: schema -> path -> characteristic.- Since:
- 11.1
-
-
Method Detail
-
clearSchemaDir
protected void clearSchemaDir()
-
getSchemasDir
public File getSchemasDir()
-
registerBuiltinTypes
protected void registerBuiltinTypes()
-
registerType
protected void registerType(Type type)
-
getTypes
protected Collection<Type> getTypes()
-
registerConfiguration
public void registerConfiguration(TypeConfiguration config)
-
unregisterConfiguration
public void unregisterConfiguration(TypeConfiguration config)
-
registerSchema
public void registerSchema(SchemaBindingDescriptor sd)
-
unregisterSchema
public void unregisterSchema(SchemaBindingDescriptor sd)
-
registerFacet
public void registerFacet(FacetDescriptor fd)
-
unregisterFacet
public void unregisterFacet(FacetDescriptor fd)
-
registerDocumentType
public void registerDocumentType(DocumentTypeDescriptor dtd)
-
unregisterDocumentType
public void unregisterDocumentType(DocumentTypeDescriptor dtd)
-
getDocumentTypeDescriptor
public DocumentTypeDescriptor getDocumentTypeDescriptor(String name)
-
getFacetDescriptor
public FacetDescriptor getFacetDescriptor(String name)
-
recomputeDynamicFacets
public void recomputeDynamicFacets()
-
registerProxies
public void registerProxies(ProxiesDescriptor pd)
-
unregisterProxies
public void unregisterProxies(ProxiesDescriptor pd)
-
checkDirty
public void checkDirty()
Checks if something has to be recomputed if a dynamic register/unregister happened.
-
recompute
protected void recompute()
Recomputes effective registries for schemas, facets and document types.
-
recomputeConfiguration
protected void recomputeConfiguration()
-
recomputeSchemas
protected void recomputeSchemas()
-
copySchema
protected void copySchema(SchemaBindingDescriptor sd) throws IOException
- Throws:
IOException
-
loadSchema
protected void loadSchema(SchemaBindingDescriptor sd) throws IOException, SAXException, TypeException
- Throws:
IOExceptionSAXExceptionTypeException
-
registerSchema
protected void registerSchema(Schema schema)
-
getSchemas
public Schema[] getSchemas()
Description copied from interface:TypeProviderGets the list of schemas.- Specified by:
getSchemasin interfaceTypeProvider
-
getSchema
public Schema getSchema(String name)
Description copied from interface:TypeProviderGets a schema.- Specified by:
getSchemain interfaceTypeProvider
-
getSchemaFromPrefix
public Schema getSchemaFromPrefix(String schemaPrefix)
- Specified by:
getSchemaFromPrefixin interfaceSchemaManager
-
getSchemaFromURI
@Deprecated(since="11.1") public Schema getSchemaFromURI(String schemaURI)
Deprecated.since 11.1, seems unused- Specified by:
getSchemaFromURIin interfaceSchemaManager
-
recomputeFacets
protected void recomputeFacets()
-
recomputeFacet
protected void recomputeFacet(FacetDescriptor fd)
-
registerFacet
protected CompositeType registerFacet(String name, Set<String> schemaNames)
-
getFacets
public CompositeType[] getFacets()
Description copied from interface:TypeProviderGets the list of facets.- Specified by:
getFacetsin interfaceTypeProvider
-
getFacet
public CompositeType getFacet(String name)
Description copied from interface:TypeProviderGets a facet.- Specified by:
getFacetin interfaceTypeProvider
-
getNoPerDocumentQueryFacets
public Set<String> getNoPerDocumentQueryFacets()
Description copied from interface:TypeProviderFinds which facets are configured as no-per-instance-query.- Specified by:
getNoPerDocumentQueryFacetsin interfaceTypeProvider
-
recomputeDocumentTypes
protected void recomputeDocumentTypes()
-
mergeDocumentTypeDescriptors
protected DocumentTypeDescriptor mergeDocumentTypeDescriptors(DocumentTypeDescriptor src, DocumentTypeDescriptor dst)
-
recomputeDocumentType
protected DocumentType recomputeDocumentType(String name, Set<String> stack, Map<String,DocumentTypeDescriptor> dtds)
-
recomputeDocumentType
protected DocumentType recomputeDocumentType(String name, DocumentTypeDescriptor dtd, DocumentType parent)
-
registerDocumentType
protected void registerDocumentType(DocumentTypeImpl docType)
-
getDocumentType
public DocumentType getDocumentType(String name)
Description copied from interface:TypeProviderGets a document type.- Specified by:
getDocumentTypein interfaceTypeProvider
-
getDocumentTypeNamesForFacet
public Set<String> getDocumentTypeNamesForFacet(String facet)
Description copied from interface:SchemaManagerReturns the names of all document types that have given facet.- Specified by:
getDocumentTypeNamesForFacetin interfaceSchemaManager- Returns:
- null or the names as a guaranteed non-empty set.
-
getDocumentTypeNamesExtending
public Set<String> getDocumentTypeNamesExtending(String docTypeName)
Description copied from interface:SchemaManagerReturn the names of all document types extending the given one, which is included.- Specified by:
getDocumentTypeNamesExtendingin interfaceSchemaManager- Returns:
- null or the set of names.
-
getDocumentTypes
public DocumentType[] getDocumentTypes()
Description copied from interface:TypeProviderGets the list of document types.- Specified by:
getDocumentTypesin interfaceTypeProvider
-
getDocumentTypesCount
public int getDocumentTypesCount()
- Specified by:
getDocumentTypesCountin interfaceSchemaManager
-
hasSuperType
public boolean hasSuperType(String docType, String superType)
Description copied from interface:SchemaManagerReturns true ifdocTypeis or extendssuperType, false otherwise.- Specified by:
hasSuperTypein interfaceSchemaManager
-
getAllowedSubTypes
public Set<String> getAllowedSubTypes(String typeName)
Description copied from interface:SchemaManagerReturns the types of the children that can be created inside a giventypetype.- Specified by:
getAllowedSubTypesin interfaceSchemaManager
-
recomputeProxies
protected void recomputeProxies()
-
getProxySchemas
public List<Schema> getProxySchemas(String docType)
Description copied from interface:TypeProviderGets the schemas on a proxy for a document of the given type.- Specified by:
getProxySchemasin interfaceTypeProvider
-
isProxySchema
public boolean isProxySchema(String schema, String docType)
Description copied from interface:TypeProviderChecks if a schema is on a proxy for a document of the given type.- Specified by:
isProxySchemain interfaceTypeProvider
-
getField
public Field getField(String xpath)
Description copied from interface:SchemaManagerReturns the field with given xpath, or null if not found.- Specified by:
getFieldin interfaceSchemaManager
-
getField
public Field getField(Field parent, String subFieldName)
Description copied from interface:SchemaManagerReturns the field with given parent field and sub name, or null if not found.- Specified by:
getFieldin interfaceSchemaManager
-
resolveSubField
protected Field resolveSubField(ListType listType, String subName, boolean fallbackOnSubElement)
-
flushPendingsRegistration
public void flushPendingsRegistration()
-
registerRecomputeCallback
public void registerRecomputeCallback(Runnable callback)
- Since:
- 8.10
-
unregisterRecomputeCallback
public void unregisterRecomputeCallback(Runnable callback)
- Since:
- 8.10
-
executeRecomputeCallbacks
protected void executeRecomputeCallbacks()
- Since:
- 8.10
-
getDeprecatedProperties
@Deprecated(since="11.1") public PropertyDeprecationHandler getDeprecatedProperties()
Deprecated.since 11.1, usePropertyCharacteristicHandlermethods instead- Specified by:
getDeprecatedPropertiesin interfaceSchemaManager- Returns:
- the deprecated properties handler
- Since:
- 9.2
-
getRemovedProperties
@Deprecated(since="11.1") public PropertyDeprecationHandler getRemovedProperties()
Deprecated.since 11.1, usePropertyCharacteristicHandlermethods instead- Specified by:
getRemovedPropertiesin interfaceSchemaManager- Returns:
- the removed properties handler
- Since:
- 9.2
-
getClearComplexPropertyBeforeSet
public boolean getClearComplexPropertyBeforeSet()
Description copied from interface:SchemaManagerWhether or not to ignore any previous values when setting complex properties.- Specified by:
getClearComplexPropertyBeforeSetin interfaceSchemaManager- Returns:
trueif setting a complex property ignores any previous values
-
getAllowVersionWriteForDublinCore
public boolean getAllowVersionWriteForDublinCore()
Description copied from interface:SchemaManagerWhether we allow to write the dublincore schema on a version.- Specified by:
getAllowVersionWriteForDublinCorein interfaceSchemaManager- Returns:
trueif write to the dublincore schema of a version is allowed
-
registerPropertyCharacteristics
protected void registerPropertyCharacteristics(List<PropertyDescriptor> descriptors)
- Since:
- 11.1
-
clearPropertyCharacteristics
protected void clearPropertyCharacteristics()
- Since:
- 11.1
-
isSecured
public boolean isSecured(String schema, String path)
Description copied from interface:PropertyCharacteristicHandlerChecks if the property represented by the givenschemaandpathis secured.- Specified by:
isSecuredin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema namepath- the property path to test- Returns:
- whether or not the given property is secured (ie: only administrators can edit it)
- Since:
- 11.1
-
isDeprecated
public boolean isDeprecated(String schema, String path)
Description copied from interface:PropertyCharacteristicHandlerChecks if the property represented by the givenschemaandpathis deprecated.- Specified by:
isDeprecatedin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)path- the property path to test- Returns:
- whether or not this property is marked as deprecated
-
isRemoved
public boolean isRemoved(String schema, String path)
Description copied from interface:PropertyCharacteristicHandlerChecks if the property represented by the givenschemaandpathis removed.- Specified by:
isRemovedin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)path- the property path to test- Returns:
- whether or not this property is marked as removed
-
getXPathSchemaName
public String getXPathSchemaName(String xpath, Set<String> docSchemas)
Description copied from interface:SchemaManagerFinds within the schemas the first matching schema having a property with the same name as the first path segment of the xpath. The xpath can be prefixed or unprefixed.- Specified by:
getXPathSchemaNamein interfaceSchemaManager- Parameters:
xpath- the prefixed or unprefixed xpathdocSchemas- the schemas to be searched- Returns:
- the first schema containing a property matching the xpath
-
getDeprecatedProperties
public Set<String> getDeprecatedProperties(String schema)
Description copied from interface:PropertyCharacteristicHandlerThe returned paths are not Nuxeo xpath as they don't have the schema prefix.- Specified by:
getDeprecatedPropertiesin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)- Returns:
- a
Setholding the deprecated property path
-
getRemovedProperties
public Set<String> getRemovedProperties(String schema)
Description copied from interface:PropertyCharacteristicHandlerThe returned paths are not Nuxeo xpath as they don't have the schema prefix.- Specified by:
getRemovedPropertiesin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)- Returns:
- a
Setholding the removed property path
-
getRetainableProperties
public Set<String> getRetainableProperties()
Description copied from interface:PropertyCharacteristicHandlerThe returned paths are not Nuxeo xpath as they don't have the schema prefix.- Specified by:
getRetainablePropertiesin interfacePropertyCharacteristicHandler- Returns:
- a
Setholding the retainable property path - Since:
- 2023
-
getRetainableProperties
public Set<String> getRetainableProperties(String schema)
Description copied from interface:PropertyCharacteristicHandlerThe returned paths are not Nuxeo xpath as they don't have the schema prefix.- Specified by:
getRetainablePropertiesin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)- Returns:
- a
Setholding the retainable property path - Since:
- 2023
-
getPropertyCharacteristics
protected <R> Set<R> getPropertyCharacteristics(String schema, Predicate<PropertyDescriptor> predicate, Function<PropertyDescriptor,R> function)
-
getFallback
public Optional<String> getFallback(String schema, String path)
Description copied from interface:PropertyCharacteristicHandlerReturns the fallback associated to this property if exist. Fallbacks exist when property is deprecated or removed.- Specified by:
getFallbackin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)path- the property path to test- Returns:
- fallback associated to this property if exist
-
getIndexedProperties
public List<PropertyIndexOrder> getIndexedProperties(String schema)
Description copied from interface:PropertyCharacteristicHandlerReturns the indexed property paths.The returned paths are not Nuxeo xpath as they don't have the schema prefix.
- Specified by:
getIndexedPropertiesin interfacePropertyCharacteristicHandler- Parameters:
schema- the schema name (not the prefix)- Returns:
- a
Listholding the indexed property paths.
-
checkPropertyCharacteristic
protected boolean checkPropertyCharacteristic(String schema, String path, Predicate<PropertyDescriptor> predicate)
-
cleanPath
protected String cleanPath(String path)
Deprecated.since 2021.32 useSchemaManager.normalizePath(String)instead.
-
getSpecialDocumentTypes
public Set<String> getSpecialDocumentTypes()
Description copied from interface:TypeProviderGets the list of document types excluded from copy.- Specified by:
getSpecialDocumentTypesin interfaceTypeProvider
-
-