Search in sources :

Example 1 with Operation

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

the class LockManagerImpl method unlock.

/**
     * @see LockStateManager#unlock(NodeState)
     */
public void unlock(NodeState nodeState) throws LockException, RepositoryException {
    // execute the operation. Note, that its possible that the session is
    // lock holder and still the lock was never accessed. thus the lockMap
    // does not provide sufficient and reliable information.
    Operation op = LockRelease.create(nodeState);
    wspManager.execute(op);
    // added to the map.
    if (lockMap.containsKey(nodeState)) {
        LockImpl l = lockMap.remove(nodeState);
        l.lockState.unlocked();
    }
}
Also used : Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) LockOperation(org.apache.jackrabbit.jcr2spi.operation.LockOperation)

Example 2 with Operation

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

the class SessionImpl method move.

/**
     * @see javax.jcr.Session#move(String, String)
     */
public void move(String srcAbsPath, String destAbsPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException {
    checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
    checkIsAlive();
    // build paths from the given JCR paths.
    Path srcPath = getQPath(srcAbsPath);
    Path destPath = getQPath(destAbsPath);
    // all validation is performed by Move Operation and state-manager
    Operation op = Move.create(srcPath, destPath, getHierarchyManager(), getPathResolver(), true);
    itemStateManager.execute(op);
}
Also used : Path(org.apache.jackrabbit.spi.Path) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 3 with Operation

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

the class WorkspaceImpl method clone.

/**
     * @see javax.jcr.Workspace#clone(String, String, String, boolean)
     */
public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean removeExisting) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    session.checkSupportedOption(Repository.LEVEL_2_SUPPORTED);
    session.checkIsAlive();
    // check workspace name
    if (getName().equals(srcWorkspace)) {
        // same as current workspace
        String msg = srcWorkspace + ": illegal workspace (same as current)";
        log.debug(msg);
        throw new RepositoryException(msg);
    }
    // make sure the specified workspace is visible for the current session.
    session.checkAccessibleWorkspace(srcWorkspace);
    Path srcPath = session.getQPath(srcAbsPath);
    Path destPath = session.getQPath(destAbsPath);
    // clone (i.e. pull) subtree at srcAbsPath from srcWorkspace
    // to 'this' workspace at destAbsPath
    SessionImpl srcSession = null;
    try {
        // create session on other workspace for current subject
        // (may throw NoSuchWorkspaceException and AccessDeniedException)
        srcSession = session.switchWorkspace(srcWorkspace);
        WorkspaceImpl srcWsp = (WorkspaceImpl) srcSession.getWorkspace();
        // do clone
        Operation op = Clone.create(srcPath, destPath, srcWsp.getName(), removeExisting, srcWsp, this);
        getUpdatableItemStateManager().execute(op);
    } finally {
        if (srcSession != null) {
            // we don't need the other session anymore, logout
            srcSession.logout();
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) RepositoryException(javax.jcr.RepositoryException) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation)

Example 4 with Operation

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

the class NodeImpl method addMixin.

/**
     * @see Node#addMixin(String)
     */
public void addMixin(String mixinName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException {
    checkIsWritable();
    Name mixinQName = getQName(mixinName);
    // get mixin types present in the jcr:mixinTypes property without
    // modifying the NodeState.
    List<Name> mixinValue = getMixinTypes();
    if (!mixinValue.contains(mixinQName) && !isNodeType(mixinQName)) {
        if (!canAddMixin(mixinQName)) {
            throw new ConstraintViolationException("Cannot add '" + mixinName + "' mixin type.");
        }
        mixinValue.add(mixinQName);
        // perform the operation
        Operation op = SetMixin.create(getNodeState(), mixinValue.toArray(new Name[mixinValue.size()]));
        session.getSessionItemStateManager().execute(op);
    }
}
Also used : ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) Name(org.apache.jackrabbit.spi.Name)

Example 5 with Operation

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

the class NodeImpl method orderBefore.

/**
     * @see Node#orderBefore(String, String)
     */
public synchronized void orderBefore(String srcChildRelPath, String destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException {
    checkIsWritable();
    if (!getPrimaryNodeType().hasOrderableChildNodes()) {
        throw new UnsupportedRepositoryOperationException("Child node ordering not supported on node " + safeGetJCRPath());
    }
    // check arguments
    if (srcChildRelPath.equals(destChildRelPath)) {
        // there's nothing to do
        return;
    }
    // check existence
    if (!hasNode(srcChildRelPath)) {
        throw new ItemNotFoundException("Node " + safeGetJCRPath() + " has no child node with name " + srcChildRelPath);
    }
    if (destChildRelPath != null && !hasNode(destChildRelPath)) {
        throw new ItemNotFoundException("Node " + safeGetJCRPath() + " has no child node with name " + destChildRelPath);
    }
    Path srcPath = getReorderPath(srcChildRelPath);
    Path beforePath = null;
    if (destChildRelPath != null) {
        beforePath = getReorderPath(destChildRelPath);
    }
    Operation op = ReorderNodes.create(getNodeState(), srcPath, beforePath);
    session.getSessionItemStateManager().execute(op);
}
Also used : Path(org.apache.jackrabbit.spi.Path) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) ItemNotFoundException(javax.jcr.ItemNotFoundException)

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