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>
listeners
Listeners (weak references)protected SessionImpl
session
The 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 void
accept(ItemVisitor visitor)
protected void
checkIsWritable()
Checks if the repository supports level 2 (writing) and the status of this item.protected void
checkStatus()
Performs a sanity check on this item and the associated session.Item
getAncestor(int depth)
int
getDepth()
protected ItemManager
getItemManager()
Returns the ItemManager associated with this item's Session.protected ItemState
getItemState()
Returns the item-state associated with thisItem
.abstract String
getName()
Node
getParent()
String
getPath()
Session
getSession()
Note: as of 2.x this method returns the session irrespective of the item's status.boolean
isModified()
boolean
isNew()
abstract boolean
isNode()
boolean
isSame(Item otherItem)
protected boolean
isWritable()
Returns true if the repository supports level 2 (writing).void
refresh(boolean keepChanges)
void
remove()
void
save()
void
statusChanged(ItemState state, int previousStatus)
Called after anItemState
has 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:
getPath
in interfaceItem
- Throws:
RepositoryException
- See Also:
Item.getPath()
-
getName
public abstract String getName() throws RepositoryException
- Specified by:
getName
in interfaceItem
- Throws:
RepositoryException
- See Also:
Item.getName()
-
getAncestor
public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Specified by:
getAncestor
in interfaceItem
- Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException
- See Also:
Item.getAncestor(int)
-
getParent
public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Specified by:
getParent
in interfaceItem
- Throws:
ItemNotFoundException
AccessDeniedException
RepositoryException
- See Also:
Item.getParent()
-
getDepth
public int getDepth() throws RepositoryException
- Specified by:
getDepth
in 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:
getSession
in interfaceItem
- Throws:
RepositoryException
- See Also:
Item.getSession()
, Issue JCR-2529
-
isNew
public boolean isNew()
- Specified by:
isNew
in interfaceItem
- See Also:
Item.isNew()
-
isModified
public boolean isModified()
- Specified by:
isModified
in interfaceItem
- See Also:
Item.isModified()
-
isSame
public boolean isSame(Item otherItem) throws RepositoryException
- Specified by:
isSame
in interfaceItem
- Throws:
RepositoryException
- See Also:
Item.isSame(Item)
-
accept
public abstract void accept(ItemVisitor visitor) throws RepositoryException
- Specified by:
accept
in interfaceItem
- Throws:
RepositoryException
- See Also:
Item.accept(ItemVisitor)
-
isNode
public abstract boolean isNode()
- Specified by:
isNode
in interfaceItem
- See Also:
Item.isNode()
-
save
public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, RepositoryException
- Specified by:
save
in interfaceItem
- Throws:
AccessDeniedException
ConstraintViolationException
InvalidItemStateException
ReferentialIntegrityException
VersionException
LockException
RepositoryException
- See Also:
Item.save()
-
refresh
public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException
- Specified by:
refresh
in interfaceItem
- Throws:
InvalidItemStateException
RepositoryException
- See Also:
Item.refresh(boolean)
-
remove
public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException
- Specified by:
remove
in interfaceItem
- Throws:
VersionException
LockException
ConstraintViolationException
RepositoryException
- See Also:
Item.remove()
-
statusChanged
public void statusChanged(ItemState state, int previousStatus)
Description copied from interface:ItemStateLifeCycleListener
Called after anItemState
has changed its status. The new status can be retrieved by callingItemState.getStatus()
.- Specified by:
statusChanged
in interfaceItemStateLifeCycleListener
- Parameters:
state
-previousStatus
-
-
checkStatus
protected void checkStatus() throws RepositoryException
Performs 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, RepositoryException
Checks 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 RepositoryException
Returns 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:
UnsupportedRepositoryOperationException
RepositoryException
- 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
-
-