Search in sources :

Example 6 with HadoopSecurityGroup

use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup in project kylo by Teradata.

the class SimpleCategoryModelTransform method domainToFeedCategorySimple.

/**
 * Transforms the specified Metadata category to a simple Feed Manager category.
 *
 * @param domainCategory the Metadata category
 * @return the Feed Manager category
 */
@Nullable
public FeedCategory domainToFeedCategorySimple(@Nullable final Category domainCategory, boolean includeProperties, boolean includeSecurityGroups) {
    if (domainCategory != null) {
        FeedCategory category = new FeedCategory();
        category.setId(domainCategory.getId().toString());
        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.setCreateDate(domainCategory.getCreatedTime() != null ? domainCategory.getCreatedTime().toDate() : null);
        category.setUpdateDate(domainCategory.getModifiedTime() != null ? domainCategory.getModifiedTime().toDate() : null);
        if (includeProperties) {
            // Transform user-defined fields and properties
            category.setUserFields(UserPropertyTransform.toUserFields(categoryProvider.getFeedUserFields(domainCategory.getId()).orElse(Collections.emptySet())));
            category.setUserProperties(UserPropertyTransform.toUserProperties(domainCategory.getUserProperties(), categoryProvider.getUserFields()));
        }
        if (includeSecurityGroups) {
            // 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);
        }
        return category;
    } else {
        return null;
    }
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) ArrayList(java.util.ArrayList) Nullable(javax.annotation.Nullable)

Example 7 with HadoopSecurityGroup

use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup in project kylo by Teradata.

the class CategoryDetails method getSecurityGroups.

public List<? extends HadoopSecurityGroup> getSecurityGroups() {
    Set<Node> list = JcrPropertyUtil.getReferencedNodeSet(this.node, HADOOP_SECURITY_GROUPS);
    List<HadoopSecurityGroup> hadoopSecurityGroups = new ArrayList<>();
    if (list != null) {
        for (Node n : list) {
            hadoopSecurityGroups.add(JcrUtil.createJcrObject(n, JcrHadoopSecurityGroup.class));
        }
    }
    return hadoopSecurityGroups;
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)

Example 8 with HadoopSecurityGroup

use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup 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)

Example 9 with HadoopSecurityGroup

use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup in project kylo by Teradata.

the class FeedData method getSecurityGroups.

public List<? extends HadoopSecurityGroup> getSecurityGroups() {
    Set<Node> list = JcrPropertyUtil.getReferencedNodeSet(this.node, HADOOP_SECURITY_GROUPS);
    List<HadoopSecurityGroup> hadoopSecurityGroups = new ArrayList<>();
    if (list != null) {
        for (Node n : list) {
            hadoopSecurityGroups.add(JcrUtil.createJcrObject(n, JcrHadoopSecurityGroup.class));
        }
    }
    return hadoopSecurityGroups;
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)

Example 10 with HadoopSecurityGroup

use of com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup in project kylo by Teradata.

the class JcrFeedProvider method mergeFeedProperties.

@Override
public Map<String, Object> mergeFeedProperties(ID feedId, Map<String, Object> properties) {
    JcrFeed feed = (JcrFeed) getFeed(feedId);
    List<String> securityGroupNames = new ArrayList<>();
    for (Object o : feed.getSecurityGroups()) {
        HadoopSecurityGroup securityGroup = (HadoopSecurityGroup) o;
        securityGroupNames.add(securityGroup.getName());
    }
    Map<String, Object> merged = feed.mergeProperties(properties);
    PropertyChange change = new PropertyChange(feed.getId().getIdValue(), feed.getCategory().getSystemName(), feed.getSystemName(), securityGroupNames, feed.getProperties(), properties);
    this.metadataEventService.notify(new FeedPropertyChangeEvent(change));
    return merged;
}
Also used : HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) PropertyChange(com.thinkbiganalytics.metadata.api.event.feed.PropertyChange) ArrayList(java.util.ArrayList) JcrObject(com.thinkbiganalytics.metadata.modeshape.common.JcrObject) FeedPropertyChangeEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedPropertyChangeEvent)

Aggregations

HadoopSecurityGroup (com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup)11 ArrayList (java.util.ArrayList)9 JcrHadoopSecurityGroup (com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)8 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)5 Category (com.thinkbiganalytics.metadata.api.category.Category)4 Nonnull (javax.annotation.Nonnull)4 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)3 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)3 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)3 UserFieldDescriptor (com.thinkbiganalytics.metadata.api.extension.UserFieldDescriptor)3 FeedManagerTemplate (com.thinkbiganalytics.metadata.api.template.FeedManagerTemplate)3 Node (javax.jcr.Node)3 DefaultTag (com.thinkbiganalytics.discovery.model.DefaultTag)2 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)2 UserProperty (com.thinkbiganalytics.feedmgr.rest.model.UserProperty)2 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)2 DateTime (org.joda.time.DateTime)2 Stopwatch (com.google.common.base.Stopwatch)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Sets (com.google.common.collect.Sets)1