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;
});
}
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;
}
}
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);
});
}
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());
}
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());
}
Aggregations