use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class EntryTest method testIsLocal.
public void testIsLocal() throws NotExecutableException, RepositoryException {
acl = getPolicy(acMgr, testPath, testUser.getPrincipal());
modifyPrivileges(testPath, Privilege.JCR_READ, true);
NodeImpl aclNode = (NodeImpl) superuser.getNode(acl.getPath() + "/rep:policy");
List<Entry> entries = Entry.readEntries(aclNode, testRootNode.getPath());
assertTrue(!entries.isEmpty());
assertEquals(1, entries.size());
Entry entry = entries.iterator().next();
// false since acl has been created from path only -> no id
assertTrue(entry.isLocal(((NodeImpl) testRootNode).getNodeId()));
// false since internal id is null -> will never match.
assertFalse(entry.isLocal(NodeId.randomId()));
}
use of org.apache.jackrabbit.core.NodeImpl 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.core.NodeImpl in project jackrabbit by apache.
the class LockManagerImpl method removeLockToken.
/**
* {@inheritDoc}
*/
public void removeLockToken(SessionImpl session, String lt) throws LockException, RepositoryException {
try {
acquire();
NodeId id = LockInfo.parseLockToken(lt);
NodeImpl node = (NodeImpl) sysSession.getItemManager().getItem(id);
PathMap.Element<LockInfo> element = lockMap.map(node.getPrimaryPath(), true);
if (element != null) {
LockInfo info = element.get();
if (info != null) {
if (info.isLockHolder(session)) {
info.setLockHolder(null);
} else if (info.getLockHolder() != null) {
String msg = "Cannot remove lock token: lock held by other session.";
log.warn(msg);
info.throwLockException(msg, session);
}
}
}
// inform SessionLockManager
getSessionLockManager(session).lockTokenRemoved(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.core.NodeImpl in project jackrabbit by apache.
the class LockManagerImpl method getLocks.
/**
* {@inheritDoc}
*/
public Lock[] getLocks(SessionImpl session) throws RepositoryException {
acquire();
LockInfo[] infos = getLockInfos(session);
try {
Lock[] locks = new Lock[infos.length];
for (int i = 0; i < infos.length; i++) {
NodeImpl holder = (NodeImpl) session.getItemManager().getItem(infos[i].getId());
locks[i] = new LockImpl(infos[i], holder);
}
return locks;
} finally {
release();
}
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class LockManagerImpl method getLock.
/**
* {@inheritDoc}
*/
public Lock getLock(NodeImpl node) throws LockException, RepositoryException {
acquire();
try {
SessionImpl session = (SessionImpl) node.getSession();
Path path = getPath(session, node.getId());
PathMap.Element<LockInfo> element = lockMap.map(path, false);
LockInfo info = element.get();
if (info != null && (element.hasPath(path) || info.isDeep())) {
NodeImpl lockHolder = (NodeImpl) session.getItemManager().getItem(info.getId());
return new LockImpl(info, lockHolder);
} else {
throw new LockException("Node not locked: " + node);
}
} catch (ItemNotFoundException e) {
throw new LockException("Node not locked: " + node);
} finally {
release();
}
}
Aggregations