public class BatchedItemOperations extends ItemValidator
BatchedItemOperations
is an internal helper class that
provides both high- and low-level operations directly on the
ItemState
level.Modifier and Type | Field and Description |
---|---|
protected static int |
CLONE |
protected static int |
CLONE_REMOVE_EXISTING |
protected static int |
COPY |
protected SessionImpl |
session
current session used for checking access rights
|
protected UpdatableItemStateManager |
stateMgr
wrapped item state manager
|
CHECK_ACCESS, CHECK_CHECKED_OUT, CHECK_CONSTRAINTS, CHECK_HOLD, CHECK_LOCK, CHECK_PENDING_CHANGES, CHECK_PENDING_CHANGES_ON_NODE, CHECK_REFERENCES, CHECK_RETENTION, context
Constructor and Description |
---|
BatchedItemOperations(UpdatableItemStateManager stateMgr,
SessionContext sessionContext)
Creates a new
BatchedItemOperations instance. |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancel an update operation.
|
void |
checkAddNode(NodeState parentState,
Name nodeName,
Name nodeTypeName,
int options)
Checks if adding a child node called
nodeName of node type
nodeTypeName to the given parent node is allowed in the
current context. |
void |
checkRemoveNode(NodeState targetState,
int options)
Checks if removing the given target node is allowed in the current context.
|
void |
checkRemoveNode(NodeState targetState,
NodeId parentId,
int options)
Checks if removing the given target node from the specifed parent
is allowed in the current context.
|
NodeId |
clone(NodeState srcState,
NodeState destParentState,
Name destName)
Implementation of
clone(Path, Path) that has already determined
the affected NodeState s. |
NodeId |
clone(Path srcPath,
Path destPath)
Clones the subtree at the node
srcAbsPath in to the new
location at destAbsPath . |
NodeId |
copy(Path srcPath,
ItemStateManager srcStateMgr,
HierarchyManager srcHierMgr,
AccessManager srcAccessMgr,
Path destPath,
int flag)
Copies the tree at
srcPath retrieved using the specified
srcStateMgr to the new location at destPath . |
NodeId |
copy(Path srcPath,
Path destPath,
int flag)
Copies the tree at
srcPath to the new location at
destPath . |
NodeState |
createNodeState(NodeState parent,
Name nodeName,
Name nodeTypeName,
Name[] mixinNames,
NodeId id)
Creates a new node.
|
NodeState |
createNodeState(NodeState parent,
Name nodeName,
Name nodeTypeName,
Name[] mixinNames,
NodeId id,
QNodeDefinition def)
Creates a new node based on the given definition.
|
PropertyState |
createPropertyState(NodeState parent,
Name propName,
int type,
int numValues)
Creates a new property.
|
PropertyState |
createPropertyState(NodeState parent,
Name propName,
int type,
QPropertyDefinition def)
Creates a new property based on the given definition.
|
void |
destroy(ItemState state)
Destroy an item state.
|
void |
edit()
Starts an edit operation on the wrapped state manager.
|
ItemState |
getItemState(ItemId id)
Retrieves the state of the item with the given id.
|
protected ItemState |
getItemState(ItemStateManager srcStateMgr,
ItemId id)
Retrieves the state of the item with the specified id using the given
item state manager.
|
protected NodeState |
getNodeState(ItemStateManager srcStateMgr,
HierarchyManager srcHierMgr,
Path nodePath)
Retrieves the state of the node at
nodePath using the given
item state manager. |
NodeState |
getNodeState(NodeId id)
Retrieves the state of the node with the given id.
|
NodeState |
getNodeState(Path nodePath)
Retrieves the state of the node at the given path.
|
PropertyState |
getPropertyState(PropertyId id)
Retrieves the state of the property with the given id.
|
NodeId |
move(Path srcPath,
Path destPath)
Moves the tree at
srcPath to the new location at
destPath . |
void |
removeNode(Path nodePath)
Removes the specified node, recursively removing its properties and
child nodes.
|
void |
removeNodeState(NodeState target)
Unlinks the specified node state from its parent and recursively
removes it including its properties and child nodes.
|
void |
store(ItemState state)
Store an item state.
|
void |
update()
End an update operation.
|
void |
verifyCanRead(Path nodePath)
Verifies that the node at
nodePath can be read. |
void |
verifyCanWrite(Path nodePath)
Verifies that the node at
nodePath is writable. |
protected void |
verifyCheckedOut(Path nodePath)
Verifies that the node at
nodePath is checked-out; throws a
VersionException if that's not the case. |
protected void |
verifyNotProtected(Path nodePath)
Verifies that the node at
nodePath is not protected. |
protected void |
verifyUnlocked(Path nodePath)
Verifies that the node at
nodePath is not locked by
somebody else than the current session. |
canModify, checkModify, checkRemove, findApplicableNodeDefinition, findApplicablePropertyDefinition, findApplicablePropertyDefinition, getEffectiveNodeType, performRelaxed, safeGetJCRPath, safeGetJCRPath, validate, validate
protected static final int COPY
protected static final int CLONE
protected static final int CLONE_REMOVE_EXISTING
protected final UpdatableItemStateManager stateMgr
protected final SessionImpl session
public BatchedItemOperations(UpdatableItemStateManager stateMgr, SessionContext sessionContext) throws RepositoryException
BatchedItemOperations
instance.stateMgr
- item state managersessionContext
- the session contextRepositoryException
public void edit() throws IllegalStateException
update()
or cancel()
must be invoked.IllegalStateException
- if the state manager is already in edit modepublic void store(ItemState state) throws IllegalStateException
state
- item state that should be storedIllegalStateException
- if the manager is not in edit mode.public void destroy(ItemState state) throws IllegalStateException
state
- item state that should be destroyedIllegalStateException
- if the manager is not in edit mode.public void update() throws RepositoryException, IllegalStateException
edit()
. If this operation fails,
no item will have been saved.RepositoryException
- if the update operation failedIllegalStateException
- if the state manager is not in edit modepublic void cancel() throws IllegalStateException
edit()
.IllegalStateException
- if the state manager is not in edit modepublic NodeId clone(Path srcPath, Path destPath) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException, IllegalStateException
srcAbsPath
in to the new
location at destAbsPath
. This operation is only supported:
mix:shareable
(or some
derived node type)destAbsPath
has not already a shareable
node in the same shared set as the node at srcPath
.srcPath
- source pathdestPath
- destination pathConstraintViolationException
- if the operation would violate a
node-type or other implementation-specific constraint.VersionException
- if the parent node of destAbsPath
is
versionable and checked-in, or is non-versionable but its nearest versionable ancestor is
checked-in. This exception will also be thrown if removeExisting
is true
,
and a UUID conflict occurs that would require the moving and/or altering of a node that is checked-in.AccessDeniedException
- if the current session does not have
sufficient access rights to complete the operation.PathNotFoundException
- if the node at srcAbsPath
in
srcWorkspace
or the parent of destAbsPath
in this workspace does not exist.ItemExistsException
- if a property already exists at
destAbsPath
or a node already exist there, and same name
siblings are not allowed or if removeExisting
is false and a
UUID conflict occurs.LockException
- if a lock prevents the clone.RepositoryException
- if the last element of destAbsPath
has an index or if another error occurs.IllegalStateException
public NodeId clone(NodeState srcState, NodeState destParentState, Name destName) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException, IllegalStateException
clone(Path, Path)
that has already determined
the affected NodeState
s.srcState
- source statedestParentState
- destination parent statedestName
- destination nameConstraintViolationException
- if the operation would violate a
node-type or other implementation-specific constraint.VersionException
- if the parent node of destAbsPath
is
versionable and checked-in, or is non-versionable but its nearest versionable ancestor is
checked-in. This exception will also be thrown if removeExisting
is true
,
and a UUID conflict occurs that would require the moving and/or altering of a node that is checked-in.AccessDeniedException
- if the current session does not have
sufficient access rights to complete the operation.PathNotFoundException
- if the node at srcAbsPath
in
srcWorkspace
or the parent of destAbsPath
in this workspace does not exist.ItemExistsException
- if a property already exists at
destAbsPath
or a node already exist there, and same name
siblings are not allowed or if removeExisting
is false and a
UUID conflict occurs.LockException
- if a lock prevents the clone.RepositoryException
- if the last element of destAbsPath
has an index or if another error occurs.IllegalStateException
clone(Path, Path)
public NodeId copy(Path srcPath, Path destPath, int flag) throws RepositoryException
srcPath
to the new location at
destPath
. Returns the id of the node at its new position.
Precondition: the state manager needs to be in edit mode.
srcPath
- destPath
- flag
- one of
COPY
CLONE
CLONE_REMOVE_EXISTING
RepositoryException
- if the copy operation failspublic NodeId copy(Path srcPath, ItemStateManager srcStateMgr, HierarchyManager srcHierMgr, AccessManager srcAccessMgr, Path destPath, int flag) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException, IllegalStateException
srcPath
retrieved using the specified
srcStateMgr
to the new location at destPath
.
Returns the id of the node at its new position.
Precondition: the state manager needs to be in edit mode.
srcPath
- srcStateMgr
- srcHierMgr
- srcAccessMgr
- destPath
- flag
- one of
COPY
CLONE
CLONE_REMOVE_EXISTING
ConstraintViolationException
AccessDeniedException
VersionException
PathNotFoundException
ItemExistsException
LockException
RepositoryException
IllegalStateException
- if the state manager is not in edit mode.public NodeId move(Path srcPath, Path destPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException, IllegalStateException
srcPath
to the new location at
destPath
. Returns the id of the moved node.
Precondition: the state manager needs to be in edit mode.
srcPath
- destPath
- ConstraintViolationException
VersionException
AccessDeniedException
PathNotFoundException
ItemExistsException
LockException
RepositoryException
IllegalStateException
- if the state manager is not in edit modepublic void removeNode(Path nodePath) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ReferentialIntegrityException, RepositoryException, IllegalStateException
Precondition: the state manager needs to be in edit mode.
public void checkAddNode(NodeState parentState, Name nodeName, Name nodeTypeName, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ItemExistsException, RepositoryException
nodeName
of node type
nodeTypeName
to the given parent node is allowed in the
current context.parentState
- nodeName
- nodeTypeName
- options
- bit-wise OR'ed flags specifying the checks that should be
performed; any combination of the following constants:
ItemValidator.CHECK_ACCESS
: make sure
current session is granted read & write access on
parent nodeItemValidator.CHECK_LOCK
: make sure
there's no foreign lock on parent nodeItemValidator.CHECK_CHECKED_OUT
: make sure
parent node is checked-outItemValidator.CHECK_CONSTRAINTS
:
make sure no node type constraints would be violatedItemValidator.CHECK_HOLD
: check for effective holds preventing the add operationItemValidator.CHECK_RETENTION
: check for effective retention policy preventing the add operationConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ItemExistsException
RepositoryException
public void checkRemoveNode(NodeState targetState, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ReferentialIntegrityException, RepositoryException
targetState
- options
- bit-wise OR'ed flags specifying the checks that should be
performed; any combination of the following constants:
ItemValidator.CHECK_ACCESS
: make sure
current session is granted read access on parent
and remove privilege on target nodeItemValidator.CHECK_LOCK
: make sure
there's no foreign lock on parent nodeItemValidator.CHECK_CHECKED_OUT
: make sure
parent node is checked-outItemValidator.CHECK_CONSTRAINTS
:
make sure no node type constraints would be violatedItemValidator.CHECK_REFERENCES
:
make sure no references exist on target nodeItemValidator.CHECK_HOLD
: check for effective holds preventing the add operationItemValidator.CHECK_RETENTION
: check for effective retention policy preventing the add operationConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ReferentialIntegrityException
RepositoryException
public void checkRemoveNode(NodeState targetState, NodeId parentId, int options) throws ConstraintViolationException, AccessDeniedException, VersionException, LockException, ItemNotFoundException, ReferentialIntegrityException, RepositoryException
targetState
- parentId
- options
- bit-wise OR'ed flags specifying the checks that should be
performed; any combination of the following constants:
ItemValidator.CHECK_ACCESS
: make sure
current session is granted read access on parent
and remove privilege on target nodeItemValidator.CHECK_LOCK
: make sure
there's no foreign lock on parent nodeItemValidator.CHECK_CHECKED_OUT
: make sure
parent node is checked-outItemValidator.CHECK_CONSTRAINTS
:
make sure no node type constraints would be violatedItemValidator.CHECK_REFERENCES
:
make sure no references exist on target nodeItemValidator.CHECK_HOLD
: check for effective holds preventing the add operationItemValidator.CHECK_RETENTION
: check for effective retention policy preventing the add operationConstraintViolationException
AccessDeniedException
VersionException
LockException
ItemNotFoundException
ReferentialIntegrityException
RepositoryException
public void verifyCanWrite(Path nodePath) throws PathNotFoundException, AccessDeniedException, ConstraintViolationException, VersionException, LockException, RepositoryException
nodePath
is writable. The
following conditions must hold true:
nodePath
- path of node to checkPathNotFoundException
- if no node exists at
nodePath
of the current
session is not granted read access
to the specified pathAccessDeniedException
- if write access to the specified
path is not allowedConstraintViolationException
- if the node at nodePath
is protectedVersionException
- if the node at nodePath
is checked-inLockException
- if the node at nodePath
is locked by another sessionRepositoryException
- if another error occurspublic void verifyCanRead(Path nodePath) throws PathNotFoundException, RepositoryException
nodePath
can be read. The
following conditions must hold true:
nodePath
- path of node to checkPathNotFoundException
- if no node exists at
nodePath
of the current
session is not granted read access
to the specified pathRepositoryException
- if another error occurspublic NodeState createNodeState(NodeState parent, Name nodeName, Name nodeTypeName, Name[] mixinNames, NodeId id) throws ItemExistsException, ConstraintViolationException, RepositoryException, IllegalStateException
Note that access rights are not enforced!
Precondition: the state manager needs to be in edit mode.
parent
- nodeName
- nodeTypeName
- mixinNames
- id
- ItemExistsException
ConstraintViolationException
RepositoryException
IllegalStateException
- if the state manager is not in edit mode.public NodeState createNodeState(NodeState parent, Name nodeName, Name nodeTypeName, Name[] mixinNames, NodeId id, QNodeDefinition def) throws ItemExistsException, ConstraintViolationException, RepositoryException, IllegalStateException
Note that access rights are not enforced!
Precondition: the state manager needs to be in edit mode.
parent
- nodeName
- nodeTypeName
- mixinNames
- id
- def
- ItemExistsException
ConstraintViolationException
RepositoryException
IllegalStateException
public PropertyState createPropertyState(NodeState parent, Name propName, int type, int numValues) throws ItemExistsException, ConstraintViolationException, RepositoryException, IllegalStateException
Note that access rights are not enforced!
Precondition: the state manager needs to be in edit mode.
parent
- propName
- type
- numValues
- ItemExistsException
ConstraintViolationException
RepositoryException
IllegalStateException
- if the state manager is not in edit modepublic PropertyState createPropertyState(NodeState parent, Name propName, int type, QPropertyDefinition def) throws ItemExistsException, RepositoryException
Note that access rights are not enforced!
Precondition: the state manager needs to be in edit mode.
parent
- propName
- type
- def
- ItemExistsException
RepositoryException
public void removeNodeState(NodeState target) throws RepositoryException
Note that no checks (access rights etc.) are performed on the specified target node state. Those checks have to be performed beforehand by the caller. However, the (recursive) removal of target node's child nodes are subject to the following checks: access rights, locking, versioning.
target
- RepositoryException
- if an error occurspublic NodeState getNodeState(Path nodePath) throws PathNotFoundException, RepositoryException
Note that access rights are not enforced!
nodePath
- PathNotFoundException
RepositoryException
public NodeState getNodeState(NodeId id) throws ItemNotFoundException, RepositoryException
Note that access rights are not enforced!
id
- ItemNotFoundException
RepositoryException
public PropertyState getPropertyState(PropertyId id) throws ItemNotFoundException, RepositoryException
Note that access rights are not enforced!
id
- ItemNotFoundException
RepositoryException
public ItemState getItemState(ItemId id) throws ItemNotFoundException, RepositoryException
Note that access rights are not enforced!
id
- ItemNotFoundException
RepositoryException
protected void verifyCheckedOut(Path nodePath) throws PathNotFoundException, VersionException, RepositoryException
nodePath
is checked-out; throws a
VersionException
if that's not the case.
A node is considered checked-out if it is versionable and checked-out, or is non-versionable but its nearest versionable ancestor is checked-out, or is non-versionable and there are no versionable ancestors.
nodePath
- PathNotFoundException
VersionException
RepositoryException
protected void verifyUnlocked(Path nodePath) throws LockException, RepositoryException
nodePath
is not locked by
somebody else than the current session.nodePath
- path of node to checkPathNotFoundException
LockException
- if write access to the specified path is not allowedRepositoryException
- if another error occursprotected void verifyNotProtected(Path nodePath) throws PathNotFoundException, ConstraintViolationException, RepositoryException
nodePath
is not protected.nodePath
- path of node to checkPathNotFoundException
- if no node exists at nodePath
ConstraintViolationException
- if write access to the specified
path is not allowedRepositoryException
- if another error occursprotected NodeState getNodeState(ItemStateManager srcStateMgr, HierarchyManager srcHierMgr, Path nodePath) throws PathNotFoundException, RepositoryException
nodePath
using the given
item state manager.
Note that access rights are not enforced!
srcStateMgr
- srcHierMgr
- nodePath
- PathNotFoundException
RepositoryException
protected ItemState getItemState(ItemStateManager srcStateMgr, ItemId id) throws ItemNotFoundException, RepositoryException
Note that access rights are not enforced!
srcStateMgr
- id
- ItemNotFoundException
RepositoryException
Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.