Package org.apache.jackrabbit.core.cluster

Examples of org.apache.jackrabbit.core.cluster.ClusterOperation


        SessionImpl session = (SessionImpl) node.getSession();
        String lockOwner = (ownerInfo != null) ? ownerInfo : session.getUserID();
        LockInfo info = new LockInfo(new LockToken(node.getNodeId()),
                isSessionScoped, isDeep, lockOwner, timeoutHint);

        ClusterOperation operation = null;
        boolean successful = false;

        // Cluster is only informed about open-scoped locks
        if (eventChannel != null && !isSessionScoped) {
            operation = eventChannel.create(node.getNodeId(), isDeep, lockOwner);
        }

        acquire();

        try {
            // check whether node is already locked
            Path path = getPath(session, node.getId());
            PathMap.Element element = lockMap.map(path, false);

            LockInfo other = (LockInfo) element.get();
            if (other != null) {
                if (element.hasPath(path)) {
                    throw new LockException("Node already locked: " + node);
                } else if (other.deep) {
                    throw new LockException(
                            "Parent node has a deep lock: " + node);
                }
            }
            if (info.deep && element.hasPath(path)
                    && element.getChildrenCount() > 0) {
                throw new LockException("Some child node is locked.");
            }

            // create lock token
            info.setLockHolder(session);
            info.setLive(true);
            session.addListener(info);
            if (!info.isSessionScoped()) {
                getSessionLockManager(session).lockTokenAdded(info.lockToken.toString());
            }
            lockMap.put(path, info);

            if (!info.sessionScoped) {
                save();
                successful = true;
            }
            return info;

        } finally {
            release();
            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here


     * @throws RepositoryException if another error occurs
     */
    boolean internalUnlock(NodeImpl node)
            throws LockException, RepositoryException {

        ClusterOperation operation = null;
        boolean successful = false;

        if (eventChannel != null) {
            operation = eventChannel.create(node.getNodeId());
        }

        acquire();

        try {
            SessionImpl session = (SessionImpl) node.getSession();
            // check whether node is locked by this session
            PathMap.Element element = lockMap.map(getPath(session, node.getId()), true);
            if (element == null) {
                throw new LockException("Node not locked: " + node);
            }
            AbstractLockInfo info = (AbstractLockInfo) element.get();
            if (info == null) {
                throw new LockException("Node not locked: " + node);
            }
            if (session != info.getLockHolder()) {
                throw new LockException("Node not locked by session: " + node);
            }

            getSessionLockManager(session).lockTokenRemoved(info.getLockToken(session));
           
            element.set(null);
            info.setLive(false);

            if (!info.sessionScoped) {
                save();
                successful = true;
            }
            return true;
        } finally {
            release();

            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

        SessionImpl session = (SessionImpl) node.getSession();
        String lockOwner = (ownerInfo != null) ? ownerInfo : session.getUserID();
        InternalLockInfo info = new InternalLockInfo(
                node.getNodeId(), isSessionScoped, isDeep, lockOwner, timeoutHint);

        ClusterOperation operation = null;
        boolean successful = false;

        // Cluster is only informed about open-scoped locks
        if (eventChannel != null && !isSessionScoped) {
            operation = eventChannel.create(node.getNodeId(), isDeep, lockOwner);
        }

        acquire();

        try {
            // check whether node is already locked
            Path path = getPath(session, node.getId());
            PathMap.Element<LockInfo> element = lockMap.map(path, false);

            LockInfo other = element.get();
            if (other != null) {
                if (element.hasPath(path)) {
                    other.throwLockException(
                            "Node already locked: " + node, session);
                } else if (other.isDeep()) {
                    other.throwLockException(
                            "Parent node has a deep lock: " + node, session);
                }
            }
            if (info.isDeep() && element.hasPath(path)
                    && element.getChildrenCount() > 0) {
                info.throwLockException("Some child node is locked", session);
            }

            // create lock token
            info.setLockHolder(session);
            info.setLive(true);
            session.addListener(info);
            if (!info.isSessionScoped()) {
                getSessionLockManager(session).lockTokenAdded(info.getLockToken());
            }
            lockMap.put(path, info);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return info;

        } finally {
            release();
            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

     * @throws RepositoryException if another error occurs
     */
    boolean internalUnlock(NodeImpl node)
            throws LockException, RepositoryException {

        ClusterOperation operation = null;
        boolean successful = false;

        if (eventChannel != null) {
            operation = eventChannel.create(node.getNodeId());
        }

        acquire();

        try {
            SessionImpl session = (SessionImpl) node.getSession();
            // check whether node is locked by this session
            PathMap.Element<LockInfo> element =
                lockMap.map(getPath(session, node.getId()), true);
            if (element == null) {
                throw new LockException("Node not locked: " + node);
            }
            LockInfo info = element.get();
            if (info == null) {
                throw new LockException("Node not locked: " + node);
            }
            checkUnlock(info, session);

            getSessionLockManager(session).lockTokenRemoved(info.getLockToken());

            element.set(null);
            info.setLive(false);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return true;
        } finally {
            release();

            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

        SessionImpl session = (SessionImpl) node.getSession();
        String lockOwner = (ownerInfo != null) ? ownerInfo : session.getUserID();
        InternalLockInfo info = new InternalLockInfo(new LockToken(node.getNodeId()),
                isSessionScoped, isDeep, lockOwner, timeoutHint);

        ClusterOperation operation = null;
        boolean successful = false;

        // Cluster is only informed about open-scoped locks
        if (eventChannel != null && !isSessionScoped) {
            operation = eventChannel.create(node.getNodeId(), isDeep, lockOwner);
        }

        acquire();

        try {
            // check whether node is already locked
            Path path = getPath(session, node.getId());
            PathMap.Element element = lockMap.map(path, false);

            LockInfo other = (LockInfo) element.get();
            if (other != null) {
                if (element.hasPath(path)) {
                    throw new LockException("Node already locked: " + node);
                } else if (other.isDeep()) {
                    throw new LockException(
                            "Parent node has a deep lock: " + node);
                }
            }
            if (info.deep && element.hasPath(path)
                    && element.getChildrenCount() > 0) {
                throw new LockException("Some child node is locked.");
            }

            // create lock token
            info.setLockHolder(session);
            info.setLive(true);
            session.addListener(info);
            if (!info.isSessionScoped()) {
                getSessionLockManager(session).lockTokenAdded(info.getLockToken());
            }
            lockMap.put(path, info);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return info;

        } finally {
            release();
            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

     * @throws RepositoryException if another error occurs
     */
    boolean internalUnlock(NodeImpl node)
            throws LockException, RepositoryException {

        ClusterOperation operation = null;
        boolean successful = false;

        if (eventChannel != null) {
            operation = eventChannel.create(node.getNodeId());
        }

        acquire();

        try {
            SessionImpl session = (SessionImpl) node.getSession();
            // check whether node is locked by this session
            PathMap.Element element = lockMap.map(getPath(session, node.getId()), true);
            if (element == null) {
                throw new LockException("Node not locked: " + node);
            }
            AbstractLockInfo info = (AbstractLockInfo) element.get();
            if (info == null) {
                throw new LockException("Node not locked: " + node);
            }
            checkUnlock(info, session);

            getSessionLockManager(session).lockTokenRemoved(info.getLockToken(session));

            element.set(null);
            info.setLive(false);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return true;
        } finally {
            release();

            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

        SessionImpl session = (SessionImpl) node.getSession();
        String lockOwner = (ownerInfo != null) ? ownerInfo : session.getUserID();
        InternalLockInfo info = new InternalLockInfo(
                node.getNodeId(), isSessionScoped, isDeep, lockOwner, timeoutHint);

        ClusterOperation operation = null;
        boolean successful = false;

        // Cluster is only informed about open-scoped locks
        if (eventChannel != null && !isSessionScoped) {
            operation = eventChannel.create(node.getNodeId(), isDeep, lockOwner);
        }

        acquire();

        try {
            // check whether node is already locked
            Path path = getPath(session, node.getId());
            PathMap.Element<LockInfo> element = lockMap.map(path, false);

            LockInfo other = element.get();
            if (other != null) {
                if (element.hasPath(path)) {
                    other.throwLockException(
                            "Node already locked: " + node, session);
                } else if (other.isDeep()) {
                    other.throwLockException(
                            "Parent node has a deep lock: " + node, session);
                }
            }
            if (info.isDeep() && element.hasPath(path)
                    && element.getChildrenCount() > 0) {
                info.throwLockException("Some child node is locked", session);
            }

            // create lock token
            info.setLockHolder(session);
            info.setLive(true);
            session.addListener(info);
            if (!info.isSessionScoped()) {
                getSessionLockManager(session).lockTokenAdded(info.getLockToken());
            }
            lockMap.put(path, info);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return info;

        } finally {
            release();
            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

     * @throws RepositoryException if another error occurs
     */
    boolean internalUnlock(NodeImpl node)
            throws LockException, RepositoryException {

        ClusterOperation operation = null;
        boolean successful = false;

        if (eventChannel != null) {
            operation = eventChannel.create(node.getNodeId());
        }

        acquire();

        try {
            SessionImpl session = (SessionImpl) node.getSession();
            // check whether node is locked by this session
            PathMap.Element<LockInfo> element =
                lockMap.map(getPath(session, node.getId()), true);
            if (element == null) {
                throw new LockException("Node not locked: " + node);
            }
            LockInfo info = element.get();
            if (info == null) {
                throw new LockException("Node not locked: " + node);
            }
            checkUnlock(info, session);

            getSessionLockManager(session).lockTokenRemoved(info.getLockToken());

            element.set(null);
            info.setLive(false);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return true;
        } finally {
            release();

            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

        SessionImpl session = (SessionImpl) node.getSession();
        String lockOwner = (ownerInfo != null) ? ownerInfo : session.getUserID();
        InternalLockInfo info = new InternalLockInfo(
                node.getNodeId(), isSessionScoped, isDeep, lockOwner, timeoutHint);

        ClusterOperation operation = null;
        boolean successful = false;

        // Cluster is only informed about open-scoped locks
        if (eventChannel != null && !isSessionScoped) {
            operation = eventChannel.create(node.getNodeId(), isDeep, lockOwner);
        }

        acquire();

        try {
            // check whether node is already locked
            Path path = getPath(session, node.getId());
            PathMap.Element<LockInfo> element = lockMap.map(path, false);

            LockInfo other = element.get();
            if (other != null) {
                if (element.hasPath(path)) {
                    other.throwLockException(
                            "Node already locked: " + node, session);
                } else if (other.isDeep()) {
                    other.throwLockException(
                            "Parent node has a deep lock: " + node, session);
                }
            }
            if (info.isDeep() && element.hasPath(path)
                    && element.getChildrenCount() > 0) {
                info.throwLockException("Some child node is locked", session);
            }

            // create lock token
            info.setLockHolder(session);
            info.setLive(true);
            session.addListener(info);
            if (!info.isSessionScoped()) {
                getSessionLockManager(session).lockTokenAdded(info.getLockToken());
            }
            lockMap.put(path, info);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return info;

        } finally {
            release();
            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

     * @throws RepositoryException if another error occurs
     */
    boolean internalUnlock(NodeImpl node)
            throws LockException, RepositoryException {

        ClusterOperation operation = null;
        boolean successful = false;

        if (eventChannel != null) {
            operation = eventChannel.create(node.getNodeId());
        }

        acquire();

        try {
            SessionImpl session = (SessionImpl) node.getSession();
            // check whether node is locked by this session
            PathMap.Element<LockInfo> element =
                lockMap.map(getPath(session, node.getId()), true);
            if (element == null) {
                throw new LockException("Node not locked: " + node);
            }
            LockInfo info = element.get();
            if (info == null) {
                throw new LockException("Node not locked: " + node);
            }
            checkUnlock(info, session);

            getSessionLockManager(session).lockTokenRemoved(info.getLockToken());

            element.set(null);
            info.setLive(false);

            if (!info.isSessionScoped()) {
                save();
                successful = true;
            }
            return true;
        } finally {
            release();

            if (operation != null) {
                operation.ended(successful);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.cluster.ClusterOperation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.