@Immutable public class JcrNodeTypeManager extends Object implements NodeTypeManager
Name
s and String
s based
on the namespace registry from the session's execution context in order to support transient namespace remappings. All
NodeType
s returned by this implementation are wrapped with the execution context of the session to allow proper ongoing
handling of names. This implies that reference equality is not a safe test for node type equivalence.RepositoryNodeTypeManager
Modifier and Type | Method and Description |
---|---|
javax.jcr.nodetype.NodeDefinitionTemplate |
createNodeDefinitionTemplate()
Returns an empty
PropertyDefinitionTemplate which can then be used to create a property definition and attached to
a NodeTypeTemplate . |
javax.jcr.nodetype.NodeTypeTemplate |
createNodeTypeTemplate()
Returns an empty
NodeTypeTemplate which can then be used to define a node type and passed to
registerNodeType(NodeTypeDefinition, boolean) |
javax.jcr.nodetype.NodeTypeTemplate |
createNodeTypeTemplate(javax.jcr.nodetype.NodeTypeDefinition ntd)
Returns a
NodeTypeTemplate based on the definition given in ntd . |
javax.jcr.nodetype.PropertyDefinitionTemplate |
createPropertyDefinitionTemplate()
Returns an empty
PropertyDefinitionTemplate which can then be used to create a property definition and attached to
a NodeTypeTemplate . |
javax.jcr.nodetype.NodeTypeIterator |
getAllNodeTypes() |
javax.jcr.nodetype.NodeTypeIterator |
getMixinNodeTypes() |
org.modeshape.jcr.JcrNodeType |
getNodeType(String nodeTypeName) |
javax.jcr.nodetype.NodeTypeIterator |
getPrimaryNodeTypes() |
boolean |
hasNodeType(String nodeTypeName)
Returns true if and only if the node type with the given name exists.
|
protected List<javax.jcr.nodetype.NodeTypeDefinition> |
importFromXml(InputSource source) |
boolean |
isDerivedFrom(String[] testTypeNames,
String primaryTypeName,
String[] mixinNames)
Determine if any of the test type names are equal to or have been derived from the primary type or any of the mixins.
|
protected String |
messageFrom(Problems problems) |
javax.jcr.nodetype.NodeType |
registerNodeType(javax.jcr.nodetype.NodeTypeDefinition template,
boolean allowUpdate)
Registers a new node type or updates an existing node type using the specified definition and returns the resulting
NodeType object. |
javax.jcr.nodetype.NodeTypeIterator |
registerNodeTypes(Collection<javax.jcr.nodetype.NodeTypeDefinition> templates,
boolean allowUpdates)
Registers or updates the specified Collection of
NodeTypeDefinition objects. |
javax.jcr.nodetype.NodeTypeIterator |
registerNodeTypes(File file,
boolean allowUpdate)
Registers or updates the node type definitions per the Compact Node Definition
(CND) file given by the supplied file.
|
javax.jcr.nodetype.NodeTypeIterator |
registerNodeTypes(InputStream stream,
boolean allowUpdate)
Registers or updates the node type definitions per the Compact Node Definition
(CND) file given by the supplied stream.
|
javax.jcr.nodetype.NodeTypeIterator |
registerNodeTypes(Iterable<javax.jcr.nodetype.NodeTypeDefinition> nodeTypes)
Registers the node types from the given
JcrNodeTypeSource . |
javax.jcr.nodetype.NodeTypeIterator |
registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[] ntds,
boolean allowUpdate)
Registers or updates the specified array of
NodeTypeDefinition objects. |
javax.jcr.nodetype.NodeTypeIterator |
registerNodeTypes(URL url,
boolean allowUpdate)
Registers or updates the node type definitions per the Compact Node Definition
(CND) file given by the supplied URL.
|
void |
unregisterNodeType(String nodeTypeName)
Unregisters the named node type if it is not referenced by other node types as a supertype, a default primary type of a
child node (or nodes), or a required primary type of a child node (or nodes).
|
void |
unregisterNodeTypes(Collection<String> nodeTypeNames)
Allows the collection of node types to be unregistered if they are not referenced by other node types as supertypes,
default primary types of child nodes, or required primary types of child nodes.
|
void |
unregisterNodeTypes(String[] names)
Allows the collection of node types to be unregistered if they are not referenced by other node types as supertypes,
default primary types of child nodes, or required primary types of child nodes.
|
public javax.jcr.nodetype.NodeTypeIterator getAllNodeTypes() throws javax.jcr.RepositoryException
getAllNodeTypes
in interface javax.jcr.nodetype.NodeTypeManager
javax.jcr.RepositoryException
public javax.jcr.nodetype.NodeTypeIterator getMixinNodeTypes() throws javax.jcr.RepositoryException
getMixinNodeTypes
in interface javax.jcr.nodetype.NodeTypeManager
javax.jcr.RepositoryException
public org.modeshape.jcr.JcrNodeType getNodeType(String nodeTypeName) throws javax.jcr.nodetype.NoSuchNodeTypeException, javax.jcr.RepositoryException
getNodeType
in interface javax.jcr.nodetype.NodeTypeManager
javax.jcr.nodetype.NoSuchNodeTypeException
javax.jcr.RepositoryException
public boolean hasNodeType(String nodeTypeName)
This is equivalent to the following code:
try { getNodeType(nodeTypeName); return true; } catch (NoSuchNodeTypeException nsnte) { return false; }However, the implementation is more efficient that the approach listed above and does not rely upon exceptions.
hasNodeType
in interface javax.jcr.nodetype.NodeTypeManager
nodeTypeName
- the name of the node typeNodeTypes.hasNodeType(Name)
public javax.jcr.nodetype.NodeTypeIterator getPrimaryNodeTypes() throws javax.jcr.RepositoryException
getPrimaryNodeTypes
in interface javax.jcr.nodetype.NodeTypeManager
javax.jcr.RepositoryException
public javax.jcr.nodetype.NodeType registerNodeType(javax.jcr.nodetype.NodeTypeDefinition template, boolean allowUpdate) throws javax.jcr.nodetype.InvalidNodeTypeDefinitionException, NodeTypeExistsException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
NodeType
object.
Typically, the object passed to this method will be a NodeTypeTemplate
(a subclass of NodeTypeDefinition
)
acquired from createNodeTypeTemplate()
and then filled-in with definition information.
registerNodeType
in interface javax.jcr.nodetype.NodeTypeManager
template
- the new node type to registerallowUpdate
- this flag is not usednewly created node type
javax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if the NodeTypeDefinition
is invalidNodeTypeExistsException
- if allowUpdate
is false and the NodeTypeDefinition
specifies a node type
name that already existsjavax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if another error occurspublic javax.jcr.nodetype.NodeTypeIterator registerNodeTypes(Collection<javax.jcr.nodetype.NodeTypeDefinition> templates, boolean allowUpdates) throws javax.jcr.nodetype.InvalidNodeTypeDefinitionException, NodeTypeExistsException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
NodeTypeDefinition
objects. This method is used to register or
update a set of node types with mutual dependencies. Returns an iterator over the resulting NodeType
objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
templates
- the new node types to registerallowUpdates
- this flag is not usednewly created node types
javax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if a NodeTypeDefinition
within the collection is invalidNodeTypeExistsException
- if allowUpdate
is false and a NodeTypeDefinition
within the collection
specifies a node type name that already existsjavax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if another error occurspublic javax.jcr.nodetype.NodeTypeIterator registerNodeTypes(Iterable<javax.jcr.nodetype.NodeTypeDefinition> nodeTypes) throws javax.jcr.nodetype.InvalidNodeTypeDefinitionException, NodeTypeExistsException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
JcrNodeTypeSource
. This method is used to register or update a set of node
types with mutual dependencies. Returns an iterator over the resulting NodeType
objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
nodeTypes
- the iterable object containing the new node types to registernewly created node types
javax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if a NodeTypeDefinition
within the collection is invalidNodeTypeExistsException
- if allowUpdate
is false and a NodeTypeDefinition
within the collection
specifies a node type name that already existsjavax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if another error occurspublic javax.jcr.nodetype.NodeTypeIterator registerNodeTypes(javax.jcr.nodetype.NodeTypeDefinition[] ntds, boolean allowUpdate) throws javax.jcr.nodetype.InvalidNodeTypeDefinitionException, NodeTypeExistsException, javax.jcr.RepositoryException
NodeTypeDefinition
objects. This method is used to register or update a
set of node types with mutual dependencies. Returns an iterator over the resulting NodeType
objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
registerNodeTypes
in interface javax.jcr.nodetype.NodeTypeManager
ntds
- the new node types to registerallowUpdate
- must be false
; ModeShape does not allow updating node types at this timenewly created node types
javax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if a NodeTypeDefinition
within the collection is invalidNodeTypeExistsException
- if allowUpdate
is false and a NodeTypeDefinition
within the collection
specifies a node type name that already existsjavax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if another error occurspublic void unregisterNodeType(String nodeTypeName) throws javax.jcr.nodetype.NoSuchNodeTypeException, javax.jcr.nodetype.InvalidNodeTypeDefinitionException, javax.jcr.RepositoryException
unregisterNodeType
in interface javax.jcr.nodetype.NodeTypeManager
nodeTypeName
- javax.jcr.nodetype.NoSuchNodeTypeException
- if node type name does not correspond to a registered node typejavax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if the node type with the given name cannot be unregistered because it is the
supertype, one of the required primary types, or a default primary type of another node typejavax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if any other error occurspublic void unregisterNodeTypes(Collection<String> nodeTypeNames) throws javax.jcr.nodetype.NoSuchNodeTypeException, javax.jcr.nodetype.InvalidNodeTypeDefinitionException, javax.jcr.RepositoryException
nodeTypeNames
- the names of the node types to be unregisteredjavax.jcr.nodetype.NoSuchNodeTypeException
- if any of the node type names do not correspond to a registered node typejavax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if any of the node types with the given names cannot be unregistered because
they are the supertype, one of the required primary types, or a default primary type of a node type that is not
being unregistered.javax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if any other error occurspublic void unregisterNodeTypes(String[] names) throws javax.jcr.nodetype.NoSuchNodeTypeException, javax.jcr.RepositoryException
unregisterNodeTypes
in interface javax.jcr.nodetype.NodeTypeManager
names
- the names of the node types to be unregisteredjavax.jcr.nodetype.NoSuchNodeTypeException
- if any of the node type names do not correspond to a registered node typejavax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if any of the node types with the given names cannot be unregistered because
they are the supertype, one of the required primary types, or a default primary type of a node type that is not
being unregistered.javax.jcr.AccessDeniedException
- if the current session does not have the register
type permission
.javax.jcr.RepositoryException
- if any other error occurspublic javax.jcr.nodetype.NodeTypeTemplate createNodeTypeTemplate() throws javax.jcr.RepositoryException
NodeTypeTemplate
which can then be used to define a node type and passed to
registerNodeType(NodeTypeDefinition, boolean)
createNodeTypeTemplate
in interface javax.jcr.nodetype.NodeTypeManager
NodeTypeTemplate
which can then be used to define a node type and passed to
registerNodeType(NodeTypeDefinition, boolean)
.javax.jcr.RepositoryException
- if another error occurspublic javax.jcr.nodetype.NodeTypeTemplate createNodeTypeTemplate(javax.jcr.nodetype.NodeTypeDefinition ntd) throws javax.jcr.RepositoryException
NodeTypeTemplate
based on the definition given in ntd
. This template can then be used to define a
node type and passed to registerNodeType(NodeTypeDefinition, boolean)
createNodeTypeTemplate
in interface javax.jcr.nodetype.NodeTypeManager
ntd
- an existing node type definition; null values will be ignoredNodeTypeTemplate
which can then be used to define a node type and passed to
registerNodeType(NodeTypeDefinition, boolean)
.javax.jcr.RepositoryException
- if another error occurspublic javax.jcr.nodetype.NodeDefinitionTemplate createNodeDefinitionTemplate() throws javax.jcr.RepositoryException
PropertyDefinitionTemplate
which can then be used to create a property definition and attached to
a NodeTypeTemplate
.createNodeDefinitionTemplate
in interface javax.jcr.nodetype.NodeTypeManager
PropertyDefinitionTemplate
which can then be used to create a property definition and attached to
a NodeTypeTemplate
.javax.jcr.RepositoryException
- if another error occurspublic javax.jcr.nodetype.PropertyDefinitionTemplate createPropertyDefinitionTemplate() throws javax.jcr.RepositoryException
PropertyDefinitionTemplate
which can then be used to create a property definition and attached to
a NodeTypeTemplate
.createPropertyDefinitionTemplate
in interface javax.jcr.nodetype.NodeTypeManager
PropertyDefinitionTemplate
which can then be used to create a property definition and attached to
a NodeTypeTemplate
.javax.jcr.RepositoryException
- if another error occurspublic boolean isDerivedFrom(String[] testTypeNames, String primaryTypeName, String[] mixinNames) throws javax.jcr.RepositoryException
testTypeNames
- the names of the types or mixins being tested against (never null
)primaryTypeName
- the primary type name (never null
)mixinNames
- the mixin names (may be null
)true
if at least one test type name is equal to or derived from the primary type or one of the mixinsjavax.jcr.RepositoryException
- if there is an exception obtaining node typesIllegalArgumentException
- if testTypeNames
is null
or empty or if
primaryTypeName
is null
or zero lengthprotected List<javax.jcr.nodetype.NodeTypeDefinition> importFromXml(InputSource source) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public javax.jcr.nodetype.NodeTypeIterator registerNodeTypes(File file, boolean allowUpdate) throws IOException, javax.jcr.RepositoryException
NodeTypeManager
NodeType
objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
file
- the file containing the node typesallowUpdate
- a boolean stating whether existing node type definitions should be modified/updatedIOException
- if there is a problem reading from the supplied streamjavax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if a NodeTypeDefinition
within the Collection
is invalid or if the
Collection
contains an object of a type other than
NodeTypeDefinition
.javax.jcr.nodetype.NodeTypeExistsException
- if allowUpdate
is
false
and a NodeTypeDefinition
within the
Collection
specifies a node type name that is already
registered.javax.jcr.UnsupportedRepositoryOperationException
- if this implementation
does not support node type registration.javax.jcr.RepositoryException
- if another error occurs.public javax.jcr.nodetype.NodeTypeIterator registerNodeTypes(InputStream stream, boolean allowUpdate) throws IOException, javax.jcr.nodetype.InvalidNodeTypeDefinitionException, javax.jcr.nodetype.NodeTypeExistsException, javax.jcr.UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
NodeTypeManager
NodeType
objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
stream
- the stream containing the node type definitions in CND formatallowUpdate
- a boolean stating whether existing node type definitions should be modified/updatedIOException
- if there is a problem reading from the supplied streamjavax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if a NodeTypeDefinition
within the Collection
is invalid or if the
Collection
contains an object of a type other than
NodeTypeDefinition
.javax.jcr.nodetype.NodeTypeExistsException
- if allowUpdate
is
false
and a NodeTypeDefinition
within the
Collection
specifies a node type name that is already
registered.javax.jcr.UnsupportedRepositoryOperationException
- if this implementation
does not support node type registration.javax.jcr.RepositoryException
- if another error occurs.public javax.jcr.nodetype.NodeTypeIterator registerNodeTypes(URL url, boolean allowUpdate) throws IOException, javax.jcr.RepositoryException
NodeTypeManager
NodeType
objects.
The effect of the method is "all or nothing"; if an error occurs, no node types are registered or updated.
url
- the URL that can be resolved to the file containing the node type definitions in CND formatallowUpdate
- a boolean stating whether existing node type definitions should be modified/updatedIOException
- if there is a problem reading from the supplied streamjavax.jcr.nodetype.InvalidNodeTypeDefinitionException
- if a NodeTypeDefinition
within the Collection
is invalid or if the
Collection
contains an object of a type other than
NodeTypeDefinition
.javax.jcr.nodetype.NodeTypeExistsException
- if allowUpdate
is
false
and a NodeTypeDefinition
within the
Collection
specifies a node type name that is already
registered.javax.jcr.UnsupportedRepositoryOperationException
- if this implementation
does not support node type registration.javax.jcr.RepositoryException
- if another error occurs.Copyright © 2008-2015 JBoss, a division of Red Hat. All Rights Reserved.