Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.jcr
Class JcrNodeTypeManager

    java.lang.Object
      org.modeshape.jcr.JcrNodeTypeManager

All Implemented Interfaces:
  NodeTypeManager

    @Immutable
    public class JcrNodeTypeManager

extends Object
implements NodeTypeManager

Local implementation of @{link NodeTypeManager}. This class handles translation between `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.

See Also:
  `RepositoryNodeTypeManager`

Method Summary
`NodeDefinitionTemplate` | `createNodeDefinitionTemplate()` Returns an empty `PropertyDefinitionTemplate` which can then be used to create a property definition and attached to a `NodeTypeTemplate`.
`NodeTypeTemplate` | `createNodeTypeTemplate()` Returns an empty `NodeTypeTemplate` which can then be used to define a node type and passed to `registerNodeType(NodeTypeDefinition, boolean)`
`NodeTypeTemplate` | `createNodeTypeTemplate(NodeTypeDefinition ntd)` Returns a `NodeTypeTemplate` based on the definition given in `ntd`.
`PropertyDefinitionTemplate` | `createPropertyDefinitionTemplate()` Returns an empty `PropertyDefinitionTemplate` which can then be used to create a property definition and attached to a `NodeTypeTemplate`.
`NodeTypeIterator` | `getAllNodeTypes()`
`NodeTypeIterator` | `getMixinNodeTypes()`
`org.modeshape.jcr.JcrNodeType` | `getNodeType(String nodeTypeName)`
`NodeTypeIterator` | `getPrimaryNodeTypes()`
`boolean` | `hasNodeType(String nodeTypeName)` Returns true if and only if the node type with the given name exists.
`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)`
`NodeType` | `registerNodeType(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.
`NodeTypeIterator` | `registerNodeTypes(Collection<NodeTypeDefinition> templates, boolean allowUpdates)` Registers or updates the specified Collection of `NodeTypeDefinition` objects.
`void` | `registerNodeTypes(File file, boolean allowUpdate)` Read the supplied file containing node type definitions in the standard JCR 2.0 Compact Node Definition (CND) format, and register the node types with this repository.
`void` | `registerNodeTypes(InputStream stream, boolean allowUpdate)` Read the supplied stream containing node type definitions in the standard JCR 2.0 Compact Node Definition (CND) format, and register the node types with this repository.
`NodeTypeIterator` | `registerNodeTypes(Iterable<NodeTypeDefinition> nodeTypes)` Registers the node types from the given `JcrNodeTypeSource`.
`NodeTypeIterator` | `registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate)` Registers or updates the specified array of `NodeTypeDefinition` objects.
`void` | `registerNodeTypes(URL url, boolean allowUpdate)` Read the supplied stream containing node type definitions in the standard JCR 2.0 Compact Node Definition (CND) format, and register the node types with this repository.
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getAllNodeTypes

    public NodeTypeIterator getAllNodeTypes()
                                     throws RepositoryException

  Specified by:
    `getAllNodeTypes` in interface `NodeTypeManager`
  Throws:
    `RepositoryException`
  See Also:
    `NodeTypeManager.getAllNodeTypes()`

### getMixinNodeTypes

    public NodeTypeIterator getMixinNodeTypes()
                                       throws RepositoryException

  Specified by:
    `getMixinNodeTypes` in interface `NodeTypeManager`
  Throws:
    `RepositoryException`
  See Also:
    `NodeTypeManager.getMixinNodeTypes()`

### getNodeType

    public org.modeshape.jcr.JcrNodeType getNodeType(String nodeTypeName)
                                              throws NoSuchNodeTypeException,
                                                     RepositoryException

  Specified by:
    `getNodeType` in interface `NodeTypeManager`
  Throws:
    `NoSuchNodeTypeException`
    `RepositoryException`
  See Also:
    `NodeTypeManager.getNodeType(java.lang.String)`

### hasNodeType

    public boolean hasNodeType(String nodeTypeName)

  Returns true if and only if the node type with the given name exists.

  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.

  Specified by:
    `hasNodeType` in interface `NodeTypeManager`
  Parameters:
    `nodeTypeName` - the name of the node type
  Returns:
    true if the named node type does exist, or false otherwise
  See Also:
    `RepositoryNodeTypeManager.hasNodeType(Name)`

### getPrimaryNodeTypes

    public NodeTypeIterator getPrimaryNodeTypes()
                                         throws RepositoryException

  Specified by:
    `getPrimaryNodeTypes` in interface `NodeTypeManager`
  Throws:
    `RepositoryException`
  See Also:
    `NodeTypeManager.getPrimaryNodeTypes()`

### registerNodeType

    public NodeType registerNodeType(NodeTypeDefinition template,
                                     boolean allowUpdate)
                              throws InvalidNodeTypeDefinitionException,
                                     NodeTypeExistsException,
                                     UnsupportedRepositoryOperationException,
                                     AccessDeniedException,
                                     RepositoryException

  Registers a new node type or updates an existing node type using the specified definition and returns the resulting `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.

  Specified by:
    `registerNodeType` in interface `NodeTypeManager`
  Parameters:
    `template` - the new node type to register
    `allowUpdate` - this flag is not used
  Returns:
    the `newly created node type`
  Throws:
    `InvalidNodeTypeDefinitionException` - if the `NodeTypeDefinition` is invalid
    `NodeTypeExistsException` - if `allowUpdate` is false and the `NodeTypeDefinition` specifies a node type name that already exists
    `UnsupportedRepositoryOperationException` - if `allowUpdate` is true; ModeShape does not allow updating node types at this time.
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if another error occurs

### registerNodeTypes

    public NodeTypeIterator registerNodeTypes(Collection<NodeTypeDefinition> templates,
                                              boolean allowUpdates)
                                       throws InvalidNodeTypeDefinitionException,
                                              NodeTypeExistsException,
                                              UnsupportedRepositoryOperationException,
                                              AccessDeniedException,
                                              RepositoryException

  Registers or updates the specified Collection of `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.

  Parameters:
    `templates` - the new node types to register
    `allowUpdates` - this flag is not used
  Returns:
    the `newly created node types`
  Throws:
    `InvalidNodeTypeDefinitionException` - if a `NodeTypeDefinition` within the collection is invalid
    `NodeTypeExistsException` - if `allowUpdate` is false and a `NodeTypeDefinition` within the collection specifies a node type name that already exists
    `UnsupportedRepositoryOperationException` - if `allowUpdate` is true; ModeShape does not allow updating node types at this time.
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if another error occurs

### registerNodeTypes

    public NodeTypeIterator registerNodeTypes(Iterable<NodeTypeDefinition> nodeTypes)
                                       throws InvalidNodeTypeDefinitionException,
                                              NodeTypeExistsException,
                                              UnsupportedRepositoryOperationException,
                                              AccessDeniedException,
                                              RepositoryException

  Registers the node types from the given `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.

  Parameters:
    `nodeTypes` - the iterable object containing the new node types to register
  Returns:
    the `newly created node types`
  Throws:
    `InvalidNodeTypeDefinitionException` - if a `NodeTypeDefinition` within the collection is invalid
    `NodeTypeExistsException` - if `allowUpdate` is false and a `NodeTypeDefinition` within the collection specifies a node type name that already exists
    `UnsupportedRepositoryOperationException` - if `allowUpdate` is true; ModeShape does not allow updating node types at this time.
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if another error occurs

### registerNodeTypes

    public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds,
                                              boolean allowUpdate)
                                       throws InvalidNodeTypeDefinitionException,
                                              NodeTypeExistsException,
                                              UnsupportedRepositoryOperationException,
                                              RepositoryException

  Registers or updates the specified array of `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.

  Specified by:
    `registerNodeTypes` in interface `NodeTypeManager`
  Parameters:
    `ntds` - the new node types to register
    `allowUpdate` - must be `false`; ModeShape does not allow updating node types at this time
  Returns:
    the `newly created node types`
  Throws:
    `InvalidNodeTypeDefinitionException` - if a `NodeTypeDefinition` within the collection is invalid
    `NodeTypeExistsException` - if `allowUpdate` is false and a `NodeTypeDefinition` within the collection specifies a node type name that already exists
    `UnsupportedRepositoryOperationException` - if `allowUpdate` is true; ModeShape does not allow updating node types at this time.
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if another error occurs

### unregisterNodeType

    public void unregisterNodeType(String nodeTypeName)
                            throws NoSuchNodeTypeException,
                                   InvalidNodeTypeDefinitionException,
                                   RepositoryException

  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).

  Specified by:
    `unregisterNodeType` in interface `NodeTypeManager`
  Parameters:
    `nodeTypeName` -
  Throws:
    `NoSuchNodeTypeException` - if node type name does not correspond to a registered node type
    `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 type
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if any other error occurs

### unregisterNodeTypes

    public void unregisterNodeTypes(Collection<String> nodeTypeNames)
                             throws NoSuchNodeTypeException,
                                    InvalidNodeTypeDefinitionException,
                                    RepositoryException

  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.

  Parameters:
    `nodeTypeNames` - the names of the node types to be unregistered
  Throws:
    `NoSuchNodeTypeException` - if any of the node type names do not correspond to a registered node type
    `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.
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if any other error occurs

