public static List<DynamicResourceAccess> createDynamicGrants(final String signature) {
final List<DynamicResourceAccess> grants = new LinkedList<>();
final long initialFlagsValue = 0;
final App app = StructrApp.getInstance();
try {
ResourceAccess grant = app.nodeQuery(ResourceAccess.class).and(ResourceAccess.signature, signature).getFirst();
if (grant == null) {
// create new grant
grants.add(app.create(DynamicResourceAccess.class,
new NodeAttribute(DynamicResourceAccess.signature, signature),
new NodeAttribute(DynamicResourceAccess.flags, initialFlagsValue)
));
// create additional grant for the _schema resource
grants.add(app.create(DynamicResourceAccess.class,
new NodeAttribute(DynamicResourceAccess.signature, "_schema/" + signature),
new NodeAttribute(DynamicResourceAccess.flags, initialFlagsValue)
));
// create additional grant for the Ui view
grants.add(app.create(DynamicResourceAccess.class,
new NodeAttribute(DynamicResourceAccess.signature, signature + "/_Ui"),
new NodeAttribute(DynamicResourceAccess.flags, initialFlagsValue)
));
}