use of com.thinkbiganalytics.metadata.modeshape.category.JcrCategory in project kylo by Teradata.
the class JcrFeedProvider method ensureFeed.
/**
* Ensure the Feed, but the Category must exist!
*/
@Override
public Feed ensureFeed(String categorySystemName, String feedSystemName) {
JcrCategory category = null;
try {
String categoryPath = EntityUtil.pathForCategory(categorySystemName);
Node categoryNode = getSession().getNode(categoryPath);
if (categoryNode != null) {
category = JcrUtil.createJcrObject(categoryNode, JcrCategory.class);
} else {
category = (JcrCategory) categoryProvider.findBySystemName(categorySystemName);
}
} catch (RepositoryException e) {
throw new CategoryNotFoundException("Unable to find Category for " + categorySystemName, null);
}
String feedParentPath = category.getFeedParentPath();
boolean newFeed = !hasEntityNode(feedParentPath, feedSystemName);
Node feedNode = findOrCreateEntityNode(feedParentPath, feedSystemName, getJcrEntityClass());
JcrFeed feed = new JcrFeed(feedNode, category, this.opsAccessProvider);
feed.setSystemName(feedSystemName);
if (newFeed) {
if (this.accessController.isEntityAccessControlled()) {
List<SecurityRole> roles = this.roleProvider.getEntityRoles(SecurityRole.FEED);
this.actionsProvider.getAvailableActions(AllowedActions.FEED).ifPresent(actions -> feed.enableAccessControl((JcrAllowedActions) actions, JcrMetadataAccess.getActiveUser(), roles));
} else {
this.actionsProvider.getAvailableActions(AllowedActions.FEED).ifPresent(actions -> feed.disableAccessControl((JcrAllowedActions) actions, JcrMetadataAccess.getActiveUser()));
}
addPostFeedChangeAction(feed, ChangeType.CREATE);
}
return feed;
}
use of com.thinkbiganalytics.metadata.modeshape.category.JcrCategory in project kylo by Teradata.
the class CheckEntityAccessControlAction method ensureCategoryAccessControl.
private void ensureCategoryAccessControl() {
List<Category> categories = categoryProvider.findAll();
if (categories != null) {
List<SecurityRole> catRoles = this.roleProvider.getEntityRoles(SecurityRole.CATEGORY);
List<SecurityRole> feedRoles = this.roleProvider.getEntityRoles(SecurityRole.FEED);
Optional<AllowedActions> allowedActions = this.actionsProvider.getAvailableActions(AllowedActions.CATEGORY);
categories.stream().forEach(category -> {
Principal owner = category.getOwner() != null ? category.getOwner() : JcrMetadataAccess.getActiveUser();
allowedActions.ifPresent(actions -> ((JcrCategory) category).enableAccessControl((JcrAllowedActions) actions, owner, catRoles, feedRoles));
});
}
}
Aggregations