Search in sources :

Example 1 with JcrHadoopSecurityGroup

use of com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup in project kylo by Teradata.

the class FeedData method setSecurityGroups.

public void setSecurityGroups(List<? extends HadoopSecurityGroup> hadoopSecurityGroups) {
    JcrPropertyUtil.setProperty(this.node, HADOOP_SECURITY_GROUPS, null);
    for (HadoopSecurityGroup securityGroup : hadoopSecurityGroups) {
        Node securityGroupNode = ((JcrHadoopSecurityGroup) securityGroup).getNode();
        JcrPropertyUtil.addToSetProperty(this.node, HADOOP_SECURITY_GROUPS, securityGroupNode, true);
    }
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) Node(javax.jcr.Node) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)

Example 2 with JcrHadoopSecurityGroup

use of com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup in project kylo by Teradata.

the class CategoryModelTransform method feedCategoryToDomain.

/**
 * Transforms the specified Feed Manager category to a Metadata category.
 *
 * @param feedCategory the Feed Manager category
 * @param userFields   the user-defined fields
 * @return the Metadata category
 */
@Nonnull
private Category feedCategoryToDomain(@Nonnull final FeedCategory feedCategory, @Nonnull final Set<UserFieldDescriptor> userFields) {
    Category.ID domainId = feedCategory.getId() != null ? categoryProvider.resolveId(feedCategory.getId()) : null;
    Category category = null;
    if (domainId != null) {
        category = categoryProvider.findById(domainId);
    }
    if (category == null) {
        category = categoryProvider.ensureCategory(feedCategory.getSystemName());
    }
    if (category == null) {
        throw new CategoryNotFoundException("Unable to find Category ", domainId);
    }
    domainId = category.getId();
    feedCategory.setId(domainId.toString());
    category.setDisplayName(feedCategory.getName());
    category.setSystemName(feedCategory.getSystemName());
    category.setDescription(feedCategory.getDescription());
    category.setIcon(feedCategory.getIcon());
    category.setIconColor(feedCategory.getIconColor());
    category.setAllowIndexing(feedCategory.isAllowIndexing());
    category.setCreatedTime(new DateTime(feedCategory.getCreateDate()));
    category.setModifiedTime(new DateTime(feedCategory.getUpdateDate()));
    // Transforms the Feed Manager user-defined properties to domain user-defined properties
    if (feedCategory.getUserProperties() != null) {
        category.setUserProperties(UserPropertyTransform.toMetadataProperties(feedCategory.getUserProperties()), userFields);
    }
    // Set the hadoop security groups
    final List<HadoopSecurityGroup> securityGroups = new ArrayList<>();
    if (feedCategory.getSecurityGroups() != null) {
        for (com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup securityGroup : feedCategory.getSecurityGroups()) {
            JcrHadoopSecurityGroup hadoopSecurityGroup = (JcrHadoopSecurityGroup) hadoopSecurityGroupProvider.ensureSecurityGroup(securityGroup.getName());
            hadoopSecurityGroup.setGroupId(securityGroup.getId());
            hadoopSecurityGroup.setDescription(securityGroup.getDescription());
            securityGroups.add(hadoopSecurityGroup);
        }
    }
    category.setSecurityGroups(securityGroups);
    return category;
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) Category(com.thinkbiganalytics.metadata.api.category.Category) FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) CategoryNotFoundException(com.thinkbiganalytics.metadata.api.category.CategoryNotFoundException) ArrayList(java.util.ArrayList) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) DateTime(org.joda.time.DateTime) Nonnull(javax.annotation.Nonnull)

Example 3 with JcrHadoopSecurityGroup

use of com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup in project kylo by Teradata.

the class FeedModelTransform method feedToDomain.

/**
 * Transforms the specified Feed Manager feed to a Metadata feed.
 *
 * @param feedMetadata the Feed Manager feed
 * @return the Metadata feed
 */
