Search in sources :

Example 26 with JcrFeed

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);
        });
    }
}
Also used : JcrAllowedActions(com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed) Principal(java.security.Principal)

Aggregations

JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)26 Node (javax.jcr.Node)13 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)11 JcrAllowedActions (com.thinkbiganalytics.metadata.modeshape.security.action.JcrAllowedActions)6 UpgradeException (com.thinkbiganalytics.server.upgrade.UpgradeException)5 JcrCategory (com.thinkbiganalytics.metadata.modeshape.category.JcrCategory)4 ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)4 AllowedActions (com.thinkbiganalytics.security.action.AllowedActions)4 SecurityRole (com.thinkbiganalytics.security.role.SecurityRole)4 Principal (java.security.Principal)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Category (com.thinkbiganalytics.metadata.api.category.Category)2 ExtensibleEntity (com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity)2 FeedProvider (com.thinkbiganalytics.metadata.api.feed.FeedProvider)2 FeedSource (com.thinkbiganalytics.metadata.api.feed.FeedSource)2 OpsManagerFeed (com.thinkbiganalytics.metadata.api.feed.OpsManagerFeed)2 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement)2 FeedServiceLevelAgreementRelationship (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)2