Search in sources :

Example 11 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class AccessControlManagerImpl method setMixin.

private void setMixin(NodeState parent, Name mixinName) throws RepositoryException {
    if (!isNodeType(parent, mixinName)) {
        Operation sm = SetMixin.create(parent, new Name[] { mixinName });
        itemStateMgr.execute(sm);
    } else {
        log.debug(mixinName.toString() + " is already present on the given node state " + parent.getName().toString());
    }
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 12 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class AccessControlManagerImpl method addNode.

private NodeState addNode(SetTree treeOperation, NodeState parent, Name nodeName, String uuid, Name nodeTypeName) throws RepositoryException {
    Operation sp = treeOperation.addChildNode(parent, nodeName, nodeTypeName, uuid);
    itemStateMgr.execute(sp);
    return (NodeState) ((AddNode) sp).getAddedStates().get(0);
}
Also used : NodeState(org.apache.jackrabbit.jcr2spi.state.NodeState) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) AddNode(org.apache.jackrabbit.jcr2spi.operation.AddNode)

Example 13 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class ChangeLog method persisted.

//-----------------------------------------------< Inform the ChangeLog >---
/**
     * Call this method when this change log has been successfully persisted.
     * This implementation will call {@link Operation#persisted()} on the
     * individual operations followed by setting all remaining modified
     * states to EXISTING.
     */
public void persisted() throws RepositoryException {
    List<NodeState> changedMixins = new ArrayList<NodeState>();
    List<NodeState> changedPrimaryTypes = new ArrayList<NodeState>();
    Operation[] ops = operations.toArray(new Operation[operations.size()]);
    for (int i = 0; i < ops.length; i++) {
        ops[i].persisted();
        if (ops[i] instanceof SetMixin) {
            changedMixins.add(((SetMixin) ops[i]).getNodeState());
        } else if (ops[i] instanceof SetPrimaryType) {
            changedPrimaryTypes.add(((SetPrimaryType) ops[i]).getNodeState());
        }
    }
    // operation persistence.
    for (ItemState state : affectedStates) {
        HierarchyEntry he = state.getHierarchyEntry();
        switch(state.getStatus()) {
            case Status.EXISTING_MODIFIED:
                state.setStatus(Status.EXISTING);
                if (state.isNode()) {
                    if (changedPrimaryTypes.contains(state)) {
                        // primary type changed for a node -> force reloading upon next
                        // access in order to be aware of modified definition etc...
                        he.invalidate(true);
                    } else if (changedMixins.contains(state)) {
                        // mixin changed for a node -> force reloading upon next
                        // access in order to be aware of modified uniqueID.
                        he.invalidate(false);
                    }
                }
                break;
            case Status.EXISTING_REMOVED:
                he.remove();
                break;
            case Status.NEW:
                // illegal. should not get here.
                log.error("ChangeLog still contains NEW state: " + state.getName());
                state.setStatus(Status.EXISTING);
                break;
            case Status.MODIFIED:
            case Status._UNDEFINED_:
            case Status.STALE_DESTROYED:
            case Status.STALE_MODIFIED:
                // illegal.
                log.error("ChangeLog contains state (" + state.getName() + ") with illegal status " + Status.getName(state.getStatus()));
                break;
            case Status.EXISTING:
                if (state.isNode() && changedMixins.contains(state)) {
                    // mixin changed for a node -> force reloading upon next
                    // access in order to be aware of modified uniqueID.
                    he.invalidate(false);
                }
                // otherwise: ignore. operations already have been completed
                break;
            case Status.INVALIDATED:
            case Status.REMOVED:
                he.invalidate(false);
                break;
        }
    }
}
Also used : SetPrimaryType(org.apache.jackrabbit.jcr2spi.operation.SetPrimaryType) ArrayList(java.util.ArrayList) SetMixin(org.apache.jackrabbit.jcr2spi.operation.SetMixin) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) HierarchyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.HierarchyEntry)

Example 14 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class VersionManagerImpl method restore.

public void restore(NodeState nodeState, Path relativePath, NodeState versionState, boolean removeExisting) throws RepositoryException {
    Operation op = Restore.create(nodeState, relativePath, versionState, removeExisting);
    workspaceManager.execute(op);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 15 with Operation

use of org.apache.jackrabbit.jcr2spi.operation.Operation in project jackrabbit by apache.

the class VersionManagerImpl method checkout.

public void checkout(NodeState nodeState) throws RepositoryException {
    Operation co = Checkout.create(nodeState, this);
    workspaceManager.execute(co);
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

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