use of org.apache.jackrabbit.core.NodeImpl 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);
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class HierarchyConstraint method getBaseNodeId.
/**
* Returns the id of the base node or <code>null</code> if there is no node
* at the base path.
*
* @param context the evaluation context.
* @return the id or <code>null</code> if it doesn't exist.
*/
protected final NodeId getBaseNodeId(EvaluationContext context) {
if (id == null) {
try {
NodeImpl node = (NodeImpl) context.getSession().getNode(path);
id = (NodeId) node.getId();
} catch (RepositoryException e) {
return null;
}
}
return id;
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class VersionManagerImplBase method checkModify.
/**
* Checks modify and permissions
* @param state state to check
* @param options options to check
* @param permissions permissions to check
* @throws RepositoryException if an error occurs
*/
protected void checkModify(NodeStateEx state, int options, int permissions) throws RepositoryException {
NodeImpl node;
try {
node = session.getNodeById(state.getNodeId());
} catch (RepositoryException e) {
// ignore
return;
}
context.getItemValidator().checkModify(node, options, permissions);
}
use of org.apache.jackrabbit.core.NodeImpl in project jackrabbit by apache.
the class AccessManagerTest method testCanReadNewId.
public void testCanReadNewId() throws Exception {
Session s = getHelper().getReadOnlySession();
try {
NodeImpl n = (NodeImpl) testRootNode.addNode(nodeName1);
PropertyImpl p = (PropertyImpl) n.setProperty(propertyName1, "somevalue");
try {
AccessManager acMgr = getAccessManager(s);
acMgr.canRead(null, n.getId());
fail("expected repositoryexception");
} catch (RepositoryException e) {
// success
}
try {
AccessManager acMgr = getAccessManager(s);
acMgr.canRead(null, p.getId());
fail("expected repositoryexception");
} catch (RepositoryException e) {
// success
}
} finally {
s.logout();
}
}
use of org.apache.jackrabbit.core.NodeImpl in project pentaho-platform by pentaho.
the class PentahoCompiledPermissionsImpl method canRead.
/**
* Changed so that access to entryCollector is done outside of a <code>monitor</code> synchronized block.<br/>
* Should be functionally equivalent to {@link CompiledPermissions#canRead(Path, ItemId)}
*
* @see org.apache.jackrabbit.core.security.authorization.CompiledPermissions#canRead(Path, ItemId)
*/
public boolean canRead(Path path, ItemId itemId) throws RepositoryException {
ItemId id = (itemId == null) ? session.getHierarchyManager().resolvePath(path) : itemId;
// no extra check for existence as method may only be called for existing items.
boolean isExistingNode = id.denotesNode();
boolean canRead = false;
// synchronized (readMonitor) {
synchronized (monitor) {
if (readCache.containsKey(id)) {
return readCache.get(id);
}
}
ItemManager itemMgr = session.getItemManager();
NodeId nodeId = (isExistingNode) ? (NodeId) id : ((PropertyId) id).getParentId();
NodeImpl node = (NodeImpl) itemMgr.getItem(nodeId);
boolean isAcItem = util.isAcItem(node);
EntryFilterImpl filter;
if (path == null) {
filter = new PentahoEntryFilterImpl(principalNames, id, session);
} else {
filter = new PentahoEntryFilterImpl(principalNames, path, session);
}
if (isAcItem) {
/* item defines ac content -> regular evaluation */
Result result = buildResult(node, isExistingNode, isAcItem, filter);
canRead = result.grants(Permission.READ);
} else {
for (Object entry : entryCollector.collectEntries(node, filter)) {
PrivilegeBits privilegeBits = null;
boolean isAllow = false;
if (entry instanceof PentahoEntry) {
privilegeBits = ((PentahoEntry) entry).getPrivilegeBits();
isAllow = ((PentahoEntry) entry).isAllow();
} else {
privilegeBits = ((Entry) entry).getPrivilegeBits();
isAllow = ((Entry) entry).isAllow();
}
if (privilegeBits.includesRead()) {
canRead = isAllow;
break;
}
}
}
synchronized (monitor) {
readCache.put(id, canRead);
}
// } // readMonitor
return canRead;
}
Aggregations