001: /*
002: * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Scott Ferguson
028: */
029:
030: package javax.jcr;
031:
032: import javax.jcr.lock.Lock;
033: import javax.jcr.lock.LockException;
034: import javax.jcr.nodetype.ConstraintViolationException;
035: import javax.jcr.nodetype.NoSuchNodeTypeException;
036: import javax.jcr.nodetype.NodeDefinition;
037: import javax.jcr.nodetype.NodeType;
038: import javax.jcr.version.Version;
039: import javax.jcr.version.VersionException;
040: import javax.jcr.version.VersionHistory;
041: import java.io.InputStream;
042: import java.util.Calendar;
043:
044: /**
045: * Represents a directory node in the repository.
046: */
047: public interface Node extends Item {
048: /**
049: * Creates a new node given by the relative path.
050: *
051: * @param relPath relative path to the new node.
052: */
053: public Node addNode(String relPath) throws ItemExistsException,
054: PathNotFoundException, VersionException,
055: ConstraintViolationException, LockException,
056: RepositoryException;
057:
058: /**
059: * Creates a new node given by the relative path.
060: *
061: * @param relPath relative path to the new node.
062: * @param primaryNodeTypeName the node type of the new node
063: */
064: public Node addNode(String relPath, String primaryNodeTypeName)
065: throws ItemExistsException, PathNotFoundException,
066: NoSuchNodeTypeException, LockException, VersionException,
067: ConstraintViolationException, RepositoryException;
068:
069: /**
070: * Moves the source node before the dest
071: *
072: * @param srcChildRelPath relative path to the source item
073: * @param destChildRelPath relative path to the destination item
074: */
075: public void orderBefore(String srcChildRelPath,
076: String destChildRelPath)
077: throws UnsupportedRepositoryOperationException,
078: VersionException, ConstraintViolationException,
079: ItemNotFoundException, LockException, RepositoryException;
080:
081: /**
082: * Sets a property of the node.
083: *
084: * @param name single-level name identifying the property
085: * @param value the property's new value
086: */
087: public Property setProperty(String name, Value value)
088: throws ValueFormatException, VersionException,
089: LockException, ConstraintViolationException,
090: RepositoryException;
091:
092: /**
093: * Sets a property of the node.
094: *
095: * @param name single-level name identifying the property
096: * @param value the property's new value
097: * @param type the property's value type
098: */
099: public Property setProperty(String name, Value value, int type)
100: throws ValueFormatException, VersionException,
101: LockException, ConstraintViolationException,
102: RepositoryException;
103:
104: /**
105: * Sets a property of the node with a value array.
106: *
107: * @param name single-level name identifying the property
108: * @param values array of values for the property
109: */
110: public Property setProperty(String name, Value[] values)
111: throws ValueFormatException, VersionException,
112: LockException, ConstraintViolationException,
113: RepositoryException;
114:
115: /**
116: * Sets a property of the node with a value array.
117: *
118: * @param name single-level name identifying the property
119: * @param values array of values for the property
120: * @param type the expected type of the property
121: */
122: public Property setProperty(String name, Value[] values, int type)
123: throws ValueFormatException, VersionException,
124: LockException, ConstraintViolationException,
125: RepositoryException;
126:
127: /**
128: * Sets a property of the node with an array of string values
129: *
130: * @param name single-level name identifying the property
131: * @param values array of values for the property
132: */
133: public Property setProperty(String name, String[] values)
134: throws ValueFormatException, VersionException,
135: LockException, ConstraintViolationException,
136: RepositoryException;
137:
138: /**
139: * Sets a property of the node with an array of string values
140: *
141: * @param name single-level name identifying the property
142: * @param values array of values for the property
143: * @param type the expected type of the property
144: */
145: public Property setProperty(String name, String[] values, int type)
146: throws ValueFormatException, VersionException,
147: LockException, ConstraintViolationException,
148: RepositoryException;
149:
150: /**
151: * Sets a property of the node with a single string value
152: *
153: * @param name single-level name identifying the property
154: * @param values array of values for the property
155: * @param type the expected type of the property
156: */
157: public Property setProperty(String name, String value)
158: throws ValueFormatException, VersionException,
159: LockException, ConstraintViolationException,
160: RepositoryException;
161:
162: /**
163: * Sets a property of the node with a single string value
164: *
165: * @param name single-level name identifying the property
166: * @param values array of values for the property
167: * @param type the expected type of the property
168: */
169: public Property setProperty(String name, String value, int type)
170: throws ValueFormatException, VersionException,
171: LockException, ConstraintViolationException,
172: RepositoryException;
173:
174: /**
175: * Sets a property of the node from an input stream
176: *
177: * @param name single-level name identifying the property
178: * @param value input stream containing the data
179: */
180: public Property setProperty(String name, InputStream value)
181: throws ValueFormatException, VersionException,
182: LockException, ConstraintViolationException,
183: RepositoryException;
184:
185: /**
186: * Sets a property of the node from a boolean
187: *
188: * @param name single-level name identifying the property
189: * @param value boolean data
190: */
191: public Property setProperty(String name, boolean value)
192: throws ValueFormatException, VersionException,
193: LockException, ConstraintViolationException,
194: RepositoryException;
195:
196: /**
197: * Sets a property of the node from a double
198: *
199: * @param name single-level name identifying the property
200: * @param value double data
201: */
202: public Property setProperty(String name, double value)
203: throws ValueFormatException, VersionException,
204: LockException, ConstraintViolationException,
205: RepositoryException;
206:
207: /**
208: * Sets a property of the node from a long
209: *
210: * @param name single-level name identifying the property
211: * @param value long data
212: */
213: public Property setProperty(String name, long value)
214: throws ValueFormatException, VersionException,
215: LockException, ConstraintViolationException,
216: RepositoryException;
217:
218: /**
219: * Sets a property of the node from a date
220: *
221: * @param name single-level name identifying the property
222: * @param value calendar data
223: */
224: public Property setProperty(String name, Calendar value)
225: throws ValueFormatException, VersionException,
226: LockException, ConstraintViolationException,
227: RepositoryException;
228:
229: /**
230: * Sets a property of the node from a based on a reference to a node
231: *
232: * @param name single-level name identifying the property
233: * @param value node reference
234: */
235: public Property setProperty(String name, Node value)
236: throws ValueFormatException, VersionException,
237: LockException, ConstraintViolationException,
238: RepositoryException;
239:
240: /**
241: * Returns the node with the given relative path.
242: *
243: * @param name relPath path to the given ndoe.
244: */
245: public Node getNode(String relPath) throws PathNotFoundException,
246: RepositoryException;
247:
248: /**
249: * Returns the direct child nodes.
250: */
251: public NodeIterator getNodes() throws RepositoryException;
252:
253: /**
254: * Returns the child nodes matching the name pattern.
255: */
256: public NodeIterator getNodes(String namePattern)
257: throws RepositoryException;
258:
259: /**
260: * Returns the property based on the relative path.
261: */
262: public Property getProperty(String relPath)
263: throws PathNotFoundException, RepositoryException;
264:
265: /**
266: * Returns the an iterator of the properties of the node.
267: */
268: public PropertyIterator getProperties() throws RepositoryException;
269:
270: /**
271: * Returns the an iterator of the properties of the node matching
272: * the pattern.
273: */
274: public PropertyIterator getProperties(String namePattern)
275: throws RepositoryException;
276:
277: /**
278: * Returns the node's primary item.
279: */
280: public Item getPrimaryItem() throws ItemNotFoundException,
281: RepositoryException;
282:
283: /**
284: * Returns the node's UUID
285: */
286: public String getUUID()
287: throws UnsupportedRepositoryOperationException,
288: RepositoryException;
289:
290: /**
291: * Returns the node's index
292: */
293: public int getIndex() throws RepositoryException;
294:
295: /**
296: * Returns the an iterator of the references
297: */
298: public PropertyIterator getReferences() throws RepositoryException;
299:
300: /**
301: * Returns true if the path points to a node.
302: *
303: * @param relPath path to a property
304: */
305: public boolean hasNode(String relPath) throws RepositoryException;
306:
307: /**
308: * Returns true if the path points to a property.
309: *
310: * @param relPath path to a property
311: */
312: public boolean hasProperty(String relPath)
313: throws RepositoryException;
314:
315: /**
316: * Returns true if the node has child nodes.
317: */
318: public boolean hasNodes() throws RepositoryException;
319:
320: /**
321: * Returns true if the node has any properties.
322: */
323: public boolean hasProperties() throws RepositoryException;
324:
325: /**
326: * Returns the node's primary type.
327: */
328: public NodeType getPrimaryNodeType() throws RepositoryException;
329:
330: /**
331: * Returns any mixin types for the node.
332: */
333: public NodeType[] getMixinNodeTypes() throws RepositoryException;
334:
335: /**
336: * Returns true if the node supports the given node tyep.
337: */
338: public boolean isNodeType(String nodeTypeName)
339: throws RepositoryException;
340:
341: /**
342: * Adds a mixin type to the node.
343: */
344: public void addMixin(String mixinName)
345: throws NoSuchNodeTypeException, VersionException,
346: ConstraintViolationException, LockException,
347: RepositoryException;
348:
349: /**
350: * Removes a mixin type to the node.
351: */
352: public void removeMixin(String mixinName)
353: throws NoSuchNodeTypeException, VersionException,
354: ConstraintViolationException, LockException,
355: RepositoryException;
356:
357: /**
358: * Returns true if the given mixin type can be added to the node.
359: */
360: public boolean canAddMixin(String mixinName)
361: throws NoSuchNodeTypeException, RepositoryException;
362:
363: /**
364: * Returns a description of the node.
365: */
366: public NodeDefinition getDefinition() throws RepositoryException;
367:
368: /**
369: * Checks in a new version for to the node.
370: */
371: public Version checkin() throws VersionException,
372: UnsupportedRepositoryOperationException,
373: InvalidItemStateException, LockException,
374: RepositoryException;
375:
376: /**
377: * Checks out a version.
378: */
379: public void checkout()
380: throws UnsupportedRepositoryOperationException,
381: LockException, RepositoryException;
382:
383: /**
384: * Mark the version merge as complete.
385: */
386: public void doneMerge(Version version) throws VersionException,
387: InvalidItemStateException,
388: UnsupportedRepositoryOperationException,
389: RepositoryException;
390:
391: /**
392: * Cancel a version merge.
393: */
394: public void cancelMerge(Version version) throws VersionException,
395: InvalidItemStateException,
396: UnsupportedRepositoryOperationException,
397: RepositoryException;
398:
399: /**
400: * Updates a workspace
401: */
402: public void update(String srcWorkspaceName)
403: throws NoSuchWorkspaceException, AccessDeniedException,
404: LockException, InvalidItemStateException,
405: RepositoryException;
406:
407: /**
408: * Merges child nodes.
409: */
410: public NodeIterator merge(String srcWorkspace, boolean bestEffort)
411: throws NoSuchWorkspaceException, AccessDeniedException,
412: MergeException, LockException, InvalidItemStateException,
413: RepositoryException;
414:
415: /**
416: * Returns the node path to a workspace.
417: */
418: public String getCorrespondingNodePath(String workspaceName)
419: throws ItemNotFoundException, NoSuchWorkspaceException,
420: AccessDeniedException, RepositoryException;
421:
422: /**
423: * Returns true for a checked out node.
424: */
425: public boolean isCheckedOut() throws RepositoryException;
426:
427: /**
428: * Restore the node based on an older version.
429: */
430: public void restore(String versionName, boolean removeExisting)
431: throws VersionException, ItemExistsException,
432: UnsupportedRepositoryOperationException, LockException,
433: InvalidItemStateException, RepositoryException;
434:
435: /**
436: * Restore the node based on an older version.
437: */
438: public void restore(Version version, boolean removeExisting)
439: throws VersionException, ItemExistsException,
440: UnsupportedRepositoryOperationException, LockException,
441: RepositoryException;
442:
443: /**
444: * Restore the node based on an older version.
445: */
446: public void restore(Version version, String relPath,
447: boolean removeExisting) throws PathNotFoundException,
448: ItemExistsException, VersionException,
449: ConstraintViolationException,
450: UnsupportedRepositoryOperationException, LockException,
451: InvalidItemStateException, RepositoryException;
452:
453: /**
454: * Restore the node based on an older version.
455: */
456: public void restoreByLabel(String versionLabel,
457: boolean removeExisting) throws VersionException,
458: ItemExistsException,
459: UnsupportedRepositoryOperationException, LockException,
460: InvalidItemStateException, RepositoryException;
461:
462: /**
463: * Returns the node's version history.
464: */
465: public VersionHistory getVersionHistory()
466: throws UnsupportedRepositoryOperationException,
467: RepositoryException;
468:
469: /**
470: * Returns the base version.
471: */
472: public Version getBaseVersion()
473: throws UnsupportedRepositoryOperationException,
474: RepositoryException;
475:
476: /**
477: * Lock the node.
478: */
479: public Lock lock(boolean isDeep, boolean isSessionScoped)
480: throws UnsupportedRepositoryOperationException,
481: LockException, AccessDeniedException,
482: InvalidItemStateException, RepositoryException;
483:
484: /**
485: * Returns the current lock.
486: */
487: public Lock getLock()
488: throws UnsupportedRepositoryOperationException,
489: LockException, AccessDeniedException, RepositoryException;
490:
491: /**
492: * Unlocks the node.
493: */
494: public void unlock()
495: throws UnsupportedRepositoryOperationException,
496: LockException, AccessDeniedException,
497: InvalidItemStateException, RepositoryException;
498:
499: /**
500: * Returns true if the node owns a lock.
501: */
502: public boolean holdsLock() throws RepositoryException;
503:
504: /**
505: * Returns true if the node is locked.
506: */
507: public boolean isLocked() throws RepositoryException;
508: }
|