use of org.structr.api.graph.Direction in project structr by structr.
the class AbstractNode method getRelationships.
@Override
public final <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target, R extends Relation<A, B, S, T>> Iterable<R> getRelationships(final Class<R> type) {
final RelationshipFactory<R> factory = new RelationshipFactory<>(securityContext);
final R template = getRelationshipForType(type);
final Direction direction = template.getDirectionForType(entityType);
final RelationshipType relType = template;
return new IterableAdapter<>(dbNode.getRelationships(direction, relType), factory);
}
use of org.structr.api.graph.Direction in project structr by structr.
the class AbstractNode method hasEffectivePermissions.
private boolean hasEffectivePermissions(final BFSInfo parent, final Principal principal, final Permission permission, final PermissionResolutionMask mask, final int level, final AlreadyTraversed alreadyTraversed, final Queue<BFSInfo> bfsNodes, final boolean doLog) {
// check nodes here to avoid circles in permission-propagating relationships
if (alreadyTraversed.contains("Node", dbNode.getId())) {
return false;
}
for (final Class<Relation> propagatingType : SchemaRelationshipNode.getPropagatingRelationshipTypes()) {
final Relation template = getRelationshipForType(propagatingType);
final Direction direction = template.getDirectionForType(entityType);
// skip relationship type if it is not applicable for the current node type
if (Direction.BOTH.equals(direction)) {
continue;
}
// iterate over list of relationships
final Iterable<Relation> iterable = getRelationshipsAsSuperUser(propagatingType);
for (final Relation source : iterable) {
if (source instanceof PermissionPropagation) {
final PermissionPropagation perm = (PermissionPropagation) source;
final RelationshipInterface rel = (RelationshipInterface) source;
// check propagation direction vs. evaluation direction
if (propagationAllowed(this, rel, perm.getPropagationDirection(), doLog)) {
applyCurrentStep(perm, mask);
if (mask.allowsPermission(permission)) {
final AbstractNode otherNode = (AbstractNode) rel.getOtherNode(this);
if (otherNode.isGranted(permission, principal, mask, level + 1, alreadyTraversed, false, doLog)) {
otherNode.storePermissionResolutionResult(principal.getId(), permission, true);
// break early
return true;
} else {
// add node to BFS queue
bfsNodes.add(new BFSInfo(parent, otherNode));
}
}
}
}
}
}
return false;
}
use of org.structr.api.graph.Direction in project structr by structr.
the class AbstractNode method getRelationshipsAsSuperUser.
protected final <A extends NodeInterface, B extends NodeInterface, S extends Source, T extends Target, R extends Relation<A, B, S, T>> Iterable<R> getRelationshipsAsSuperUser(final Class<R> type) {
final RelationshipFactory<R> factory = new RelationshipFactory<>(SecurityContext.getSuperUserInstance());
final R template = getRelationshipForType(type);
final Direction direction = template.getDirectionForType(entityType);
final RelationshipType relType = template;
return new IterableAdapter<>(dbNode.getRelationships(direction, relType), factory);
}
Aggregations