Interface Item
-
- All Known Subinterfaces:
JackrabbitNode,Node,Property,Version,VersionHistory
- All Known Implementing Classes:
AbstractItem,AbstractNode,AbstractProperty
public interface Item
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description voidaccept(ItemVisitor visitor)Accepts anItemVisitor.ItemgetAncestor(int depth)Returns the ancestor of thisItemat the specified depth.intgetDepth()Returns the depth of thisItemin the workspace item graph.java.lang.StringgetName()Returns the name of thisItemin qualified form.NodegetParent()Returns the parent of thisItem.java.lang.StringgetPath()Returns the normalized absolute path to this item.SessiongetSession()Returns theSessionthrough which thisItemwas acquired.booleanisModified()Returnstrueif thisItemhas 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.booleanisNew()Returnstrueif this is a new item, meaning that it exists only in transient storage on theSessionand has not yet been saved.booleanisNode()Indicates whether thisItemis aNodeor aProperty.booleanisSame(Item otherItem)Returnstrueif thisItemobject (the Java object instance) represents the same actual workspace item as the objectotherItem.voidrefresh(boolean keepChanges)IfkeepChangesisfalse, this method discards all pending changes currently recorded in thisSessionthat apply to this Item or any of its descendants (that is, the subgraph rooted at this Item)and returns all items to reflect the current saved state.voidremove()Removesthisitem (and its subgraph).voidsave()Deprecated.As of JCR 2.0,Session.save()should be used instead.
-
-
-
Method Detail
-
getPath
java.lang.String getPath() throws RepositoryExceptionReturns the normalized absolute path to this item.- Returns:
- the normalized absolute path of this
Item. - Throws:
RepositoryException- if an error occurs.
-
getName
java.lang.String getName() throws RepositoryExceptionReturns the name of thisItemin qualified form. If thisItemis the root node of the workspace, an empty string is returned.- Returns:
- the name of this
Itemin qualified form or an empty string if thisItemis the root node of a workspace. - Throws:
RepositoryException- if an error occurs.
-
getAncestor
Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException
Returns the ancestor of thisItemat the specified depth. An ancestor of depth x is theItemthat is x levels down along the path from the root node to thisItem.- depth = 0 returns the root node of a workspace.
- depth = 1 returns the child of the root node along
the path to this
Item. - depth = 2 returns
the grandchild of the root node along the path to this
Item. - And so on to depth = n, where
n is the depth of this
Item, which returns thisItemitself.
If this node has more than one path (i.e., if it is a descendant of a shared node) then the path used to define the ancestor is implementaion-dependent.
- Parameters:
depth- An integer, 0 <= depth <= n where n is the depth of thisItem.- Returns:
- The ancestor of this
Itemat the specifieddepth. - Throws:
ItemNotFoundException- if depth < 0 or depth > n where n is the is the depth of this item.AccessDeniedException- if the current session does not have sufficent access to retrieve the specified node.RepositoryException- if another error occurs.
-
getParent
Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
Returns the parent of thisItem.- Returns:
- The parent of this
Item. - Throws:
ItemNotFoundException- if thisItemis the root node of a workspace.AccessDeniedException- if the current session does not have sufficent access to retrieve the parent of this item.RepositoryException- if another error occurs.
-
getDepth
int getDepth() throws RepositoryExceptionReturns the depth of thisItemin the workspace item graph.- The root node returns 0.
- A property or child node of the root node returns 1.
- A property or child node of a child node of the root returns 2.
- And so on to this
Item.
- Returns:
- The depth of this
Itemin the workspace item graph. - Throws:
RepositoryException- if an error occurs.
-
getSession
Session getSession() throws RepositoryException
Returns theSessionthrough which thisItemwas acquired.- Returns:
- the
Sessionthrough which thisItemwas acquired. - Throws:
RepositoryException- if an error occurs.
-
isNode
boolean isNode()
Indicates whether thisItemis aNodeor aProperty. Returnstrueif thisItemis aNode; Returnsfalseif thisItemis aProperty.- Returns:
trueif thisItemis aNode,falseif it is aProperty.
-
isNew
boolean isNew()
Returnstrueif this is a new item, meaning that it exists only in transient storage on theSessionand has not yet been saved. Within a transaction,isNewon anItemmay returnfalse(because the item has been saved) even if thatItemis not in persistent storage (because the transaction has not yet been committed).Note that if an item returns
trueonisNew, then by definition is parent will returntrueonisModified.Note that in read-only implementations, this method will always return
false.- Returns:
trueif this item is new;falseotherwise.
-
isModified
boolean isModified()
Returnstrueif thisItemhas 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. Within a transaction,isModifiedon anItemmay returnfalse(because theItemhas been saved since the modification) even if the modification in question is not in persistent storage (because the transaction has not yet been committed).Note that in read-only implementations, this method will always return
false.- Returns:
trueif this item is modified;falseotherwise.
-
isSame
boolean isSame(Item otherItem) throws RepositoryException
Returnstrueif thisItemobject (the Java object instance) represents the same actual workspace item as the objectotherItem.Two
Itemobjects represent the same workspace item if and only if all the following are true:- Both objects were acquired
through
Sessionobjects that were created by the sameRepositoryobject. - Both objects were acquired
through
Sessionobjects bound to the same repository workspace. - The objects are either both
Nodeobjects or bothPropertyobjects. - If they are
Nodeobjects, they have the same identifier. - If
they are
Propertyobjects they have identical names andisSameis true of their parent nodes.
Itemobjects representing the same actual workspace item have been retrieved through two different sessions and one has been modified, then this method will still returntruewhen comparing these two objects. Note that if twoItemobjects representing the same workspace item are retrieved through the same session they will always reflect the same state.- Parameters:
otherItem- theItemobject to be tested for identity with thisItem.- Returns:
trueif thisItemobject andotherItemrepresent the same actual repository item;falseotherwise.- Throws:
RepositoryException- if an error occurs.
- Both objects were acquired
through
-
accept
void accept(ItemVisitor visitor) throws RepositoryException
Accepts anItemVisitor. Calls the appropriateItemVisitorvisitmethod of the according to whether thisItemis aNodeor aProperty.- Parameters:
visitor- The ItemVisitor to be accepted.- Throws:
RepositoryException- if an error occurs.
-
save
void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException
Deprecated.As of JCR 2.0,Session.save()should be used instead.Validates all pending changes currently recorded in thisSessionthat apply to thisItemor any of its descendants (that is, the subgraph rooted at this Item). If validation of all pending changes succeeds, then this change information is cleared from theSession. If thesaveoccurs outside a transaction, the changes are persisted and thus made visible to otherSessions. If thesaveoccurs within a transaction, the changes are not persisted until the transaction is committed.If validation fails, then no pending changes are saved and they remain recorded on the
Session. There is no best-effort or partial save.The item in persistent storage to which a transient item is saved is
- Throws:
AccessDeniedException- if any of the changes to be persisted would exceed the access capabilities of the the current session. Also thrown if any of the changes to be persisted would cause the removal of a node that is currently referenced by aREFERENCEproperty that the current session does not have read access to.ItemExistsException- if any of the changes to be persisted would be prevented by the presence of an already existing item in the workspace.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.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 atsave-time and therefore was not detected earlier, at change-time.ReferentialIntegrityException- if any of the changes to be persisted would cause the removal of a node that is currently referenced by aREFERENCEproperty that thisSessionhas read access to.VersionException- if thesavewould make a result in a change to persistent storage that would violate the read-only status of a checked-in node.LockException- if thesavewould result in a change to persistent storage that would violate a lock.NoSuchNodeTypeException- if thesavewould result in the addition of a node with an unrecognized node type.RepositoryException- if another error occurs.
-
refresh
void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryExceptionIfkeepChangesisfalse, this method discards all pending changes currently recorded in thisSessionthat apply to this Item or any of its descendants (that is, the subgraph rooted at this Item)and returns all items to reflect the current saved state. Outside a transaction this state is simple the current state of persistent storage. Within a transaction, this state will reflect persistent storage as modified by changes that have been saved but not yet committed.If
keepChangesis 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.- Parameters:
keepChanges- a boolean- Throws:
InvalidItemStateException- if thisItemobject represents a workspace item that has been removed (either by this session or another).RepositoryException- if another error occurs.
-
remove
void remove() throws VersionException, LockException, ConstraintViolationException, AccessDeniedException, RepositoryExceptionRemovesthisitem (and its subgraph).To persist a removal, a
savemust be performed that includes the (former) parent of the removed item within its scope.If a node with same-name siblings is removed, this decrements by one the indices of all the siblings with indices greater than that of the removed node. In other words, a removal compacts the array of same-name siblings and causes the minimal re-numbering required to maintain the original order but leave no gaps in the numbering.
- Throws:
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 untilsave.LockException- if a lock prevents the removal of this item and this implementation performs this validation immediately instead of waiting untilsave.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 untilsave.AccessDeniedException- if this item or an item in its subgraph is currently the target of aREFERENCEproperty located in this workspace but outside this item's subgraph and the currentSessiondoes not have read access to thatREFERENCEproperty or if the currentSessiondoes not have sufficent privileges to remove the item.RepositoryException- if another error occurs.- See Also:
Session.removeItem(String)
-
-