Search in sources :

Example 16 with Path

use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.

the class LockManagerImpl method externalLock.

/**
     * {@inheritDoc}
     */
public void externalLock(NodeId nodeId, boolean isDeep, String lockOwner) throws RepositoryException {
    acquire();
    try {
        Path path = getPath(sysSession, nodeId);
        // create lock token
        InternalLockInfo info = new InternalLockInfo(nodeId, false, isDeep, lockOwner, Long.MAX_VALUE);
        info.setLive(true);
        lockMap.put(path, info);
        save();
    } finally {
        release();
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path)

Example 17 with Path

use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.

the class LockManagerImpl method addLockToken.

/**
     * {@inheritDoc}
     */
public void addLockToken(SessionImpl session, String lt) throws LockException, RepositoryException {
    try {
        acquire();
        NodeId id = LockInfo.parseLockToken(lt);
        NodeImpl node = (NodeImpl) sysSession.getItemManager().getItem(id);
        Path path = node.getPrimaryPath();
        PathMap.Element<LockInfo> element = lockMap.map(path, true);
        if (element != null) {
            LockInfo info = element.get();
            if (info != null && !info.isLockHolder(session)) {
                if (info.getLockHolder() == null) {
                    info.setLockHolder(session);
                    if (info instanceof InternalLockInfo) {
                        session.addListener((InternalLockInfo) info);
                    }
                } else {
                    String msg = "Cannot add lock token: lock already held by other session.";
                    log.warn(msg);
                    info.throwLockException(msg, session);
                }
            }
        }
        // inform SessionLockManager
        getSessionLockManager(session).lockTokenAdded(lt);
    } catch (IllegalArgumentException e) {
        String msg = "Bad lock token: " + e.getMessage();
        log.warn(msg);
        throw new LockException(msg);
    } finally {
        release();
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeImpl(org.apache.jackrabbit.core.NodeImpl) LockException(javax.jcr.lock.LockException) NodeId(org.apache.jackrabbit.core.id.NodeId) PathMap(org.apache.jackrabbit.spi.commons.name.PathMap)

Example 18 with Path

use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.

the class UserManagerImpl method findAuthorizables.

/**
     * @see UserManager#findAuthorizables(String,String, int)
     */
public Iterator<Authorizable> findAuthorizables(String relPath, String value, int searchType) throws RepositoryException {
    if (searchType < SEARCH_TYPE_USER || searchType > SEARCH_TYPE_AUTHORIZABLE) {
        throw new IllegalArgumentException("Invalid search type " + searchType);
    }
    Path path = session.getQPath(relPath);
    NodeIterator nodes;
    if (relPath.indexOf('/') == -1) {
        // search for properties somewhere below an authorizable node
        nodes = authResolver.findNodes(path, value, searchType, true, Long.MAX_VALUE);
    } else {
        path = path.getNormalizedPath();
        if (path.getLength() == 1) {
            // only search below the authorizable node
            Name ntName;
            switch(searchType) {
                case SEARCH_TYPE_GROUP:
                    ntName = NT_REP_GROUP;
                    break;
                case SEARCH_TYPE_USER:
                    ntName = NT_REP_USER;
                    break;
                default:
                    ntName = NT_REP_AUTHORIZABLE;
            }
            nodes = authResolver.findNodes(path.getName(), value, ntName, true);
        } else {
            // search below authorizable nodes but take some path constraints
            // into account.
            nodes = authResolver.findNodes(path, value, searchType, true, Long.MAX_VALUE);
        }
    }
    return new AuthorizableIterator(nodes);
}
Also used : Path(org.apache.jackrabbit.spi.Path) NodeIterator(javax.jcr.NodeIterator) Name(org.apache.jackrabbit.spi.Name)

Example 19 with Path

use of org.apache.jackrabbit.spi.Path in project jackrabbit by apache.

the class SessionImpl method getNode.

/**
     * @see Session#getNode(String)
     */
@Override
public Node getNode(String absPath) throws RepositoryException {
    checkIsAlive();
    try {
        Path qPath = getQPath(absPath).getNormalizedPath();
        ItemManager itemMgr = getItemManager();
        return itemMgr.getNode(qPath);
    } catch (AccessDeniedException ade) {
        throw new PathNotFoundException(absPath);
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) AccessDeniedException(javax.jcr.AccessDeniedException) PathNotFoundException(javax.jcr.PathNotFoundException)

Example 20 with Path

use of org.apache.jackrabbit.spi.Path 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)

Aggregations

Path (org.apache.jackrabbit.spi.Path)222 RepositoryException (javax.jcr.RepositoryException)72 Name (org.apache.jackrabbit.spi.Name)37 ItemNotFoundException (javax.jcr.ItemNotFoundException)25 NodeState (org.apache.jackrabbit.core.state.NodeState)24 PathNotFoundException (javax.jcr.PathNotFoundException)22 NodeId (org.apache.jackrabbit.core.id.NodeId)22 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)20 NamespaceException (javax.jcr.NamespaceException)16 ArrayList (java.util.ArrayList)13 AccessDeniedException (javax.jcr.AccessDeniedException)13 Node (javax.jcr.Node)12 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)12 ChildNodeEntry (org.apache.jackrabbit.core.state.ChildNodeEntry)11 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)11 NodeId (org.apache.jackrabbit.spi.NodeId)11 QValue (org.apache.jackrabbit.spi.QValue)10 MalformedPathException (org.apache.jackrabbit.spi.commons.conversion.MalformedPathException)10 IOException (java.io.IOException)9 ItemExistsException (javax.jcr.ItemExistsException)8