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();
}
}
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();
}
}
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);
}
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);
}
}
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);
}
Aggregations