use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.
the class VersionManagerImpl method removeVersionLabel.
public void removeVersionLabel(NodeState versionHistoryState, NodeState versionState, Name qLabel) throws RepositoryException {
Operation op = RemoveLabel.create(versionHistoryState, versionState, qLabel);
workspaceManager.execute(op);
}
use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.
the class VersionManagerImpl method restore.
public void restore(NodeState[] versionStates, boolean removeExisting) throws RepositoryException {
Operation op = Restore.create(versionStates, removeExisting);
workspaceManager.execute(op);
}
use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.
the class AccessControlManagerImpl method removeNode.
private void removeNode(NodeState aclNode) throws RepositoryException {
Operation removePolicy = Remove.create(aclNode, REMOVE_POLICY_OPTIONS);
itemStateMgr.execute(removePolicy);
}
use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.
the class NodeImpl method removeMixin.
/**
* @see Node#removeMixin(String)
*/
public void removeMixin(String mixinName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException {
checkIsWritable();
Name ntName = getQName(mixinName);
List<Name> mixinValue = getMixinTypes();
// remove name of target mixin
if (!mixinValue.remove(ntName)) {
throw new NoSuchNodeTypeException("Cannot remove mixin '" + mixinName + "': Nodetype is not present on this node.");
}
// mix:referenceable needs additional assertion: the mixin cannot be
// removed, if any references are left to this node.
NodeTypeImpl mixin = session.getNodeTypeManager().getNodeType(ntName);
if (mixin.isNodeType(NameConstants.MIX_REFERENCEABLE)) {
EffectiveNodeType entRemaining = getRemainingENT(mixinValue);
if (!entRemaining.includesNodeType(NameConstants.MIX_REFERENCEABLE)) {
PropertyIterator iter = getReferences();
if (iter.hasNext()) {
throw new ConstraintViolationException("Mixin type " + mixinName + " can not be removed: the node is being referenced through at least one property of type REFERENCE");
}
}
}
/*
* mix:lockable: the mixin cannot be removed if the node is currently
* locked even if the editing session is the lock holder.
*/
if (mixin.isNodeType((NameConstants.MIX_LOCKABLE))) {
EffectiveNodeType entRemaining = getRemainingENT(mixinValue);
if (!entRemaining.includesNodeType(NameConstants.MIX_LOCKABLE) && isLocked()) {
throw new ConstraintViolationException(mixinName + " can not be removed: the node is locked.");
}
}
// delegate to operation
Name[] mixins = mixinValue.toArray(new Name[mixinValue.size()]);
Operation op = SetMixin.create(getNodeState(), mixins);
session.getSessionItemStateManager().execute(op);
}
use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.
the class NodeImpl method createNode.
//---------------------------------------------< private implementation >---
/**
* Create a new <code>NodeState</code> and subsequently retrieves the
* corresponding <code>Node</code> object.
*
* @param nodeName name of the new node
* @param nodeTypeName name of the new node's node type or <code>null</code>
* if it should be determined automatically
* @return the newly added node
* @throws ItemExistsException
* @throws NoSuchNodeTypeException
* @throws VersionException
* @throws ConstraintViolationException
* @throws LockException
* @throws RepositoryException
*/
private synchronized Node createNode(Name nodeName, Name nodeTypeName) throws ItemExistsException, NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException {
QNodeDefinition definition = session.getItemDefinitionProvider().getQNodeDefinition(getNodeState().getAllNodeTypeNames(), nodeName, nodeTypeName);
if (nodeTypeName == null) {
// use default node type
nodeTypeName = definition.getDefaultPrimaryType();
}
// validation check are performed by item state manager
// NOTE: uuid is generated while creating new state.
Operation an = AddNode.create(getNodeState(), nodeName, nodeTypeName, null);
session.getSessionItemStateManager().execute(an);
// finally retrieve the new node
List<ItemState> addedStates = ((AddNode) an).getAddedStates();
ItemState nState = addedStates.get(0);
return (Node) getItemManager().getItem(nState.getHierarchyEntry());
}
Aggregations