@Nonnull
public Feed feedToDomain(@Nonnull final FeedMetadata feedMetadata) {
    // resolve the id
    Feed.ID domainId = feedMetadata.getId() != null ? feedProvider.resolveId(feedMetadata.getId()) : null;
    Feed domain = domainId != null ? feedProvider.findById(domainId) : null;
    FeedCategory restCategoryModel = feedMetadata.getCategory();
    Category category = null;
    if (restCategoryModel != null && (domain == null || domain.getCategory() == null)) {
        category = categoryProvider.findById(categoryProvider.resolveId(restCategoryModel.getId()));
    }
    if (domain == null) {
        // ensure the Category exists
        if (category == null) {
            final String categoryId = (restCategoryModel != null) ? restCategoryModel.getId() : "(null)";
            throw new RuntimeException("Category cannot be found while creating feed " + feedMetadata.getSystemFeedName() + ".  Category Id is " + categoryId);
        }
        domain = feedProvider.ensureFeed(category.getId(), feedMetadata.getSystemFeedName());
        domainId = domain.getId();
        Feed.State state = Feed.State.valueOf(feedMetadata.getState());
        domain.setState(state);
        // reassign the domain data back to the ui model....
        feedMetadata.setFeedId(domainId.toString());
        feedMetadata.setState(state.name());
    }
    domain.setDisplayName(feedMetadata.getFeedName());
    if (feedMetadata.getDescription() == null) {
        feedMetadata.setDescription("");
    }
    domain.setDescription(feedMetadata.getDescription());
    domain.setAllowIndexing(feedMetadata.isAllowIndexing());
    if (StringUtils.isNotBlank(feedMetadata.getHistoryReindexingStatus())) {
        domain.updateHistoryReindexingStatus(new HistoryReindexingStatus(com.thinkbiganalytics.metadata.api.feed.reindex.HistoryReindexingState.valueOf(feedMetadata.getHistoryReindexingStatus())));
    }
    feedMetadata.setId(domain.getId().toString());
    if (StringUtils.isNotBlank(feedMetadata.getState())) {
        Feed.State state = Feed.State.valueOf(feedMetadata.getState().toUpperCase());
        domain.setState(state);
    }
    domain.setNifiProcessGroupId(feedMetadata.getNifiProcessGroupId());
    // clear out the state as that
    RegisteredTemplate template = feedMetadata.getRegisteredTemplate();
    prepareForSave(feedMetadata);
    feedMetadata.setRegisteredTemplate(template);
    if (domain.getTemplate() == null) {
        FeedManagerTemplate.ID templateId = templateProvider.resolveId(feedMetadata.getTemplateId());
        FeedManagerTemplate domainTemplate = templateProvider.findById(templateId);
        domain.setTemplate(domainTemplate);
    }
    // Set user-defined properties
    if (feedMetadata.getUserProperties() != null) {
        final Set<UserFieldDescriptor> userFields = getUserFields(category);
        domain.setUserProperties(UserPropertyTransform.toMetadataProperties(feedMetadata.getUserProperties()), userFields);
    }
    // Set the hadoop security groups
    final List<HadoopSecurityGroup> securityGroups = new ArrayList<>();
    if (feedMetadata.getSecurityGroups() != null) {
        for (com.thinkbiganalytics.feedmgr.rest.model.HadoopSecurityGroup securityGroup : feedMetadata.getSecurityGroups()) {
            JcrHadoopSecurityGroup hadoopSecurityGroup = (JcrHadoopSecurityGroup) hadoopSecurityGroupProvider.ensureSecurityGroup(securityGroup.getName());
            hadoopSecurityGroup.setGroupId(securityGroup.getId());
            hadoopSecurityGroup.setDescription(securityGroup.getDescription());
            securityGroups.add(hadoopSecurityGroup);
        }
    }
    domain.setSecurityGroups(securityGroups);
    domain.setVersionName(domain.getVersionName());
    if (feedMetadata.getTags() != null) {
        domain.setTags(feedMetadata.getTags().stream().map(Tag::getName).collect(Collectors.toSet()));
    }
    // Create a new feed metadata stripped of any excess data that does
    // not need to be serialized and stored in the feed domain entity.
    FeedMetadata stripped = stripMetadata(feedMetadata);
    domain.setJson(ObjectMapperSerializer.serialize(stripped));
    return domain;
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) Category(com.thinkbiganalytics.metadata.api.category.Category) FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) UserFieldDescriptor(com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) ArrayList(java.util.ArrayList) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) HistoryReindexingStatus(com.thinkbiganalytics.metadata.api.feed.reindex.HistoryReindexingStatus) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) Tag(com.thinkbiganalytics.discovery.schema.Tag) DefaultTag(com.thinkbiganalytics.discovery.model.DefaultTag) FeedManagerTemplate(com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) UIFeed(com.thinkbiganalytics.feedmgr.rest.model.UIFeed) Nonnull(javax.annotation.Nonnull)

Example 4 with JcrHadoopSecurityGroup

use of com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup in project kylo by Teradata.

the class CategoryDetails method setSecurityGroups.

public void setSecurityGroups(List<? extends HadoopSecurityGroup> hadoopSecurityGroups) {
    JcrPropertyUtil.setProperty(this.node, HADOOP_SECURITY_GROUPS, null);
    for (HadoopSecurityGroup securityGroup : hadoopSecurityGroups) {
        Node securityGroupNode = ((JcrHadoopSecurityGroup) securityGroup).getNode();
        JcrPropertyUtil.addToSetProperty(this.node, HADOOP_SECURITY_GROUPS, securityGroupNode, true);
    }
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) Node(javax.jcr.Node) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)

Aggregations

HadoopSecurityGroup (com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup)4 JcrHadoopSecurityGroup (com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)4 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)2 Category (com.thinkbiganalytics.metadata.api.category.Category)2 ArrayList (java.util.ArrayList)2 Nonnull (javax.annotation.Nonnull)2 Node (javax.jcr.Node)2 DefaultTag (com.thinkbiganalytics.discovery.model.DefaultTag)1 Tag (com.thinkbiganalytics.discovery.schema.Tag)1 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)1 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)1 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)1 CategoryNotFoundException (com.thinkbiganalytics.metadata.api.category.CategoryNotFoundException)1 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)1 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)1 HistoryReindexingStatus (com.thinkbiganalytics.metadata.api.feed.reindex.HistoryReindexingStatus)1 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)1 DateTime (org.joda.time.DateTime)1