### unregisterNodeTypes

    public void unregisterNodeTypes(String[] names)
                             throws NoSuchNodeTypeException,
                                    RepositoryException

  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.

  Specified by:
    `unregisterNodeTypes` in interface `NodeTypeManager`
  Parameters:
    `names` - the names of the node types to be unregistered
  Throws:
    `NoSuchNodeTypeException` - if any of the node type names do not correspond to a registered node type
    `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.
    `AccessDeniedException` - if the current session does not have the `register type permission`.
    `RepositoryException` - if any other error occurs

### createNodeTypeTemplate

    public NodeTypeTemplate createNodeTypeTemplate()
                                            throws RepositoryException

  Returns an empty `NodeTypeTemplate` which can then be used to define a node type and passed to `registerNodeType(NodeTypeDefinition, boolean)`

  Specified by:
    `createNodeTypeTemplate` in interface `NodeTypeManager`
  Returns:
    an empty `NodeTypeTemplate` which can then be used to define a node type and passed to `registerNodeType(NodeTypeDefinition, boolean)`.
  Throws:
    `RepositoryException` - if another error occurs

### createNodeTypeTemplate

    public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd)
                                            throws RepositoryException

  Returns a `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)`

  Specified by:
    `createNodeTypeTemplate` in interface `NodeTypeManager`
  Parameters:
    `ntd` - an existing node type definition; null values will be ignored
  Returns:
    an empty `NodeTypeTemplate` which can then be used to define a node type and passed to `registerNodeType(NodeTypeDefinition, boolean)`.
  Throws:
    `RepositoryException` - if another error occurs

### createNodeDefinitionTemplate

    public NodeDefinitionTemplate createNodeDefinitionTemplate()
                                                        throws RepositoryException

  Returns an empty `PropertyDefinitionTemplate` which can then be used to create a property definition and attached to a `NodeTypeTemplate`.

  Specified by:
    `createNodeDefinitionTemplate` in interface `NodeTypeManager`
  Returns:
    an empty `PropertyDefinitionTemplate` which can then be used to create a property definition and attached to a `NodeTypeTemplate`.
  Throws:
    `RepositoryException` - if another error occurs

### createPropertyDefinitionTemplate

    public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
                                                                throws RepositoryException

  Returns an empty `PropertyDefinitionTemplate` which can then be used to create a property definition and attached to a `NodeTypeTemplate`.

  Specified by:
    `createPropertyDefinitionTemplate` in interface `NodeTypeManager`
  Returns:
    an empty `PropertyDefinitionTemplate` which can then be used to create a property definition and attached to a `NodeTypeTemplate`.
  Throws:
    `RepositoryException` - if another error occurs

### isDerivedFrom

    public boolean isDerivedFrom(String[] testTypeNames,
                                 String primaryTypeName,
                                 String[] mixinNames)
                          throws RepositoryException

  Determine if any of the test type names are equal to or have been derived from the primary type or any of the mixins.

  Parameters:
    `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`)
  Returns:
    `true` if at least one test type name is equal to or derived from the primary type or one of the mixins
  Throws:
    `RepositoryException` - if there is an exception obtaining node types
    `IllegalArgumentException` - if `testTypeNames` is `null` or empty or if `primaryTypeName` is `null` or zero length

### registerNodeTypes

    public void registerNodeTypes(File file,
                                  boolean allowUpdate)
                           throws IOException,
                                  RepositoryException

  Description copied from interface: `NodeTypeManager`
  Read the supplied file containing node type definitions in the standard JCR 2.0 Compact Node Definition (CND) format, and register the node types with this repository.

  Parameters:
    `file` - the file containing the node types
    `allowUpdate` - a boolean stating whether existing node type definitions should be modified/updated
  Throws:
    `IOException` - if there is a problem reading from the supplied stream
    `InvalidNodeTypeDefinitionException` - if the `NodeTypeDefinition` is invalid.
    `NodeTypeExistsException` - if `allowUpdate` is `false` and the `NodeTypeDefinition` specifies a node type name that is already registered.
    `UnsupportedRepositoryOperationException` - if this implementation does not support node type registration.
    `RepositoryException` - if another error occurs.

### registerNodeTypes

    public void registerNodeTypes(InputStream stream,
                                  boolean allowUpdate)
                           throws IOException,
                                  InvalidNodeTypeDefinitionException,
                                  NodeTypeExistsException,
                                  UnsupportedRepositoryOperationException,
                                  RepositoryException

  Description copied from interface: `NodeTypeManager`
  Read the supplied stream containing node type definitions in the standard JCR 2.0 Compact Node Definition (CND) format, and register the node types with this repository.

  Parameters:
    `stream` - the stream containing the node type definitions in CND format
    `allowUpdate` - a boolean stating whether existing node type definitions should be modified/updated
  Throws:
    `IOException` - if there is a problem reading from the supplied stream
    `InvalidNodeTypeDefinitionException` - if the `NodeTypeDefinition` is invalid.
    `NodeTypeExistsException` - if `allowUpdate` is `false` and the `NodeTypeDefinition` specifies a node type name that is already registered.
    `UnsupportedRepositoryOperationException` - if this implementation does not support node type registration.
    `RepositoryException` - if another error occurs.

### registerNodeTypes

    public void registerNodeTypes(URL url,
                                  boolean allowUpdate)
                           throws IOException,
                                  RepositoryException

  Description copied from interface: `NodeTypeManager`
  Read the supplied stream containing node type definitions in the standard JCR 2.0 Compact Node Definition (CND) format, and register the node types with this repository.

  Parameters:
    `url` - the URL that can be resolved to the file containing the node type definitions in CND format
    `allowUpdate` - a boolean stating whether existing node type definitions should be modified/updated
  Throws:
    `IOException` - if there is a problem reading from the supplied stream
    `InvalidNodeTypeDefinitionException` - if the `NodeTypeDefinition` is invalid.
    `NodeTypeExistsException` - if `allowUpdate` is `false` and the `NodeTypeDefinition` specifies a node type name that is already registered.
    `UnsupportedRepositoryOperationException` - if this implementation does not support node type registration.
    `RepositoryException` - if another error occurs.

### messageFrom

    protected String messageFrom(Problems problems)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.