Skip navigation links

Oracle Beehive Java Content Repository Java API Reference
Release 1 (1.3)

E11993-02


oracle.ocs.jcr
Interface OracleItem

All Superinterfaces:
javax.jcr.Item

public interface OracleItem
extends javax.jcr.Item

The OrcleItem is the base interface of OracleNode and OracleProperty.


Method Summary
 void accept(javax.jcr.ItemVisitor visitor)
          Accepts an ItemVistor.
 javax.jcr.Item getAncestor(int depth)
          Returns the ancestor of the specified depth.
 int getDepth()
          Returns the depth of this Item in the workspace tree.
 java.lang.String getName()
          Returns the name of this Item.
 javax.jcr.Node getParent()
          Returns the parent of this Item.
 java.lang.String getPath()
          Returns the absolute path to this item.
 javax.jcr.Session getSession()
          Returns the Session through which this Item was acquired.
 boolean isModified()
          Returns true if this Item has been saved but has subsequently been modified through the current session and therefore the state of this item as recorded in the session differs from the state of this item as saved.
 boolean isNew()
          Returns true if this is a new item, meaning that it exists only in transient storage on the Session and has not yet been saved.
 boolean isNode()
          Indicates whether this Item is a Node or a Property.
 boolean isSame(javax.jcr.Item otherItem)
          Returns true if this Item object (the Java object instance) represents the same actual repository item as the object otherItem.
 void refresh(boolean keepChanges)
          If keepChanges is false, this method discards all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item)and returns all items to reflect the current saved state.
 void remove()
          Removes this item (and its subtree).
 void save()
          Validates all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item).

 

Method Detail

getPath

java.lang.String getPath()
                         throws javax.jcr.RepositoryException
Returns the absolute path to this item.
Specified by:
getPath in interface javax.jcr.Item
Returns:
the path of this Item.
Throws:
javax.jcr.RepositoryException - if an error occurs.

getName

java.lang.String getName()
                         throws javax.jcr.RepositoryException
Returns the name of this Item. The name of an item is the last element in its path. If this Item is the root node of the workspace (i.e., if this.getDepth() == 0), "/" is returned.
Specified by:
getName in interface javax.jcr.Item
Returns:
the (or a) name of this Item or an empty string if this Item is the root node.
Throws:
javax.jcr.RepositoryException - if an error occurs.

getAncestor

javax.jcr.Item getAncestor(int depth)
                           throws javax.jcr.ItemNotFoundException,
                                  javax.jcr.RepositoryException
Returns the ancestor of the specified depth. An ancestor of depth x is the Item that is x levels down along the path from the root node to this Item. If depth > n is specified then a ItemNotFoundException is thrown.
Specified by:
getAncestor in interface javax.jcr.Item
Parameters:
depth - An integer, 0 <= depth <= n where n is the depth of this Item.
Returns:
The ancestor of this Item at the specified depth.
Throws:
javax.jcr.ItemNotFoundException - if depth < 0 or depth > n where n is the is the depth of this item.
javax.jcr.AccessDeniedException - - if the current session does not have sufficient access rights to retrieve the specified node.
javax.jcr.RepositoryException - if another error occurs.

getParent

javax.jcr.Node getParent()
                         throws javax.jcr.ItemNotFoundException,
                                javax.jcr.RepositoryException
Returns the parent of this Item.
Specified by:
getParent in interface javax.jcr.Item
Returns:
The parent of this Item.
Throws:
javax.jcr.ItemNotFoundException - if there is no parent. This only happens if this item is the root node of a workspace.
javax.jcr.AccessDeniedException - if the current session does not have sufficient access rights to retrieve the parent of this item.
javax.jcr.RepositoryException - if another error occurs.

getDepth

int getDepth()
             throws javax.jcr.RepositoryException
Returns the depth of this Item in the workspace tree. Returns the depth below the root node of this Item (counting this Item itself).
Specified by:
getDepth in interface javax.jcr.Item
Returns:
The depth of this Item in the workspace hierarchy.
Throws:
javax.jcr.RepositoryException - if an error occurs.

getSession

javax.jcr.Session getSession()
                             throws javax.jcr.RepositoryException
