use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class CustomPrivilegeTest method testCustomPrivilege.
public void testCustomPrivilege() throws RepositoryException, FileSystemException {
boolean isAbstract = false;
Name name = ((SessionImpl) superuser).getQName("test");
privilegeRegistry.registerDefinition(name, isAbstract, Collections.<Name>emptySet());
PrivilegeManagerImpl pm = new PrivilegeManagerImpl(privilegeRegistry, resolver);
String privName = resolver.getJCRName(name);
Privilege priv = pm.getPrivilege(privName);
assertEquals(privName, priv.getName());
assertEquals(isAbstract, priv.isAbstract());
assertFalse(priv.isAggregate());
assertFalse(pm.getBits(priv).isEmpty());
Privilege jcrWrite = pm.getPrivilege(Privilege.JCR_WRITE);
assertFalse(pm.getBits(jcrWrite).equals(pm.getBits(priv, jcrWrite)));
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class LockManagerImpl method removeLockProperties.
/**
*
* @param node
* @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();
try {
acquireLockPropertiesLock();
// add properties to content
if (stateMgr.inEditMode()) {
throw new RepositoryException("Unable to remove lock properties.");
}
stateMgr.edit();
try {
NodeId nodeId = node.getNodeId();
NodeState nodeState = (NodeState) stateMgr.getItemState(nodeId);
if (nodeState.hasPropertyName(NameConstants.JCR_LOCKOWNER)) {
PropertyState propState = (PropertyState) stateMgr.getItemState(new PropertyId(nodeId, NameConstants.JCR_LOCKOWNER));
nodeState.removePropertyName(NameConstants.JCR_LOCKOWNER);
stateMgr.destroy(propState);
stateMgr.store(nodeState);
}
if (nodeState.hasPropertyName(NameConstants.JCR_LOCKISDEEP)) {
PropertyState propState = (PropertyState) stateMgr.getItemState(new PropertyId(nodeId, NameConstants.JCR_LOCKISDEEP));
nodeState.removePropertyName(NameConstants.JCR_LOCKISDEEP);
stateMgr.destroy(propState);
stateMgr.store(nodeState);
}
stateMgr.update();
success = true;
} catch (ItemStateException e) {
throw new RepositoryException("Error while removing lock.", e);
} finally {
if (!success) {
// failed to set lock meta-data content, cleanup
stateMgr.cancel();
}
}
} finally {
releaseLockPropertiesLock();
}
}
use of org.apache.jackrabbit.core.SessionImpl 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();
}
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class XALockManager method checkLock.
/**
* {@inheritDoc}
*/
public void checkLock(Path path, Session session) throws LockException, RepositoryException {
if (isInXA()) {
SessionImpl sessionImpl = (SessionImpl) session;
checkLock(sessionImpl.getItemManager().getNode(path));
} else {
lockMgr.checkLock(path, session);
}
}
use of org.apache.jackrabbit.core.SessionImpl in project jackrabbit by apache.
the class XALockManager method getLock.
/**
* {@inheritDoc}
*/
public Lock getLock(NodeImpl node) throws LockException, RepositoryException {
LockInfo info;
if (isInXA()) {
info = xaEnv.getLockInfo(node);
} else {
info = lockMgr.getLockInfo(node.getNodeId());
}
if (info == null) {
throw new LockException("Node not locked: " + node);
}
SessionImpl session = (SessionImpl) node.getSession();
NodeImpl holder = (NodeImpl) session.getItemManager().getItem(info.getId());
return new XALockImpl(this, info, holder);
}
Aggregations