Package org.apache.jackrabbit.jcr2spi
Class ItemImpl
- java.lang.Object
-
- org.apache.jackrabbit.jcr2spi.ItemImpl
-
- All Implemented Interfaces:
Item,ItemStateLifeCycleListener
- Direct Known Subclasses:
NodeImpl,PropertyImpl
public abstract class ItemImpl extends Object implements Item, ItemStateLifeCycleListener
ItemImpl...
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<ItemLifeCycleListener,ItemLifeCycleListener>listenersListeners (weak references)protected SessionImplsessionThe session that created this item.
-
Constructor Summary
Constructors Constructor Description ItemImpl(SessionImpl session, ItemState state, ItemLifeCycleListener[] listeners)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaccept(ItemVisitor visitor)protected voidcheckIsWritable()Checks if the repository supports level 2 (writing) and the status of this item.protected voidcheckStatus()Performs a sanity check on this item and the associated session.ItemgetAncestor(int depth)intgetDepth()protected ItemManagergetItemManager()Returns the ItemManager associated with this item's Session.protected ItemStategetItemState()Returns the item-state associated with thisItem.abstract StringgetName()NodegetParent()StringgetPath()SessiongetSession()Note: as of 2.x this method returns the session irrespective of the item's status.booleanisModified()booleanisNew()abstract booleanisNode()booleanisSame(Item otherItem)protected booleanisWritable()Returns true if the repository supports level 2 (writing).voidrefresh(boolean keepChanges)voidremove()voidsave()voidstatusChanged(ItemState state, int previousStatus)Called after anItemStatehas changed its status.
-
-
-
Field Detail
-
session
protected SessionImpl session
The session that created this item.
-
listeners
protected final Map<ItemLifeCycleListener,ItemLifeCycleListener> listeners
Listeners (weak references)
-
-
Constructor Detail
-
ItemImpl
public ItemImpl(SessionImpl session, ItemState state, ItemLifeCycleListener[] listeners)
-
-
Method Detail
-
getPath
public String getPath() throws RepositoryException
- Specified by:
getPathin interfaceItem- Throws:
RepositoryException- See Also:
Item.getPath()
-
getName
public abstract String getName() throws RepositoryException
- Specified by:
getNamein interfaceItem- Throws:
RepositoryException- See Also:
Item.getName()
-
getAncestor
public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Specified by:
getAncestorin interfaceItem- Throws:
ItemNotFoundExceptionAccessDeniedExceptionRepositoryException- See Also:
Item.getAncestor(int)
-
getParent
public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Specified by:
getParentin interfaceItem- Throws:
ItemNotFoundExceptionAccessDeniedExceptionRepositoryException- See Also:
Item.getParent()
-
getDepth
public int getDepth() throws RepositoryException- Specified by:
getDepthin interfaceItem- Throws:
RepositoryException- See Also:
Item.getDepth()
-
getSession
public Session getSession() throws RepositoryException
Note: as of 2.x this method returns the session irrespective of the item's status.- Specified by:
getSessionin interfaceItem- Throws:
RepositoryException- See Also:
Item.getSession(), Issue JCR-2529
-
isNew
public boolean isNew()
- Specified by:
isNewin interfaceItem- See Also:
Item.isNew()
-
isModified
public boolean isModified()
- Specified by:
isModifiedin interfaceItem- See Also:
Item.isModified()
-
isSame
public boolean isSame(Item otherItem) throws RepositoryException
- Specified by:
isSamein interfaceItem- Throws:
RepositoryException- See Also:
Item.isSame(Item)
-
accept
public abstract void accept(ItemVisitor visitor) throws RepositoryException
- Specified by:
acceptin interfaceItem- Throws:
RepositoryException- See Also:
Item.accept(ItemVisitor)
-
isNode
public abstract boolean isNode()
- Specified by:
isNodein interfaceItem- See Also:
Item.isNode()
-
save
public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, RepositoryException- Specified by:
savein interfaceItem- Throws:
AccessDeniedExceptionConstraintViolationExceptionInvalidItemStateExceptionReferentialIntegrityExceptionVersionExceptionLockExceptionRepositoryException- See Also:
Item.save()
-
refresh
public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException- Specified by:
refreshin interfaceItem- Throws:
InvalidItemStateExceptionRepositoryException- See Also:
Item.refresh(boolean)
-
remove
public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException- Specified by:
removein interfaceItem- Throws:
VersionExceptionLockExceptionConstraintViolationExceptionRepositoryException- See Also:
Item.remove()
-
statusChanged
public void statusChanged(ItemState state, int previousStatus)
Description copied from interface:ItemStateLifeCycleListenerCalled after anItemStatehas changed its status. The new status can be retrieved by callingItemState.getStatus().- Specified by:
statusChangedin interfaceItemStateLifeCycleListener- Parameters:
state-previousStatus-
-
checkStatus
protected void checkStatus() throws RepositoryExceptionPerforms a sanity check on this item and the associated session. If the underlying item state is in an invalidated state then it will be refreshed to get the current status of the item state. The status check is then performed on the newly retrieved status.- Throws:
RepositoryException- if this item has been rendered invalid for some reason
-
checkIsWritable
protected void checkIsWritable() throws UnsupportedRepositoryOperationException, ConstraintViolationException, RepositoryExceptionChecks if the repository supports level 2 (writing) and the status of this item. Note, that this method does not perform any additional validation checks such as access restrictions, locking, checkin status or protection that affect the writing to nodes and properties.
-
isWritable
protected boolean isWritable() throws RepositoryExceptionReturns true if the repository supports level 2 (writing). Note, that this method does not perform any additional validation tests such as access restrictions, locking, checkin status or protection that affect the writing to nodes and properties.- Throws:
UnsupportedRepositoryOperationExceptionRepositoryException- if the sanity check on this item fails. SeecheckStatus().- See Also:
ItemStateValidator
-
getItemState
protected ItemState getItemState()
Returns the item-state associated with thisItem.- Returns:
- state associated with this
Item
-
getItemManager
protected ItemManager getItemManager()
Returns the ItemManager associated with this item's Session.- Returns:
- ItemManager
-
-