Search in sources :

Example 1 with RoleMembership

use of com.thinkbiganalytics.security.role.RoleMembership in project kylo by Teradata.

the class JcrFeedProvider method moveFeed.

/* (non-Javadoc)
     * @see com.thinkbiganalytics.metadata.api.feed.FeedProvider#moveFeed(com.thinkbiganalytics.metadata.api.feed.Feed, com.thinkbiganalytics.metadata.api.category.Category)
     */
@Override
public Feed moveFeed(Feed feed, Category toCat) {
    // Only allow a move if none of this feed's versions has ever been deployed.
    if (findDeployedVersion(feed.getId(), false).isPresent()) {
        throw new MetadataRepositoryException("Only a draft feed with no versions may change its category - current category is: " + toCat.getDisplayName());
    } else {
        Set<RoleMembership> prevCatMemberships = feed.getCategory().getFeedRoleMemberships();
        Node feedNode = ((JcrFeed) feed).getNode();
        Path newPath = JcrUtil.path(EntityUtil.pathForFeed(toCat.getSystemName(), feed.getSystemName()));
        feedNode = JcrUtil.moveNode(feedNode, newPath);
        JcrFeed moved = JcrUtil.getJcrObject(feedNode, JcrFeed.class, this.opsAccessProvider);
        moved.updateAllRoleMembershipPermissions(prevCatMemberships.stream());
        return moved;
    }
}
Also used : MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Path(java.nio.file.Path) Node(javax.jcr.Node) RoleMembership(com.thinkbiganalytics.security.role.RoleMembership)

Aggregations

MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)1 RoleMembership (com.thinkbiganalytics.security.role.RoleMembership)1 Path (java.nio.file.Path)1 Node (javax.jcr.Node)1