Search in sources :

Example 16 with FeedSummary

use of com.thinkbiganalytics.feedmgr.rest.model.FeedSummary in project kylo by Teradata.

the class DefaultFeedManagerFeedService method disableFeed.

public FeedSummary disableFeed(final String feedId) {
    return metadataAccess.commit(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
        if (StringUtils.isNotBlank(feedId)) {
            FeedMetadata feedMetadata = getFeedById(feedId);
            Feed.ID domainId = feedProvider.resolveFeed(feedId);
            boolean disabled = disableFeed(domainId);
            // re fetch it
            if (disabled) {
                feedMetadata.setState(Feed.State.DISABLED.name());
                serviceLevelAgreementService.disableServiceLevelAgreementSchedule(domainId);
            }
            FeedSummary feedSummary = new FeedSummary(feedMetadata);
            return feedSummary;
        }
        return null;
    });
}
Also used : FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) UIFeed(com.thinkbiganalytics.feedmgr.rest.model.UIFeed) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Example 17 with FeedSummary

use of com.thinkbiganalytics.feedmgr.rest.model.FeedSummary 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;
    }
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) ArrayList(java.util.ArrayList) HadoopSecurityGroup(com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup) JcrHadoopSecurityGroup(com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary) Nullable(javax.annotation.Nullable)

Example 18 with FeedSummary

use of com.thinkbiganalytics.feedmgr.rest.model.FeedSummary in project kylo by Teradata.

the class FeedManagerMetadataService method disableFeed.

public FeedSummary disableFeed(final String feedId) {
    return metadataAccess.commit(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
        FeedMetadata feedMetadata = feedProvider.getFeedById(feedId);
        if (feedMetadata == null) {
            throw new NotFoundException("Feed not found for id " + feedId);
        }
        if (!feedMetadata.getState().equals(Feed.State.DISABLED.name())) {
            FeedSummary feedSummary = feedProvider.disableFeed(feedId);
            boolean updatedNifi = updateNifiFeedRunningStatus(feedSummary, Feed.State.DISABLED);
            if (!updatedNifi) {
                // rollback
                throw new RuntimeException("Unable to disable Feed " + feedId);
            }
            return feedSummary;
        }
        return new FeedSummary(feedMetadata);
    });
}
Also used : NifiClientRuntimeException(com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) NotFoundException(javax.ws.rs.NotFoundException) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Example 19 with FeedSummary

use of com.thinkbiganalytics.feedmgr.rest.model.FeedSummary in project kylo by Teradata.

the class InMemoryFeedManagerCategoryService method saveCategory.

@Override
public void saveCategory(final FeedCategory category) {
    if (category.getId() == null) {
        category.setId(UUID.randomUUID().toString());
        category.setSystemName(SystemNamingService.generateSystemName(category.getName()));
    } else {
        FeedCategory oldCategory = categories.get(category.getId());
        if (oldCategory != null && !oldCategory.getName().equalsIgnoreCase(category.getName())) {
            // only regenerate the system name if there are no related feeds
            if (oldCategory.getRelatedFeeds() == 0) {
                category.setSystemName(SystemNamingService.generateSystemName(category.getName()));
            }
        }
        List<FeedSummary> feeds = categories.get(category.getId()).getFeeds();
        category.setFeeds(feeds);
    }
    categories.put(category.getId(), category);
    FileObjectPersistence.getInstance().writeCategoriesToFile(categories.values());
}
Also used : FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Example 20 with FeedSummary

use of com.thinkbiganalytics.feedmgr.rest.model.FeedSummary in project kylo by Teradata.

the class IntegrationTestBase method disableFeed.

protected void disableFeed(String feedId) {
    LOG.info("Disabling feed {}", feedId);
    Response response = disableFeedExpecting(feedId, HTTP_OK);
    FeedSummary feed = response.as(FeedSummary.class);
    Assert.assertEquals(Feed.State.DISABLED.name(), feed.getState());
}
Also used : Response(com.jayway.restassured.response.Response) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Aggregations

FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)22 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)11 FeedCategory (com.thinkbiganalytics.feedmgr.rest.model.FeedCategory)10 ArrayList (java.util.ArrayList)9 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)6 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)5 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)4 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)4 UserProperty (com.thinkbiganalytics.feedmgr.rest.model.UserProperty)4 Category (com.thinkbiganalytics.metadata.api.category.Category)4 FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)4 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)4 NotFoundException (javax.ws.rs.NotFoundException)4 Response (com.jayway.restassured.response.Response)3 DefaultTag (com.thinkbiganalytics.discovery.model.DefaultTag)3 EntityVersionDifference (com.thinkbiganalytics.feedmgr.rest.model.EntityVersionDifference)3 FeedVersions (com.thinkbiganalytics.feedmgr.rest.model.FeedVersions)3 HadoopSecurityGroup (com.thinkbiganalytics.metadata.api.security.HadoopSecurityGroup)3 JcrHadoopSecurityGroup (com.thinkbiganalytics.metadata.modeshape.security.JcrHadoopSecurityGroup)3 FieldRuleProperty (com.thinkbiganalytics.policy.rest.model.FieldRuleProperty)3