use of org.structr.core.graph.RelationshipInterface 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.core.graph.RelationshipInterface in project structr by structr.
the class StructrApp method getRelationshipById.
@Override
public RelationshipInterface getRelationshipById(final Class type, final String uuid) throws FrameworkException {
if (uuid == null) {
return null;
}
final Long id = getRelFromCache(uuid);
if (id == null) {
final Query query = relationshipQuery().uuid(uuid);
// set type for faster query
if (type != null) {
query.andType(type);
} else {
logger.warn("Relationship access by UUID is deprecated and not supported by Neo4j, this can take a very long time. Please examine the following stack trace and amend.");
Thread.dumpStack();
}
final GraphObject entity = query.getFirst();
if (entity != null) {
relUuidMap.put(uuid, entity.getId());
return (RelationshipInterface) entity;
}
} else {
try {
return relFactory.instantiate(getDatabaseService().getRelationshipById(id));
} catch (NotFoundException ignore) {
relUuidMap.remove(uuid);
}
}
return null;
}
use of org.structr.core.graph.RelationshipInterface in project structr by structr.
the class ChildrenCommand method processMessage.
@Override
public void processMessage(final WebSocketMessage webSocketData) {
final RelationshipFactory factory = new RelationshipFactory(this.getWebSocket().getSecurityContext());
final AbstractNode node = getNode(webSocketData.getId());
if (node == null) {
return;
}
final Iterable<RelationshipInterface> rels = new IterableAdapter<>(node.getNode().getRelationships(Direction.OUTGOING, RelType.CONTAINS), factory);
final List<GraphObject> result = new LinkedList();
for (RelationshipInterface rel : rels) {
NodeInterface endNode = rel.getTargetNode();
if (endNode == null) {
continue;
}
result.add(endNode);
}
webSocketData.setView(PropertyView.Ui);
webSocketData.setResult(result);
// send only over local connection
getWebSocket().send(webSocketData, true);
}
Aggregations