Package org.apache.jackrabbit.core
Class ItemManager
- java.lang.Object
-
- org.apache.jackrabbit.core.ItemManager
-
- All Implemented Interfaces:
ItemStateListener
public class ItemManager extends Object implements ItemStateListener
There's oneItemManager
instance perSession
instance. It is the factory forNode
andProperty
instances.The
ItemManager
's responsibilities are:- providing access to
Item
instances byItemId
whereasNode
andItem
are only providing relative access. - returning the instance of an existing
Node
orProperty
, given its absolute path. - creating the per-session instance of a
Node
orProperty
that doesn't exist yet and needs to be created first. - guaranteeing that there aren't multiple instances representing the same
Node
orProperty
associated with the sameSession
instance. - maintaining a cache of the item instances it created.
- respecting access rights of associated
Session
in all methods.
If the parent
Session
is anXASession
, there is oneItemManager
instance per started global transaction.
-
-
Field Summary
Fields Modifier and Type Field Description protected SessionImpl
session
protected SessionContext
sessionContext
Component context of the associated session.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ItemManager(SessionContext sessionContext)
Creates a new per-session instanceItemManager
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ItemImpl
getItem(ItemId id)
ItemImpl
getItem(Path path)
Deprecated.As of JSR 283, aPath
doesn't anymore uniquely identify anItem
, thereforegetNode(Path)
andgetProperty(Path)
should be used instead.NodeImpl
getNode(NodeId id, NodeId parentId)
Returns a node with a given id and parent id.NodeImpl
getNode(Path path)
PropertyImpl
getProperty(Path path)
void
itemDestroyed(ItemId id, ItemData data)
boolean
itemExists(ItemId id)
Checks if the item with the given id exists.boolean
itemExists(Path path)
Deprecated.As of JSR 283, aPath
doesn't anymore uniquely identify anItem
, thereforenodeExists(Path)
andpropertyExists(Path)
should be used instead.void
itemInvalidated(ItemId id, ItemData data)
boolean
nodeExists(Path path)
Checks whether a node exists at the specified path.boolean
propertyExists(Path path)
Checks whether a property exists at the specified path.void
stateCreated(ItemState created)
Called when anItemState
has successfully been created (i.e.void
stateDestroyed(ItemState destroyed)
Called when anItemState
has successfully been removed (i.e.void
stateDiscarded(ItemState discarded)
Called when anItemState
has been discarded (i.e.void
stateModified(ItemState modified)
Called when anItemState
has successfully been modified (i.e.String
toString()
-
-
-
Field Detail
-
sessionContext
protected final SessionContext sessionContext
Component context of the associated session.
-
session
protected final SessionImpl session
-
-
Constructor Detail
-
ItemManager
protected ItemManager(SessionContext sessionContext)
Creates a new per-session instanceItemManager
instance.- Parameters:
sessionContext
- component context of the associated session
-
-
Method Detail
-
itemExists
@Deprecated public boolean itemExists(Path path)
Deprecated.As of JSR 283, aPath
doesn't anymore uniquely identify anItem
, thereforenodeExists(Path)
andpropertyExists(Path)
should be used instead.Checks whether an item exists at the specified path.- Parameters:
path
- path to the item to be checked- Returns:
- true if the specified item exists
-
nodeExists
public boolean nodeExists(Path path)
Checks whether a node exists at the specified path.- Parameters:
path
- path to the node to be checked- Returns:
- true if a node exists at the specified path
-
propertyExists
public boolean propertyExists(Path path)
Checks whether a property exists at the specified path.- Parameters:
path
- path to the property to be checked- Returns:
- true if a property exists at the specified path
-
itemExists
public boolean itemExists(ItemId id)
Checks if the item with the given id exists.- Parameters:
id
- id of the item to be checked- Returns:
- true if the specified item exists
-
getItem
@Deprecated public ItemImpl getItem(Path path) throws PathNotFoundException, AccessDeniedException, RepositoryException
Deprecated.As of JSR 283, aPath
doesn't anymore uniquely identify anItem
, thereforegetNode(Path)
andgetProperty(Path)
should be used instead.Returns the node at the specified absolute path in the workspace. If no such node exists, then it returns the property at the specified path. If no such property exists aPathNotFoundException
is thrown.- Parameters:
path
-- Returns:
- Throws:
PathNotFoundException
AccessDeniedException
RepositoryException
-
getNode
public NodeImpl getNode(Path path) throws PathNotFoundException, AccessDeniedException, RepositoryException
- Parameters:
path
-- Returns:
- Throws:
PathNotFoundException
AccessDeniedException
RepositoryException
-
getProperty
public PropertyImpl getProperty(Path path) throws PathNotFoundException, AccessDeniedException, RepositoryException
- Parameters:
path
-- Returns:
- Throws:
PathNotFoundException
AccessDeniedException
RepositoryException
-
getItem
public ItemImpl getItem(ItemId id) throws ItemNotFoundException, AccessDeniedException, RepositoryException
- Parameters:
id
-- Returns:
- Throws:
RepositoryException
ItemNotFoundException
AccessDeniedException
-
getNode
public NodeImpl getNode(NodeId id, NodeId parentId) throws ItemNotFoundException, AccessDeniedException, RepositoryException
Returns a node with a given id and parent id. If the indicated node is shareable, there might be multiple nodes associated with the same id, but there'is only one node with the given parent id.- Parameters:
id
- node idparentId
- parent node id- Returns:
- node
- Throws:
RepositoryException
- if an error occursItemNotFoundException
AccessDeniedException
-
stateCreated
public void stateCreated(ItemState created)
Called when anItemState
has successfully been created (i.e. its underlying persistent state was created).- Specified by:
stateCreated
in interfaceItemStateListener
- Parameters:
created
- theItemState
that has been 'created'
-
stateModified
public void stateModified(ItemState modified)
Called when anItemState
has successfully been modified (i.e. its underlying persistent state has changed).- Specified by:
stateModified
in interfaceItemStateListener
- Parameters:
modified
- theItemState
that has been 'modified'
-
stateDestroyed
public void stateDestroyed(ItemState destroyed)
Called when anItemState
has successfully been removed (i.e. its underlying persistent state has been destroyed).- Specified by:
stateDestroyed
in interfaceItemStateListener
- Parameters:
destroyed
- theItemState
that has been 'destroyed'
-
stateDiscarded
public void stateDiscarded(ItemState discarded)
Called when anItemState
has been discarded (i.e. it has been rendered 'invalid').- Specified by:
stateDiscarded
in interfaceItemStateListener
- Parameters:
discarded
- theItemState
that has been discarded- See Also:
ItemState.discard()
-
-