001: /*
002: * Copyright 2006 Day Management AG, Switzerland. All rights reserved.
003: */
004: package javax.jcr.nodetype;
005:
006: import javax.jcr.RepositoryException;
007: import javax.jcr.Workspace;
008: import javax.jcr.UnsupportedRepositoryOperationException;
009: import java.util.Collection;
010:
011: /**
012: * Allows for the retrieval and (in implementations that support it)
013: * the registration of node types. Accessed via
014: * {@link Workspace#getNodeTypeManager}.
015: */
016: public interface NodeTypeManager {
017:
018: /**
019: * Returns the named node type.
020: * <p>
021: * Throws a <code>NoSuchNodeTypeException</code> if a node type by that name does not exist.
022: * <p>
023: * Throws a <code>RepositoryException</code> if another error occurs.
024: *
025: * @param nodeTypeName the name of an existing node type.
026: * @return A <code>NodeType</code> object.
027: * @throws NoSuchNodeTypeException if no node type by the given name exists.
028: * @throws RepositoryException if another error occurs.
029: */
030: public NodeType getNodeType(String nodeTypeName)
031: throws NoSuchNodeTypeException, RepositoryException;
032:
033: /**
034: * Returns <code>true</code> if a node type with the specified name is
035: * registered. Returns <code>false</code> otherwise.
036: *
037: * @param name a <code>String</code>.
038: * @return a <code>boolean</code>
039: * @throws RepositoryException if an error occurs.
040: * @since JCR 2.0
041: */
042: public boolean hasNodeType(String name) throws RepositoryException;
043:
044: /**
045: * Returns an iterator over all available node types (primary and mixin).
046: *
047: * @return An <code>NodeTypeIterator</code>.
048: *
049: * @throws RepositoryException if an error occurs.
050: */
051: public NodeTypeIterator getAllNodeTypes()
052: throws RepositoryException;
053:
054: /**
055: * Returns an iterator over all available primary node types.
056: *
057: * @return An <code>NodeTypeIterator</code>.
058: *
059: * @throws RepositoryException if an error occurs.
060: */
061: public NodeTypeIterator getPrimaryNodeTypes()
062: throws RepositoryException;
063:
064: /**
065: * Returns an iterator over all available mixin node types.
066: * If none are available, an empty iterator is returned.
067: *
068: * @return An <code>NodeTypeIterator</code>.
069: *
070: * @throws RepositoryException if an error occurs.
071: */
072: public NodeTypeIterator getMixinNodeTypes()
073: throws RepositoryException;
074:
075: /**
076: * Returns an empty <code>NodeTypeTemplate</code> which can then be used to
077: * define a node type and passed to
078: * <code>NodeTypeManager.registerNodeType</code>.
079: * <p/>
080: * Throws an <code>UnsupportedRepositoryOperationException</code> if this
081: * implementation does not support node type registration.
082: * @return A <code>NodeTypeTemplate</code>.
083: * @throws UnsupportedRepositoryOperationException if this implementation
084: * does not support node type registration.
085: * @throws RepositoryException if another error occurs.
086: * @since JCR 2.0
087: */
088: public NodeTypeTemplate createNodeTypeTemplate()
089: throws UnsupportedRepositoryOperationException,
090: RepositoryException;
091:
092: /**
093: * Returns a <code>NodeTypeTemplate</code> holding the specified node type
094: * definition. This template can then be altered and passed to
095: * <code>NodeTypeManager.registerNodeType</code>.
096: * <p/>
097: * Throws an <code>UnsupportedRepositoryOperationException</code> if this
098: * implementation does not support node type registration.
099: *
100: * @param ntd a <code>NodeTypeDefinition</code>.
101: * @return A <code>NodeTypeTemplate</code>.
102: * @throws UnsupportedRepositoryOperationException if this implementation
103: * does not support node type registration.
104: * @throws RepositoryException if another error occurs.
105: * @since JCR 2.0
106: */
107: public NodeTypeTemplate createNodeTypeTemplate(
108: NodeTypeDefinition ntd)
109: throws UnsupportedRepositoryOperationException,
110: RepositoryException;
111:
112: /**
113: * Returns an empty <code>NodeDefinitionTemplate</code> which can then be
114: * used to create a child node definition and attached to a
115: * <code>NodeTypeTemplate</code>.
116: * <p/>
117: * Throws an <code>UnsupportedRepositoryOperationException</code> if this
118: * implementation does not support node type registration.
119: *
120: * @return A <code>NodeDefinitionTemplate</code>.
121: * @throws UnsupportedRepositoryOperationException if this implementation
122: * does not support node type registration.
123: * @throws RepositoryException if another error occurs.
124: * @since JCR 2.0
125: */
126: public NodeDefinitionTemplate createNodeDefinitionTemplate()
127: throws UnsupportedRepositoryOperationException,
128: RepositoryException;
129:
130: /**
131: * Returns an empty <code>PropertyDefinitionTemplate</code> which can then
132: * be used to create a property definition and attached to a
133: * <code>NodeTypeTemplate</code>.
134: * <p/>
135: * Throws an <code>UnsupportedRepositoryOperationException</code> if this
136: * implementation does not support node type registration.
137: *
138: * @return A <code>PropertyDefinitionTemplate</code>.
139: * @throws UnsupportedRepositoryOperationException if this implementation
140: * does not support node type registration.
141: * @throws RepositoryException if another error occurs.
142: * @since JCR 2.0
143: */
144: public PropertyDefinitionTemplate createPropertyDefinitionTemplate()
145: throws UnsupportedRepositoryOperationException,
146: RepositoryException;
147:
148: /**
149: * Registers a new node type or updates an existing node type using the
150: * specified definition and returns the resulting <code>NodeType</code>
151: * object.
152: * <p/>
153: * Typically, the object passed to this method will be a
154: * <code>NodeTypeTemplate</code> (a subclass of
155: * <code>NodeTypeDefinition</code>) acquired from
156: * <code>NodeTypeManager.createNodeTypeTemplate</code> and then filled-in
157: * with definition information.
158: * <p/>
159: * Throws an <code>InvalidNodeTypeDefinitionException</code> if the
160: * <code>NodeTypeDefinition</code> is invalid.
161: * <p/>
162: * Throws a <code>NodeTypeExistsException</code> if <code>allowUpdate</code>
163: * is <code>false</code> and the <code>NodeTypeDefinition</code> specifies a
164: * node type name that is already registered.
165: * <p/>
166: * Throws an <code>UnsupportedRepositoryOperationException</code> if this
167: * implementation does not support node type registration.
168: *
169: * @param ntd an <code>NodeTypeDefinition</code>.
170: * @param allowUpdate a boolean
171: * @return the registered node type
172: * @throws InvalidNodeTypeDefinitionException if the
173: * <code>NodeTypeDefinition</code> is invalid.
174: * @throws NodeTypeExistsException if <code>allowUpdate</code> is
175: * <code>false</code> and the <code>NodeTypeDefinition</code> specifies a
176: * node type name that is already registered.
177: * @throws UnsupportedRepositoryOperationException if this implementation
178: * does not support node type registration.
179: * @throws RepositoryException if another error occurs.
180: * @since JCR 2.0
181: */
182: public NodeType registerNodeType(NodeTypeDefinition ntd,
183: boolean allowUpdate)
184: throws InvalidNodeTypeDefinitionException,
185: NodeTypeExistsException,
186: UnsupportedRepositoryOperationException,
187: RepositoryException;
188:
189: /**
190: * Registers or updates the specified <code>Collection</code> of
191: * <code>NodeTypeDefinition</code> objects. This method is used to register
192: * or update a set of node types with mutual dependencies. Returns an
193: * iterator over the resulting <code>NodeType</code> objects.
194: * <p/>
195: * The effect of the method is "all or nothing"; if an error occurs, no node
196: * types are registered or updated.
197: * <p/>
198: * Throws an <code>InvalidNodeTypeDefinitionException</code> if a
199: * <code>NodeTypeDefinition</code> within the <code>Collection</code> is
200: * invalid or if the <code>Collection</code> contains an object of a type
201: * other than <code>NodeTypeDefinition</code>.
202: * <p/>
203: * Throws a <code>NodeTypeExistsException</code> if <code>allowUpdate</code>
204: * is <code>false</code> and a <code>NodeTypeDefinition</code> within the
205: * <code>Collection</code> specifies a node type name that is already
206: * registered.
207: * <p/>
208: * Throws an <code>UnsupportedRepositoryOperationException</code> if this
209: * implementation does not support node type registration.
210: *
211: * @param definitions a collection of <code>NodeTypeDefinition</code>s
212: * @param allowUpdate a boolean
213: * @return the registered node types.
214: * @throws InvalidNodeTypeDefinitionException if a
215: * <code>NodeTypeDefinition</code> within the <code>Collection</code> is
216: * invalid or if the <code>Collection</code> contains an object of a type
217: * other than <code>NodeTypeDefinition</code>.
218: * @throws NodeTypeExistsException if <code>allowUpdate</code> is
219: * <code>false</code> and a <code>NodeTypeDefinition</code> within the
220: * <code>Collection</code> specifies a node type name that is already
221: * registered.
222: * @throws UnsupportedRepositoryOperationException if this implementation
223: * does not support node type registration.
224: * @throws RepositoryException if another error occurs.
225: * @since JCR 2.0
226: */
227: public NodeTypeIterator registerNodeTypes(Collection definitions,
228: boolean allowUpdate)
229: throws InvalidNodeTypeDefinitionException,
230: NodeTypeExistsException,
231: UnsupportedRepositoryOperationException,
232: RepositoryException;
233:
234: /**
235: * Unregisters the specified node type.
236: * <p/>
237: * Throws a <code>NoSuchNodeTypeException</code> if no registered node type
238: * exists with the specified name.
239: *
240: * @param name a <code>String</code>.
241: * @throws UnsupportedRepositoryOperationException if this implementation
242: * does not support node type registration.
243: * @throws NoSuchNodeTypeException if no registered node type exists with
244: * the specified name.
245: * @throws RepositoryException if another error occurs.
246: * @since JCR 2.0
247: */
248: public void unregisterNodeType(String name)
249: throws UnsupportedRepositoryOperationException,
250: NoSuchNodeTypeException, RepositoryException;
251:
252: /**
253: * Unregisters the specified set of node types. Used to unregister a set of node types with mutual dependencies.
254: * <p/>
255: * Throws a <code>NoSuchNodeTypeException</code> if one of the names listed is not a registered node type.
256: * <p/>
257: * Throws an <code>UnsupportedRepositoryOperationException</code> if this implementation does not support node type registration.
258: *
259: * @param names a <code>String</code> array
260: * @throws UnsupportedRepositoryOperationException if this implementation does not support node type registration.
261: * @throws NoSuchNodeTypeException if one of the names listed is not a registered node type.
262: * @throws RepositoryException if another error occurs.
263: * @since JCR 2.0
264: */
265: public void unregisterNodeTypes(String[] names)
266: throws UnsupportedRepositoryOperationException,
267: NoSuchNodeTypeException, RepositoryException;
268: }
|