use of com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed in project kylo by Teradata.
the class StartFeedPermUpgradeAction method upgradeTo.
@Override
public void upgradeTo(final KyloVersion targetVersion) {
log.info("Add start feed permission to roles: {}", targetVersion);
if (this.accessController.isEntityAccessControlled()) {
// Add the new "start" action to the set of feed actions.
actionsBuilder.module(AllowedActions.FEED).action(FeedAccessControl.START).add().build();
// Grant the start action permission to the editor and admin roles
this.roleProvider.getRole(SecurityRole.FEED, "editor").ifPresent(role -> role.setPermissions(FeedAccessControl.START));
this.roleProvider.getRole(SecurityRole.FEED, "admin").ifPresent(role -> role.setPermissions(FeedAccessControl.START));
// Ensure the new action is integrated into the all of the existing feed instances.
this.feedProvider.getFeeds().forEach(feed -> {
JcrFeed jcrFeed = (JcrFeed) feed;
Principal owner = feed.getOwner();
JcrAllowedActions feedAllowed = actionsProvider.updateEntityAllowedActions(AllowedActions.FEED, jcrFeed);
// Enable the permission to the owner, admin, and any principals in the editor and admin roles.
jcrFeed.updateRolePermissions();
feedAllowed.enable(owner, FeedAccessControl.START);
feedAllowed.enable(JcrMetadataAccess.ADMIN, FeedAccessControl.START);
});
}
}
Aggregations