Package org.apache.jackrabbit.core

Examples of org.apache.jackrabbit.core.SessionImpl


     * @throws RepositoryException
     */
    protected void removeLockProperties(NodeImpl node) throws RepositoryException {
        boolean success = false;

        SessionImpl editingSession = (SessionImpl) node.getSession();
        WorkspaceImpl wsp = (WorkspaceImpl) editingSession.getWorkspace();
        UpdatableItemStateManager stateMgr = wsp.getItemStateManager();

        synchronized (stateMgr) {
            try {
                // add properties to content
View Full Code Here


        }
        super.cleanUp();
    }

    private Set<Principal> getAnonymousPrincipals() throws RepositoryException {
        SessionImpl s = ((SessionImpl) getHelper().getRepository().login(new SimpleCredentials(SecurityConstants.ANONYMOUS_ID, "".toCharArray())));
        try {
            return new HashSet<Principal>(s.getSubject().getPrincipals());
        } finally {
            s.logout();
        }
    }
View Full Code Here

     * @return internal version history
     * @throws RepositoryException if the internal version history is not available
     */
    protected InternalVersionHistory getInternalVersionHistory()
            throws RepositoryException {
        SessionImpl session = sessionContext.getSessionImpl();
        InternalVersionHistory history =
                session.getInternalVersionManager().getVersionHistory((NodeId) id);
        if (history == null) {
            throw new InvalidItemStateException(id + ": the item does not exist anymore");
        }
        return history;
    }
View Full Code Here

    /**
     * @see javax.jcr.version.VersionHistory#getRootVersion()
     */
    public javax.jcr.version.Version getRootVersion() throws RepositoryException {
        SessionImpl session = sessionContext.getSessionImpl();
        return (Version) session.getNodeById(
                getInternalVersionHistory().getRootVersion().getId());
    }
View Full Code Here

     * @see VersionHistory#getAllLinearVersions()
     */
    @SuppressWarnings("deprecation")
    public VersionIterator getAllLinearVersions() throws RepositoryException {
        // get base version. this can certainly be optimized
        SessionImpl session = sessionContext.getSessionImpl();
        InternalVersionHistory vh = getInternalVersionHistory();
        Node vn = session.getNodeById(vh.getVersionableId());
        InternalVersion base = ((VersionImpl) vn.getBaseVersion()).getInternalVersion();

        return new VersionIteratorImpl(getSession(), vh.getRootVersion(), base);
    }
View Full Code Here

        }

        // create a new lock info for this node
        info = new LockInfo(node, new LockToken(id),
                isSessionScoped, isDeep, node.getSession().getUserID());
        SessionImpl session = (SessionImpl) node.getSession();
        info.setLockHolder(session);
        info.setLive(true);
        session.addLockToken(info.lockToken.toString(), false);
        lockedNodesMap.put(id, info);
        operations.add(info);

        return info;
    }
View Full Code Here

            info = lockMgr.getLockInfo(node.getNodeId());
        }
        if (info == null) {
            throw new LockException("Node not locked: " + node.safeGetJCRPath());
        }
        SessionImpl session = (SessionImpl) node.getSession();
        NodeImpl holder = (NodeImpl) session.getItemManager().getItem(info.getId());
        return new XALock(this, info, holder);
    }
View Full Code Here

     * {@inheritDoc}
     */
    public void checkLock(Path path, Session session)
            throws LockException, RepositoryException {

        SessionImpl sessionImpl = (SessionImpl) session;
        checkLock((NodeImpl) sessionImpl.getItemManager().getItem(path));
    }
View Full Code Here

     * @throws RepositoryException if another error occurs
     */
    AbstractLockInfo internalLock(NodeImpl node, boolean isDeep, boolean isSessionScoped)
            throws LockException, RepositoryException {

        SessionImpl session = (SessionImpl) node.getSession();
        LockInfo info = new LockInfo(new LockToken(node.getNodeId()),
                isSessionScoped, isDeep, session.getUserID());

        acquire();

        try {
            // check whether node is already locked
            Path path = getPath(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.safeGetJCRPath());
                } else if (other.deep) {
                    throw new LockException("Parent node has deep lock.");
                }
            }
            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);
            session.addLockToken(info.lockToken.toString(), false);
            lockMap.put(path, info);

            if (!info.sessionScoped) {
                save();
            }
View Full Code Here

            throws LockException, RepositoryException {

        acquire();

        try {
            SessionImpl session = (SessionImpl) node.getSession();

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

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

            if (!info.sessionScoped) {
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.SessionImpl

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.