Package org.apache.jackrabbit.core

Examples of org.apache.jackrabbit.core.SessionImpl


         */
        public void loggingOut(SessionImpl session) {
            if (isLive()) {
                if (isSessionScoped()) {
                    // if no session currently holds lock, reassign
                    SessionImpl lockHolder = getLockHolder();
                    if (lockHolder == null) {
                        setLockHolder(session);
                    }
                    try {
                        NodeImpl node = (NodeImpl) session.getItemManager().getItem(getId());
                        node.unlock();
                    } catch (RepositoryException e) {
                        // Session is not allowed/able to unlock.
                        // Use system session present with lock-mgr as fallback
                        // in order to make sure, that session-scoped locks are
                        // properly cleaned.
                        SessionImpl systemSession = LockManagerImpl.this.sysSession;
                        setLockHolder(systemSession);
                        try {
                            NodeImpl node = (NodeImpl) systemSession.getItemManager().getItem(getId());
                            node.unlock();
                        } catch (RepositoryException re) {
                            log.warn("Unable to remove session-scoped lock on node '" + getLockToken() + "': " + e.getMessage());
                            log.debug("Root cause: ", e);
                        }
View Full Code Here


        }

        // create a new lock info for this node
        String lockOwner = (ownerInfo != null) ? ownerInfo : node.getSession().getUserID();
        info = new XALockInfo(node, isSessionScoped, isDeep, timeoutHint, lockOwner);
        SessionImpl session = (SessionImpl) node.getSession();
        info.setLockHolder(session);
        info.setLive(true);

        LockManagerImpl.getSessionLockManager(session).lockTokenAdded(info.getLockToken());
        lockedNodesMap.put(id, info);
View Full Code Here

         * association between update operation and session who actually invoked
         * the update, an internal event source is used.
         */
        public EventStateCollection createEventStateCollection()
                throws RepositoryException {
            SessionImpl session = source.get();
            if (session != null) {
                return createEventStateCollection(session);
            } else {
                throw new RepositoryException("Unknown event source.");
            }
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    public Version getLinearSuccessor() throws RepositoryException {
        // get base version. this can certainly be optimized
        SessionImpl session = sessionContext.getSessionImpl();
        InternalVersionHistory vh = ((VersionHistoryImpl) getContainingHistory())
                .getInternalVersionHistory();
        Node vn = session.getNodeById(vh.getVersionableId());
        InternalVersion base = ((VersionImpl) vn.getBaseVersion()).getInternalVersion();

        InternalVersion suc = getInternalVersion().getLinearSuccessor(base);
        return suc == null ? null : (Version) session.getNodeById(suc.getId());
    }
View Full Code Here

     *
     * @return array of columns.
     * @throws RepositoryException if an error occurs.
     */
    protected ColumnImpl[] getColumns() throws RepositoryException {
        SessionImpl session = sessionContext.getSessionImpl();
        QueryObjectModelFactory qomFactory =
            session.getWorkspace().getQueryManager().getQOMFactory();
        // get columns
        Map<Name, ColumnImpl> columns = new LinkedHashMap<Name, ColumnImpl>();
        for (Name name : root.getSelectProperties()) {
            String pn = sessionContext.getJCRName(name);
            ColumnImpl col = (ColumnImpl) qomFactory.column(
                    sessionContext.getJCRName(DEFAULT_SELECTOR_NAME), pn, pn);
            columns.put(name, col);
        }
        if (columns.size() == 0) {
            // use node type constraint
            LocationStepQueryNode[] steps = root.getLocationNode().getPathSteps();
            final Name[] ntName = new Name[1];
            steps[steps.length - 1].acceptOperands(new DefaultQueryNodeVisitor() {

                public Object visit(AndQueryNode node, Object data) throws RepositoryException {
                    return node.acceptOperands(this, data);
                }

                public Object visit(NodeTypeQueryNode node, Object data) {
                    ntName[0] = node.getValue();
                    return data;
                }
            }, null);
            if (ntName[0] == null) {
                ntName[0] = NameConstants.NT_BASE;
            }
            NodeTypeImpl nt = session.getNodeTypeManager().getNodeType(ntName[0]);
            PropertyDefinition[] propDefs = nt.getPropertyDefinitions();
            for (PropertyDefinition pd : propDefs) {
                QPropertyDefinition propDef = ((PropertyDefinitionImpl) pd).unwrap();
                if (!propDef.definesResidual() && !propDef.isMultiple()) {
                    columns.put(propDef.getName(), columnForName(propDef.getName()));
View Full Code Here

        }

        // create a new lock info for this node
        String lockOwner = (ownerInfo != null) ? ownerInfo : node.getSession().getUserID();
        info = new XALockInfo(node, isSessionScoped, isDeep, timeoutHint, lockOwner);
        SessionImpl session = (SessionImpl) node.getSession();
        info.setLockHolder(session);
        info.setLive(true);

        LockManagerImpl.getSessionLockManager(session).lockTokenAdded(info.getLockToken());
        lockedNodesMap.put(id, info);
View Full Code Here

                    "Session does not hold lock.",
                    (SessionImpl) node.getSession());
        } else {
            // make sure the current session has sufficient privileges to refresh
            // the lock.
            SessionImpl session = (SessionImpl) node.getSession();
            session.getAccessManager().checkPermission(
                    node.getPrimaryPath(), Permission.LOCK_MNGMT);

            // Update the lock timeout
            info.updateTimeoutTime();
        }
View Full Code Here

            lockMap.traverse(new PathMap.ElementVisitor<LockInfo>() {
                public void elementVisited(PathMap.Element<LockInfo> element) {
                    LockInfo info = element.get();
                    if (info != null && info.isLive() && info.isExpired()) {
                        NodeId id = info.getId();
                        SessionImpl holder = info.getLockHolder();
                        if (holder == null) {
                            info.setLockHolder(sysSession);
                            holder = sysSession;
                        }
                        try {
                            // FIXME: This session access is not thread-safe!
                            unlock(holder.getNodeById(id));
                        } catch (RepositoryException e) {
                            log.warn("Unable to expire the lock " + id, e);
                        }
                    }
                }
View Full Code Here

         */
        public void loggingOut(SessionImpl session) {
            if (isLive()) {
                if (isSessionScoped()) {
                    // if no session currently holds lock, reassign
                    SessionImpl lockHolder = getLockHolder();
                    if (lockHolder == null) {
                        setLockHolder(session);
                    }
                    try {
                        NodeImpl node = (NodeImpl) session.getItemManager().getItem(getId());
                        node.unlock();
                    } catch (RepositoryException e) {
                        // Session is not allowed/able to unlock.
                        // Use system session present with lock-mgr as fallback
                        // in order to make sure, that session-scoped locks are
                        // properly cleaned.
                        SessionImpl systemSession = LockManagerImpl.this.sysSession;
                        setLockHolder(systemSession);
                        try {
                            NodeImpl node = (NodeImpl) systemSession.getItemManager().getItem(getId());
                            node.unlock();
                        } catch (RepositoryException re) {
                            log.warn("Unable to remove session-scoped lock on node '" + getLockToken() + "': " + e.getMessage());
                            log.debug("Root cause: ", e);
                        }
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.