Search in sources :

Example 16 with Operation

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);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 17 with Operation

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);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 18 with Operation

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);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 19 with Operation

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);
}
Also used : EffectiveNodeType(org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType) NodeTypeImpl(org.apache.jackrabbit.jcr2spi.nodetype.NodeTypeImpl) PropertyIterator(javax.jcr.PropertyIterator) ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) Name(org.apache.jackrabbit.spi.Name) NoSuchNodeTypeException(javax.jcr.nodetype.NoSuchNodeTypeException)

Example 20 with Operation

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());
}
Also used : ItemState(org.apache.jackrabbit.jcr2spi.state.ItemState) AddNode(org.apache.jackrabbit.jcr2spi.operation.AddNode) Node(javax.jcr.Node) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) QNodeDefinition(org.apache.jackrabbit.spi.QNodeDefinition) AddNode(org.apache.jackrabbit.jcr2spi.operation.AddNode)

Aggregations

Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)32 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)6 Path (org.apache.jackrabbit.spi.Path)6 Name (org.apache.jackrabbit.spi.Name)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 RepositoryException (javax.jcr.RepositoryException)4 AddNode (org.apache.jackrabbit.jcr2spi.operation.AddNode)3 NodeState (org.apache.jackrabbit.jcr2spi.state.NodeState)3 PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)3 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)3 ItemExistsException (javax.jcr.ItemExistsException)2 HierarchyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)2 EffectiveNodeType (org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeType)2 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)2 QValue (org.apache.jackrabbit.spi.QValue)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 InvalidItemStateException (javax.jcr.InvalidItemStateException)1 Node (javax.jcr.Node)1