Returns the Session through which this Item was acquired. Every Item can ultimately be traced back through a series of method calls to the call Session.getRootNode(), Session.getItem(java.lang.String) or Session.getNodeByUUID(java.lang.String). This method returns that Session object.
Specified by:
getSession in interface javax.jcr.Item
Returns:
the Session through which this Item was acquired.
Throws:
javax.jcr.RepositoryException - if an error occurs.

isNode

boolean isNode()
Indicates whether this Item is a Node or a Property. Returns true if this Item is a Node; Returns false if this Item is a Property.
Specified by:
isNode in interface javax.jcr.Item
Returns:
true if this Item is a Node, false if it is a Property.

isNew

boolean isNew()
Returns true if this is a new item, meaning that it exists only in transient storage on the Session and has not yet been saved.

Note that if an item returns true on isNew, then by definition is parent will return true on isModified.

Specified by:
isNew in interface javax.jcr.Item
Returns:
true if this item is new; false otherwise.

isModified

boolean isModified()
Returns true if this Item has been saved but has subsequently been modified through the current session and therefore the state of this item as recorded in the session differs from the state of this item as saved.
Specified by:
isModified in interface javax.jcr.Item
Returns:
true if this item is modified; false otherwise.

isSame

boolean isSame(javax.jcr.Item otherItem)
               throws javax.jcr.RepositoryException
Returns true if this Item object (the Java object instance) represents the same actual repository item as the object otherItem.

This method does not compare the states of the two items. For example, if two Item objects representing the same actual repository item have been retrieved through two different sessions and one has been modified, then this method will still return true for these two objects. Note that if two Item objects representing the same repository item are retrieved through the same session they will always reflect the same state so comparing state is not an issue.

Specified by:
isSame in interface javax.jcr.Item
Parameters:
otherItem - the Item object to be tested for identity with this Item.
Returns:
true if this Item object and otherItem represent the same actual repository item; false otherwise.
Throws:
javax.jcr.RepositoryException - if an error occurs.

accept

void accept(javax.jcr.ItemVisitor visitor)
            throws javax.jcr.RepositoryException
Accepts an ItemVistor. Calls the appropriate ItemVistor visit method of the according to whether this Item is a Node or a Property.
Specified by:
accept in interface javax.jcr.Item
Parameters:
visitor - The ItemVisitor to be accepted.
Throws:
javax.jcr.RepositoryException - if an error occurs.

save

void save()
          throws javax.jcr.AccessDeniedException,
                 javax.jcr.ItemExistsException,
                 javax.jcr.nodetype.ConstraintViolationException,
                 javax.jcr.InvalidItemStateException,
                 javax.jcr.ReferentialIntegrityException,
                 javax.jcr.version.VersionException,
                 javax.jcr.lock.LockException,
                 javax.jcr.nodetype.NoSuchNodeTypeException,
                 javax.jcr.RepositoryException
Validates all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item). If validation of all pending changes succeeds, then this change information is cleared from the Session.

If validation fails, then no pending changes are saved and they remain recorded on the Session. There is no best-effort or partial save.

When an item is saved the item in persistent storage to which pending changes are written is determined as follows:

As a result of these rules, a save of an item that has a UUID will succeed even if that item has, in the meantime, been moved in persistent storage to a new location (that is, its path has changed). However, a save of a non-UUID item will fail (throwing an InvalidItemStateException) if it has, in the meantime, been moved in persistent storage to a new location. A save of a non-UUID item will also fail if it has, in addition to being moved, been replaced in its original position by a UUID-bearing item. An AccessDeniedException will be thrown if any of the changes to be persisted would violate the access privileges of this Session.

If any of the changes to be persisted would cause the removal of a node that is currently the target of a REFERENCE property then a ReferentialIntegrityException is thrown, provided that this Session has read access to that REFERENCE property. If, on the other hand, this Session does not have read access to the REFERENCE property in question, then an AccessDeniedException is thrown instead.

An ItemExistsException will be thrown if any of the changes to be persisted would be prevented by the presence of an already existing item in the workspace.

A ConstraintViolationException will be thrown if any of the changes to be persisted would violate a node type restriction.

An InvalidItemStateException is thrown if any of the changes to be persisted conflicts with a change already persisted through another session and the implementation is such that this conflict can only be detected at save-time and therefore was not detected earlier, at change-time.

