public class NodeTypeRegistry extends Object implements NodeTypeEventListener
NodeTypeRegistry
...Modifier and Type | Field and Description |
---|---|
static boolean |
disableCheckForReferencesInContentException
Feature flag for the unfortunate behavior in Jackrabbit 2.1 and 2.2
where the exception from
checkForReferencesInContent(Name)
was never thrown because of a mistaken commit for
JCR-2587. |
Constructor and Description |
---|
NodeTypeRegistry(NamespaceRegistry nsReg,
FileSystem fs)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(NodeTypeRegistryListener listener)
Add a
NodeTypeRegistryListener |
protected void |
checkForConflictingContent(QNodeTypeDefinition ntd,
NodeTypeDefDiff diff)
Checks whether there is existing content that would conflict with the
given node type definition.
|
protected void |
checkForReferencesInContent(Name nodeTypeName)
Checks whether there is existing content that directly or indirectly
refers to the specified node type.
|
void |
externalRegistered(Collection<QNodeTypeDefinition> ntDefs)
Called when one or more node types have been externally registered.
|
void |
externalReregistered(QNodeTypeDefinition ntDef)
Called when a node type has been externally re-registered.
|
void |
externalUnregistered(Collection<Name> ntNames)
Called when one or more node types have been externally unregistered.
|
Set<Name> |
getDependentNodeTypes(Name nodeTypeName)
Returns the names of those registered node types that have
dependencies on the given node type.
|
EffectiveNodeType |
getEffectiveNodeType(Name ntName) |
EffectiveNodeType |
getEffectiveNodeType(Name primary,
Set<Name> mixins)
Returns the effective node type of a node with the given primary
and mixin types.
|
EffectiveNodeType |
getEffectiveNodeType(Set<Name> mixins)
Returns the effective node type representation of the given node types.
|
QNodeTypeDefinition |
getNodeTypeDef(Name nodeTypeName)
Returns the node type definition of the node type with the given name.
|
Name[] |
getRegisteredNodeTypes()
Returns the names of all registered node types.
|
QNodeDefinition |
getRootNodeDef() |
boolean |
isBuiltIn(Name nodeTypeName) |
boolean |
isRegistered(Name nodeTypeName) |
protected void |
loadBuiltInNodeTypeDefs(NodeTypeDefStore store)
Loads the built-in node type definitions into the given
store . |
protected void |
loadCustomNodeTypeDefs(NodeTypeDefStore store)
Loads the custom node type definitions into the given
store . |
protected void |
persistCustomNodeTypeDefs(NodeTypeDefStore store)
Persists the custom node type definitions contained in the given
store . |
EffectiveNodeType |
registerNodeType(QNodeTypeDefinition ntd)
Validates the
NodeTypeDef and returns
an EffectiveNodeType object representing the newly
registered node type. |
void |
registerNodeTypes(Collection<QNodeTypeDefinition> ntDefs)
Same as
except
that a collection of NodeTypeDef s is registered instead of
just one. |
void |
removeListener(NodeTypeRegistryListener listener)
Remove a
NodeTypeRegistryListener |
EffectiveNodeType |
reregisterNodeType(QNodeTypeDefinition ntd)
Reregister a node type.
|
void |
setEventChannel(NodeTypeEventChannel eventChannel)
Set an event channel to inform about changes.
|
String |
toString() |
void |
unregisterNodeType(Name ntName)
Unregisters the specified node type.
|
void |
unregisterNodeTypes(Set<Name> ntNames)
Same as
except
that a set of node types is unregistered instead of just one. |
public static volatile boolean disableCheckForReferencesInContentException
checkForReferencesInContent(Name)
was never thrown because of a mistaken commit for
JCR-2587.
Setting this flag to true
(the default value comes from
the "disableCheckForReferencesInContentException" system property)
will disable the exception thrown by default by the method.public NodeTypeRegistry(NamespaceRegistry nsReg, FileSystem fs) throws RepositoryException
nsReg
- name space registryfs
- repository file systemRepositoryException
- if an error occurspublic Name[] getRegisteredNodeTypes()
public EffectiveNodeType registerNodeType(QNodeTypeDefinition ntd) throws InvalidNodeTypeDefException, RepositoryException
NodeTypeDef
and returns
an EffectiveNodeType
object representing the newly
registered node type.
The validation includes the following checks:
ntd
- the definition of the new node typeEffectiveNodeType
instanceInvalidNodeTypeDefException
- if the given node type definition is invalid.RepositoryException
- if a repository error occurs.public void registerNodeTypes(Collection<QNodeTypeDefinition> ntDefs) throws InvalidNodeTypeDefException, RepositoryException
registerNodeType(QNodeTypeDefinition)
except
that a collection of NodeTypeDef
s is registered instead of
just one.
This method can be used to register a set of node types that have dependencies on each other.
ntDefs
- a collection of QNodeTypeDefinition
objectsInvalidNodeTypeDefException
- if the given node type definition is invalid.RepositoryException
- if a repository error occurs.public void unregisterNodeTypes(Set<Name> ntNames) throws NoSuchNodeTypeException, RepositoryException
unregisterNodeType(Name)
except
that a set of node types is unregistered instead of just one.
This method can be used to unregister a set of node types that depend on each other.
ntNames
- a collection of Name
objects denoting the
node types to be unregisteredNoSuchNodeTypeException
- if any of the specified names does not
denote a registered node type.RepositoryException
- if another error occursunregisterNodeType(Name)
public void unregisterNodeType(Name ntName) throws NoSuchNodeTypeException, RepositoryException
ntName
- name of the node type to be unregisteredNoSuchNodeTypeException
- if ntName
does not
denote a registered node type.RepositoryException
- if another error occurs.unregisterNodeTypes(Collection, boolean)
public EffectiveNodeType reregisterNodeType(QNodeTypeDefinition ntd) throws NoSuchNodeTypeException, InvalidNodeTypeDefException, RepositoryException
ntd
- node type definitionNoSuchNodeTypeException
- if ntd
refers to an
unknown node typeInvalidNodeTypeDefException
- if the node type definition
is invalidRepositoryException
- if another error occurspublic EffectiveNodeType getEffectiveNodeType(Name ntName) throws NoSuchNodeTypeException
ntName
- nameNoSuchNodeTypeException
- if node type does not existpublic EffectiveNodeType getEffectiveNodeType(Name primary, Set<Name> mixins) throws NodeTypeConflictException, NoSuchNodeTypeException
primary
- primary type of the nodemixins
- mixin types of the node (set of names
);NodeTypeConflictException
- if the given types are conflictingNoSuchNodeTypeException
- if one of the given types is not foundpublic EffectiveNodeType getEffectiveNodeType(Set<Name> mixins) throws NodeTypeConflictException, NoSuchNodeTypeException
mixins
- mixin types of the node (set of names
);NodeTypeConflictException
- if the given types are conflictingNoSuchNodeTypeException
- if one of the given types is not foundpublic Set<Name> getDependentNodeTypes(Name nodeTypeName) throws NoSuchNodeTypeException
nodeTypeName
- node type nameName
sNoSuchNodeTypeException
- if node type does not existpublic QNodeTypeDefinition getNodeTypeDef(Name nodeTypeName) throws NoSuchNodeTypeException
nodeTypeName
- name of node type whose definition should be returned.NoSuchNodeTypeException
- if a node type with the given name
does not existpublic boolean isRegistered(Name nodeTypeName)
nodeTypeName
- node type nametrue
if the specified node type is registered;
false
otherwise.public boolean isBuiltIn(Name nodeTypeName)
nodeTypeName
- node type nametrue
if the specified node type is built-in;
false
otherwise.public void addListener(NodeTypeRegistryListener listener)
NodeTypeRegistryListener
listener
- the new listener to be informed on (un)registration
of node typespublic void removeListener(NodeTypeRegistryListener listener)
NodeTypeRegistryListener
listener
- an existing listenerpublic void externalRegistered(Collection<QNodeTypeDefinition> ntDefs) throws RepositoryException, InvalidNodeTypeDefException
externalRegistered
in interface NodeTypeEventListener
ntDefs
- node type definitionsRepositoryException
- if an error occursInvalidNodeTypeDefException
- if the node type definition is invalidpublic void externalReregistered(QNodeTypeDefinition ntDef) throws NoSuchNodeTypeException, InvalidNodeTypeDefException, RepositoryException
externalReregistered
in interface NodeTypeEventListener
ntDef
- node type definitionNoSuchNodeTypeException
- if the node type had not yet been registeredInvalidNodeTypeDefException
- if the node type definition is invalidRepositoryException
- if an error occurspublic void externalUnregistered(Collection<Name> ntNames) throws RepositoryException, NoSuchNodeTypeException
externalUnregistered
in interface NodeTypeEventListener
ntNames
- node type qnamesRepositoryException
- if an error occursNoSuchNodeTypeException
- if a node type is already unregisteredprotected void loadBuiltInNodeTypeDefs(NodeTypeDefStore store) throws RepositoryException
store
.
This method may be overridden by extensions of this class; It must only be called once and only from within the constructor though.
store
- The NodeTypeDefStore
into which the node type
definitions are loaded.RepositoryException
- If an error occurs while loading the
built-in node type definitions.protected void loadCustomNodeTypeDefs(NodeTypeDefStore store) throws RepositoryException
store
.
This method may be overridden by extensions of this class; It must only be called once and only from within the constructor though.
store
- The NodeTypeDefStore
into which the node type
definitions are loaded.RepositoryException
- If an error occurs while loading the
custom node type definitions.protected void persistCustomNodeTypeDefs(NodeTypeDefStore store) throws RepositoryException
store
.store
- The NodeTypeDefStore
containing the definitions to
be persisted.RepositoryException
- If an error occurs while persisting the
custom node type definitions.protected void checkForConflictingContent(QNodeTypeDefinition ntd, NodeTypeDefDiff diff) throws RepositoryException
This method is not implemented yet and always throws a
RepositoryException
.
TODO
the above checks/actions are absolutely necessary in order to guarantee integrity of repository content.
ntd
- The node type definition replacing the former node type
definition of the same name.diff
- RepositoryException
- If there is conflicting content or if the
check failed for some other reason.protected void checkForReferencesInContent(Name nodeTypeName) throws RepositoryException
This method is not implemented yet and always throws a
RepositoryException
.
TODO:
the above checks are absolutely necessary in order to guarantee integrity of repository content.
nodeTypeName
- The name of the node type to be checked.RepositoryException
- If the specified node type is currently
being referenced or if the check failed for
some other reason.public QNodeDefinition getRootNodeDef()
public void setEventChannel(NodeTypeEventChannel eventChannel)
eventChannel
- event channelCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.