use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup in project kylo by Teradata.
the class CategoryModelTransform method domainToFeedCategory.
/**
* Transforms the specified Metadata category into a Feed Manager category.
*
* @param domainCategory the Metadata category
* @param userFields the user-defined fields
* @return the Feed Manager category
*/
@Nullable
private FeedCategory domainToFeedCategory(@Nullable final Category domainCategory, @Nonnull final Set<UserFieldDescriptor> userFields, boolean includeFeedDetails) {
if (domainCategory != null) {
FeedCategory category = new FeedCategory();
category.setId(domainCategory.getId().toString());
if (includeFeedDetails && domainCategory.getFeeds() != null) {
List<FeedSummary> summaries = feedModelTransform.domainToFeedSummary(domainCategory.getFeeds());
category.setFeeds(summaries);
category.setRelatedFeeds(summaries.size());
}
category.setIconColor(domainCategory.getIconColor());
category.setIcon(domainCategory.getIcon());
category.setName(domainCategory.getDisplayName());
// in pre-0.8.4 version of Kylo there was no system name stored for domain categories
category.setSystemName(domainCategory.getSystemName() == null ? domainCategory.getDisplayName() : domainCategory.getSystemName());
category.setDescription(domainCategory.getDescription());
category.setAllowIndexing(domainCategory.isAllowIndexing());
category.setCreateDate(domainCategory.getCreatedTime() != null ? domainCategory.getCreatedTime().toDate() : null);
category.setUpdateDate(domainCategory.getModifiedTime() != null ? domainCategory.getModifiedTime().toDate() : null);
// Transform user-defined fields and properties
category.setUserFields(UserPropertyTransform.toUserFields(categoryProvider.getFeedUserFields(domainCategory.getId()).orElse(Collections.emptySet())));
category.setUserProperties(UserPropertyTransform.toUserProperties(domainCategory.getUserProperties(), userFields));
// Convert JCR securitygroup to DTO
List<com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup> restSecurityGroups = new ArrayList<>();
if (domainCategory.getSecurityGroups() != null && domainCategory.getSecurityGroups().size() > 0) {
for (Object group : domainCategory.getSecurityGroups()) {
HadoopSecurityGroup hadoopSecurityGroup = (HadoopSecurityGroup) group;
com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup restSecurityGroup = new com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup();
restSecurityGroup.setDescription(hadoopSecurityGroup.getDescription());
restSecurityGroup.setId(hadoopSecurityGroup.getGroupId());
restSecurityGroup.setName(hadoopSecurityGroup.getName());
restSecurityGroups.add(restSecurityGroup);
}
}
category.setSecurityGroups(restSecurityGroups);
securityTransform.applyAccessControl(domainCategory, category);
return category;
} else {
return null;
}
}
Aggregations