A VersionException is thrown if the save would make a result in a change to persistent storage that would violate the read-only status of a checked-in node.

A LockException is thrown if the save would result in a change to persistent storage that would violate a lock.

A NoSuchNodeTypeException is thrown if the save would result in the addition of a node with an unrecognized node type.

A RepositoryException will be thrown if another error occurs.

Specified by:
save in interface javax.jcr.Item
Throws:
javax.jcr.AccessDeniedException - if any of the changes to be persisted would violate the access privileges of the this Session. Also thrown if any of the changes to be persisted would cause the removal of a node that is currently referenced by a REFERENCE property that this Session does not have read access to.
javax.jcr.ItemExistsException - if any of the changes to be persisted would be prevented by the presence of an already existing item in the workspace.
javax.jcr.nodetype.ConstraintViolationException - if any of the changes to be persisted would violate a node type or restriction. Additionally, a repository may use this exception to enforce implementation- or configuration-dependent restrictions.
javax.jcr.InvalidItemStateException - if any of the changes to be persisted conflicts with a change already persisted through another session and the implementation is such that this conflict can only be detected at save-time and therefore was not detected earlier, at change-time.
javax.jcr.ReferentialIntegrityException - if any of the changes to be persisted would cause the removal of a node that is currently referenced by a REFERENCE property that this Session has read access to.
javax.jcr.version.VersionException - if the save would make a result in a change to persistent storage that would violate the read-only status of a checked-in node.
javax.jcr.lock.LockException - if the save would result in a change to persistent storage that would violate a lock.
javax.jcr.nodetype.NoSuchNodeTypeException - if the save would result in the addition of a node with an unrecognized node type.
javax.jcr.RepositoryException - if another error occurs.

refresh

void refresh(boolean keepChanges)
             throws javax.jcr.InvalidItemStateException,
                    javax.jcr.RepositoryException
If keepChanges is false, this method discards all pending changes currently recorded in this Session that apply to this Item or any of its descendants (that is, the subtree rooted at this Item)and returns all items to reflect the current saved state.

If keepChanges is true then pending change are not discarded but items that do not have changes pending have their state refreshed to reflect the current saved state, thus revealing changes made by other sessions.

An InvalidItemStateException is thrown if this Item object represents a workspace item that has been removed (either by this session or another).

Specified by:
refresh in interface javax.jcr.Item
Throws:
javax.jcr.InvalidItemStateException - if this Item object represents a workspace item that has been removed (either by this session or another).
javax.jcr.RepositoryException - if another error occurs.

remove

void remove()
            throws javax.jcr.version.VersionException,
                   javax.jcr.lock.LockException,
                   javax.jcr.nodetype.ConstraintViolationException,
                   javax.jcr.RepositoryException
Removes this item (and its subtree). <p/> To persist a removal, a save must be performed that includes the (former) parent of the removed item within its scope. <p/> A ReferentialIntegrityException will be thrown on save if this item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside this item's subtree and the current Session has read access to that REFERENCE property. <p/> An AccessDeniedException will be thrown on save if this item or an item in its subtree is currently the target of a REFERENCE property located in this workspace but outside this item's subtree and the current Session does not have read access to that REFERENCE property. <p/> A ConstraintViolationException will be thrown either immediately or on save, if removing this item would violate a node type. <p/> A VersionException will be thrown either immediately or on save, if the parent node of this item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in. <p/> A LockException will be thrown either immediately or on save if a lock prevents the removal of this item.
Specified by:
remove in interface javax.jcr.Item
Throws:
javax.jcr.version.VersionException - if the parent node of this item is versionable and checked-in or is non-versionable but its nearest versionable ancestor is checked-in and this implementation performs this validation immediately instead of waiting until save.
javax.jcr.lock.LockException - if a lock prevents the removal of this item and this implementation performs this validation immediately instead of waiting until save.
javax.jcr.nodetype.ConstraintViolationException - if removing the specified item would violate a node type or implementation-specific constraint and this implementation performs this validation immediately instead of waiting until save.
javax.jcr.RepositoryException - if another error occurs.

Skip navigation links

Oracle Beehive Java Content Repository Java API Reference
Release 1 (1.3)

E11993-02


Copyright © 2007, 2008, Oracle. All rights reserved.