use of org.apache.jackrabbit.core.id.NodeId in project jackrabbit-oak by apache.
the class JackrabbitNodeState method createRootNodeState.
public static JackrabbitNodeState createRootNodeState(RepositoryContext context, String workspaceName, NodeState root, Map<String, String> uriToPrefix, boolean copyBinariesByReference, boolean skipOnError) throws RepositoryException {
final Map<NodeId, JackrabbitNodeState> emptyMountPoints = ImmutableMap.of();
final PersistenceManager versionPM = context.getInternalVersionManager().getPersistenceManager();
final JackrabbitNodeState versionStorage = new JackrabbitNodeState(versionPM, root, uriToPrefix, VERSION_STORAGE_NODE_ID, "/jcr:system/jcr:versionStorage", null, emptyMountPoints, copyBinariesByReference, skipOnError);
final JackrabbitNodeState activities = new JackrabbitNodeState(versionPM, root, uriToPrefix, ACTIVITIES_NODE_ID, "/jcr:system/jcr:activities", null, emptyMountPoints, copyBinariesByReference, skipOnError);
PersistenceManager pm = context.getWorkspaceInfo(workspaceName).getPersistenceManager();
final Map<NodeId, JackrabbitNodeState> mountPoints = ImmutableMap.of(VERSION_STORAGE_NODE_ID, versionStorage, ACTIVITIES_NODE_ID, activities);
return new JackrabbitNodeState(pm, root, uriToPrefix, ROOT_NODE_ID, "/", workspaceName, mountPoints, copyBinariesByReference, skipOnError);
}
use of org.apache.jackrabbit.core.id.NodeId in project jackrabbit-oak by apache.
the class JackrabbitNodeState method getChildNodeEntries.
@Nonnull
@Override
public Iterable<MemoryChildNodeEntry> getChildNodeEntries() {
List<MemoryChildNodeEntry> entries = newArrayListWithCapacity(nodes.size());
for (Map.Entry<String, NodeId> entry : nodes.entrySet()) {
String name = entry.getKey();
final NodeState child = createChildNodeState(entry.getValue(), name);
if (child != null) {
entries.add(new MemoryChildNodeEntry(name, child));
}
}
return entries;
}
use of org.apache.jackrabbit.core.id.NodeId in project pentaho-platform by pentaho.
the class PentahoCompiledPermissionsImpl method buildResult.
private Result buildResult(NodeImpl node, boolean isExistingNode, boolean isAcItem, EntryFilterImpl filter) throws RepositoryException {
// retrieve all ACEs at path or at the direct ancestor of path that
// apply for the principal names.
NodeImpl n = ACLProvider.getNode(node, isAcItem);
Iterator entries = entryCollector.collectEntries(n, filter).iterator();
/*
* Calculate privileges and permissions: Since the ACEs only define privileges on a node and do not allow to
* add additional restrictions, the permissions can be determined without taking the given target name or
* target item into account.
*/
int allows = Permission.NONE;
int denies = Permission.NONE;
PrivilegeBits allowBits = PrivilegeBits.getInstance();
PrivilegeBits denyBits = PrivilegeBits.getInstance();
PrivilegeBits parentAllowBits = PrivilegeBits.getInstance();
PrivilegeBits parentDenyBits = PrivilegeBits.getInstance();
String parentPath = Text.getRelativeParent(filter.getPath(), 1);
NodeId nodeId = (node == null) ? null : node.getNodeId();
while (entries.hasNext()) {
Object ace = entries.next();
/*
* Determine if the ACE also takes effect on the parent: Some permissions (e.g. add-node or removal) must be
* determined from privileges defined for the parent. A 'local' entry defined on the target node never
* effects the parent. For inherited ACEs determine if the ACE matches the parent path.
*/
PrivilegeBits entryBits = null;
boolean isLocal = false;
boolean matchesParent = false;
boolean isAllow = false;
if (ace instanceof PentahoEntry) {
entryBits = (((PentahoEntry) ace).getPrivilegeBits());
isLocal = isExistingNode && ((PentahoEntry) ace).isLocal(nodeId);
matchesParent = (!isLocal && ((PentahoEntry) ace).matches(parentPath));
isAllow = ((PentahoEntry) ace).isAllow();
} else {
entryBits = ((Entry) ace).getPrivilegeBits();
isLocal = isExistingNode && ((Entry) ace).isLocal(nodeId);
matchesParent = (!isLocal && ((Entry) ace).matches(parentPath));
isAllow = ((Entry) ace).isAllow();
}
// check specific case: "Inherit permissions" may have been unchecked, and node operation permissions may
// have been granted directly to the item ( thus not requiring having those permissions defined for the parent )
boolean isLocalAndDoesNotInheritPermissions = isLocal && isValidPentahoNode(node) && !isEntriesInheriting(node);
if (matchesParent || isLocalAndDoesNotInheritPermissions) {
if (isAllow) {
parentAllowBits.addDifference(entryBits, parentDenyBits);
} else {
parentDenyBits.addDifference(entryBits, parentAllowBits);
}
}
if (isAllow) {
allowBits.addDifference(entryBits, denyBits);
int permissions = PrivilegeRegistry.calculatePermissions(allowBits, parentAllowBits, true, isAcItem);
allows |= Permission.diff(permissions, denies);
} else {
denyBits.addDifference(entryBits, allowBits);
int permissions = PrivilegeRegistry.calculatePermissions(denyBits, parentDenyBits, false, isAcItem);
denies |= Permission.diff(permissions, allows);
}
}
return new Result(allows, denies, allowBits, denyBits);
}
use of org.apache.jackrabbit.core.id.NodeId in project pentaho-platform by pentaho.
the class CachingPentahoEntryCollector method getNextID.
/**
* Find the next access control ancestor in the hierarchy 'null' indicates that there is no ac-controlled ancestor.
*
* @param node The target node for which the cache needs to be updated.
* @return The NodeId of the next access controlled ancestor in the hierarchy or null
*/
private NodeId getNextID(NodeImpl node) throws RepositoryException {
NodeImpl n = node;
NodeId nextId = null;
while (nextId == null && !isRootId(n.getNodeId())) {
NodeId parentId = n.getParentId();
if (getCache().containsKey(parentId)) {
nextId = parentId;
} else {
NodeImpl parent = (NodeImpl) n.getParent();
if (hasEntries(parent)) {
nextId = parentId;
} else {
// try next ancestor
n = parent;
}
}
}
return nextId;
}
use of org.apache.jackrabbit.core.id.NodeId in project pentaho-platform by pentaho.
the class CachingPentahoEntryCollector method getEntries.
// -----------------------------------------------------< EntryCollector >---
/**
* @see EntryCollector#getEntries(org.apache.jackrabbit.core.NodeImpl)
*/
@Override
protected PentahoEntries getEntries(NodeImpl node) throws RepositoryException {
NodeId nodeId = node.getNodeId();
Entries entries = getCache().get(nodeId);
if (entries == null) {
// fetch entries and update the cache
entries = updateCache(node);
}
return entries instanceof PentahoEntries ? (PentahoEntries) entries : new PentahoEntries(entries);
}
Aggregations