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>
allConfigurations
All the registered configurations (prefetch).protected List<DocumentTypeDescriptor>
allDocumentTypes
All the registered document types.protected List<FacetDescriptor>
allFacets
All the registered facets.protected boolean
allowVersionWriteForDublinCore
Effective allowVersionWriteForDublinCore flag.protected List<ProxiesDescriptor>
allProxies
All the registered proxy descriptors.protected List<SchemaBindingDescriptor>
allSchemas
All the registered schemas.static boolean
CLEAR_COMPLEX_PROP_BEFORE_SET_DEFAULT
Default used for clearComplexPropertyBeforeSet if there is no XML configuration found.boolean
clearComplexPropertyBeforeSet
Effective clearComplexPropertyBeforeSet flag.protected Map<String,Map<String,String>>
deprecatedProperties
Deprecated.since 11.1, usepropertyCharacteristics
insteadprotected boolean
dirty
Whether there have been changes to the registered schemas, facets or document types that require recomputation of the effective ones.protected Set<String>
disabledFacets
protected Set<String>
disabledSchemas
protected Map<String,DocumentTypeImpl>
documentTypes
Effective document types.protected Map<String,Set<String>>
documentTypesExtending
protected Map<String,Set<String>>
documentTypesForFacet
Map<String,CompositeType>
facets
Effective facets.protected Set<String>
noPerDocumentQueryFacets
protected PrefetchInfo
prefetchInfo
Effective prefetch info.protected Map<String,Schema>
prefixToSchema
protected Map<String,Map<String,PropertyDescriptor>>
propertyCharacteristics
Map holding property characteristics with: schema -> path -> characteristic.protected Set<String>
proxySchemaNames
Effective proxy schema names.protected List<Schema>
proxySchemas
Effective proxy schemas.protected List<Runnable>
recomputeCallbacks
protected Map<String,Map<String,String>>
removedProperties
Deprecated.since 11.1, usepropertyCharacteristics
insteadprotected Map<String,Schema>
schemas
Effective schemas.static String
SCHEMAS_DIR_NAME
protected Set<String>
specialDocumentTypes
protected Map<String,Type>
types
Basic type registry.
-
Constructor Summary
Constructors Constructor Description SchemaManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
checkDirty()
Checks if something has to be recomputed if a dynamic register/unregister happened.protected boolean
checkPropertyCharacteristic(String schema, String path, Predicate<PropertyDescriptor> predicate)
protected String
cleanPath(String path)
protected void
clearPropertyCharacteristics()
protected void
clearSchemaDir()
protected void
copySchema(SchemaBindingDescriptor sd)
protected void
executeRecomputeCallbacks()
void
flushPendingsRegistration()
Set<String>
getAllowedSubTypes(String typeName)
Returns the types of the children that can be created inside a giventype
type.boolean
getAllowVersionWriteForDublinCore()
Whether we allow to write the dublincore schema on a version.boolean
getClearComplexPropertyBeforeSet()
Whether or not to ignore any previous values when setting complex properties.PropertyDeprecationHandler
getDeprecatedProperties()
Deprecated.since 11.1, usePropertyCharacteristicHandler
methods insteadSet<String>
getDeprecatedProperties(String schema)
The returned path are not Nuxeo xpath as they don't have the schema prefix.DocumentType
getDocumentType(String name)
Gets a document type.DocumentTypeDescriptor
getDocumentTypeDescriptor(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.int
getDocumentTypesCount()
CompositeType
getFacet(String name)
Gets a facet.FacetDescriptor
getFacetDescriptor(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.Field
getField(String xpath)
Returns the field with given xpath, or null if not found.Field
getField(Field parent, String subFieldName)
Returns the field with given parent field and sub name, or null if not found.protected Field
getField(Field parent, String subFieldName, boolean finalCall)
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.PropertyDeprecationHandler
getRemovedProperties()
Deprecated.since 11.1, usePropertyCharacteristicHandler
methods insteadSet<String>
getRemovedProperties(String schema)
The returned path are not Nuxeo xpath as they don't have the schema prefix.Schema
getSchema(String name)
Gets a schema.Schema
getSchemaFromPrefix(String schemaPrefix)
Schema
getSchemaFromURI(String schemaURI)
Deprecated.since 11.1, seems unusedSchema[]
getSchemas()
Gets the list of schemas.File
getSchemasDir()
Set<String>
getSpecialDocumentTypes()
Gets the list of document types excluded from copy.protected Type
getType(String name)
protected Collection<Type>
getTypes()
boolean
hasSuperType(String docType, String superType)
Returns true ifdocType
is or extendssuperType
, false otherwise.boolean
isDeprecated(String schema, String path)
Checks if the property represented by the givenschema
andpath
is deprecated.boolean
isProxySchema(String schema, String docType)
Checks if a schema is on a proxy for a document of the given type.boolean
isRemoved(String schema, String path)
Checks if the property represented by the givenschema
andpath
is removed.boolean
isSecured(String schema, String path)
Checks if the property represented by the givenschema
andpath
is secured.protected void
loadSchema(SchemaBindingDescriptor sd)
protected DocumentTypeDescriptor
mergeDocumentTypeDescriptors(DocumentTypeDescriptor src, DocumentTypeDescriptor dst)
protected void
recompute()
Recomputes effective registries for schemas, facets and document types.protected void
recomputeConfiguration()
protected DocumentType
recomputeDocumentType(String name, Set<String> stack, Map<String,DocumentTypeDescriptor> dtds)
protected DocumentType
recomputeDocumentType(String name, DocumentTypeDescriptor dtd, DocumentType parent)
protected void
recomputeDocumentTypes()
void
recomputeDynamicFacets()
protected void
recomputeFacet(FacetDescriptor fd)
protected void
recomputeFacets()
protected void
recomputeProxies()
protected void
recomputeSchemas()
protected void
registerBuiltinTypes()
void
registerConfiguration(TypeConfiguration config)
void
registerDocumentType(DocumentTypeDescriptor dtd)
protected void
registerDocumentType(DocumentTypeImpl docType)
protected CompositeType
registerFacet(String name, Set<String> schemaNames)
void
registerFacet(FacetDescriptor fd)
protected void
registerPropertyCharacteristics(List<PropertyDescriptor> descriptors)
void
registerProxies(ProxiesDescriptor pd)
void
registerRecomputeCallback(Runnable callback)
void
registerSchema(SchemaBindingDescriptor sd)
protected void
registerSchema(Schema schema)
protected void
registerType(Type type)
protected Field
resolveSubField(ListType listType, String subName, boolean fallbackOnSubElement)
void
unregisterConfiguration(TypeConfiguration config)
void
unregisterDocumentType(DocumentTypeDescriptor dtd)
void
unregisterFacet(FacetDescriptor fd)
void
unregisterProxies(ProxiesDescriptor pd)
void
unregisterRecomputeCallback(Runnable callback)
void
unregisterSchema(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.
-
disabledSchemas
protected Set<String> disabledSchemas
-
prefixToSchema
protected final Map<String,Schema> prefixToSchema
-
facets
public Map<String,CompositeType> facets
Effective facets.
-
noPerDocumentQueryFacets
protected Set<String> noPerDocumentQueryFacets
-
disabledFacets
protected Set<String> disabledFacets
-
documentTypes
protected Map<String,DocumentTypeImpl> documentTypes
Effective document types.
-
specialDocumentTypes
protected Set<String> specialDocumentTypes
-
documentTypesExtending
protected Map<String,Set<String>> documentTypesExtending
-
documentTypesForFacet
protected Map<String,Set<String>> documentTypesForFacet
-
proxySchemas
protected List<Schema> proxySchemas
Effective proxy schemas.
-
proxySchemaNames
protected Set<String> proxySchemaNames
Effective proxy schema names.
-
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
-
recomputeCallbacks
protected List<Runnable> recomputeCallbacks
-
deprecatedProperties
@Deprecated(since="11.1") protected Map<String,Map<String,String>> deprecatedProperties
Deprecated.since 11.1, usepropertyCharacteristics
instead- Since:
- 9.2
-
removedProperties
@Deprecated(since="11.1") protected Map<String,Map<String,String>> removedProperties
Deprecated.since 11.1, usepropertyCharacteristics
instead- Since:
- 9.2
-
propertyCharacteristics
protected Map<String,Map<String,PropertyDescriptor>> propertyCharacteristics
Map holding property characteristics with: schema -> path -> characteristic.- Since:
- 11.1
-
-
Constructor Detail
-
SchemaManagerImpl
public SchemaManagerImpl()
-
-
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:
IOException
SAXException
TypeException
-
registerSchema
protected void registerSchema(Schema schema)
-
getSchemas
public Schema[] getSchemas()
Description copied from interface:TypeProvider
Gets the list of schemas.- Specified by:
getSchemas
in interfaceTypeProvider
-
getSchema
public Schema getSchema(String name)
Description copied from interface:TypeProvider
Gets a schema.- Specified by:
getSchema
in interfaceTypeProvider
-
getSchemaFromPrefix
public Schema getSchemaFromPrefix(String schemaPrefix)
- Specified by:
getSchemaFromPrefix
in interfaceSchemaManager
-
getSchemaFromURI
@Deprecated(since="11.1") public Schema getSchemaFromURI(String schemaURI)
Deprecated.since 11.1, seems unused- Specified by:
getSchemaFromURI
in 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:TypeProvider
Gets the list of facets.- Specified by:
getFacets
in interfaceTypeProvider
-
getFacet
public CompositeType getFacet(String name)
Description copied from interface:TypeProvider
Gets a facet.- Specified by:
getFacet
in interfaceTypeProvider
-
getNoPerDocumentQueryFacets
public Set<String> getNoPerDocumentQueryFacets()
Description copied from interface:TypeProvider
Finds which facets are configured as no-per-instance-query.- Specified by:
getNoPerDocumentQueryFacets
in 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:TypeProvider
Gets a document type.- Specified by:
getDocumentType
in interfaceTypeProvider
-
getDocumentTypeNamesForFacet
public Set<String> getDocumentTypeNamesForFacet(String facet)
Description copied from interface:SchemaManager
Returns the names of all document types that have given facet.- Specified by:
getDocumentTypeNamesForFacet
in interfaceSchemaManager
- Returns:
- null or the names as a guaranteed non-empty set.
-
getDocumentTypeNamesExtending
public Set<String> getDocumentTypeNamesExtending(String docTypeName)
Description copied from interface:SchemaManager
Return the names of all document types extending the given one, which is included.- Specified by:
getDocumentTypeNamesExtending
in interfaceSchemaManager
- Returns:
- null or the set of names.
-
getDocumentTypes
public DocumentType[] getDocumentTypes()
Description copied from interface:TypeProvider
Gets the list of document types.- Specified by:
getDocumentTypes
in interfaceTypeProvider
-
getDocumentTypesCount
public int getDocumentTypesCount()
- Specified by:
getDocumentTypesCount
in interfaceSchemaManager
-
hasSuperType
public boolean hasSuperType(String docType, String superType)
Description copied from interface:SchemaManager
Returns true ifdocType
is or extendssuperType
, false otherwise.- Specified by:
hasSuperType
in interfaceSchemaManager
-
getAllowedSubTypes
public Set<String> getAllowedSubTypes(String typeName)
Description copied from interface:SchemaManager
Returns the types of the children that can be created inside a giventype
type.- Specified by:
getAllowedSubTypes
in interfaceSchemaManager
-
recomputeProxies
protected void recomputeProxies()
-
getProxySchemas
public List<Schema> getProxySchemas(String docType)
Description copied from interface:TypeProvider
Gets the schemas on a proxy for a document of the given type.- Specified by:
getProxySchemas
in interfaceTypeProvider
-
isProxySchema
public boolean isProxySchema(String schema, String docType)
Description copied from interface:TypeProvider
Checks if a schema is on a proxy for a document of the given type.- Specified by:
isProxySchema
in interfaceTypeProvider
-
getField
public Field getField(String xpath)
Description copied from interface:SchemaManager
Returns the field with given xpath, or null if not found.- Specified by:
getField
in interfaceSchemaManager
-
getField
public Field getField(Field parent, String subFieldName)
Description copied from interface:SchemaManager
Returns the field with given parent field and sub name, or null if not found.- Specified by:
getField
in 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, usePropertyCharacteristicHandler
methods instead- Specified by:
getDeprecatedProperties
in interfaceSchemaManager
- Returns:
- the deprecated properties handler
- Since:
- 9.2
-
getRemovedProperties
@Deprecated(since="11.1") public PropertyDeprecationHandler getRemovedProperties()
Deprecated.since 11.1, usePropertyCharacteristicHandler
methods instead- Specified by:
getRemovedProperties
in interfaceSchemaManager
- Returns:
- the removed properties handler
- Since:
- 9.2
-
getClearComplexPropertyBeforeSet
public boolean getClearComplexPropertyBeforeSet()
Description copied from interface:SchemaManager
Whether or not to ignore any previous values when setting complex properties.- Specified by:
getClearComplexPropertyBeforeSet
in interfaceSchemaManager
- Returns:
true
if setting a complex property ignores any previous values
-
getAllowVersionWriteForDublinCore
public boolean getAllowVersionWriteForDublinCore()
Description copied from interface:SchemaManager
Whether we allow to write the dublincore schema on a version.- Specified by:
getAllowVersionWriteForDublinCore
in interfaceSchemaManager
- Returns:
true
if 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:PropertyCharacteristicHandler
Checks if the property represented by the givenschema
andpath
is secured.- Specified by:
isSecured
in 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:PropertyCharacteristicHandler
Checks if the property represented by the givenschema
andpath
is deprecated.- Specified by:
isDeprecated
in 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:PropertyCharacteristicHandler
Checks if the property represented by the givenschema
andpath
is removed.- Specified by:
isRemoved
in 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
-
getDeprecatedProperties
public Set<String> getDeprecatedProperties(String schema)
Description copied from interface:PropertyCharacteristicHandler
The returned path are not Nuxeo xpath as they don't have the schema prefix.- Specified by:
getDeprecatedProperties
in interfacePropertyCharacteristicHandler
- Parameters:
schema
- the schema name (not the prefix)- Returns:
- a
Set
holding the deprecated property path
-
getRemovedProperties
public Set<String> getRemovedProperties(String schema)
Description copied from interface:PropertyCharacteristicHandler
The returned path are not Nuxeo xpath as they don't have the schema prefix.- Specified by:
getRemovedProperties
in interfacePropertyCharacteristicHandler
- Parameters:
schema
- the schema name (not the prefix)- Returns:
- a
Set
holding the removed property path
-
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:PropertyCharacteristicHandler
Returns the fallback associated to this property if exist. Fallbacks exist when property is deprecated or removed.- Specified by:
getFallback
in interfacePropertyCharacteristicHandler
- Parameters:
schema
- the schema name (not the prefix)path
- the property path to test- Returns:
- fallback associated to this property if exist
-
checkPropertyCharacteristic
protected boolean checkPropertyCharacteristic(String schema, String path, Predicate<PropertyDescriptor> predicate)
-
getSpecialDocumentTypes
public Set<String> getSpecialDocumentTypes()
Description copied from interface:TypeProvider
Gets the list of document types excluded from copy.- Specified by:
getSpecialDocumentTypes
in interfaceTypeProvider
-
-