use of org.structr.core.entity.Security in project structr by structr.
the class DeployCommand method exportOwnershipAndSecurity.
private void exportOwnershipAndSecurity(final NodeInterface node, final Map<String, Object> config) {
// export unique name of owner node to pages.json
final Principal owner = node.getOwnerNode();
if (owner != null) {
final Map<String, Object> map = new HashMap<>();
map.put("name", owner.getName());
config.put("owner", map);
}
// export security grants
final List<Map<String, Object>> grantees = new LinkedList<>();
for (final Security security : node.getSecurityRelationships()) {
if (security != null) {
final Map<String, Object> grant = new TreeMap<>();
grant.put("name", security.getSourceNode().getProperty(AbstractNode.name));
final String allowedActions = StringUtils.join(security.getPermissions(), ",");
grant.put("allowed", allowedActions);
if (allowedActions.length() > 0) {
grantees.add(grant);
}
}
}
// export non-empty collection only
if (!grantees.isEmpty()) {
config.put("grantees", grantees);
}
}
Aggregations