Skip to content

Commit

Permalink
KYLO-3137 duplicate feed name check
Browse files Browse the repository at this point in the history
  • Loading branch information
scottreisdorf committed Nov 29, 2018
1 parent 1852557 commit 03a18d4
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,13 @@ public FeedMetadata saveDraftFeed(FeedMetadata feedMetadata) {
// Check existence of required category and template entities with service privileges.
metadataAccess.read(() -> {
//Read all the feeds as System Service account to ensure the feed name is unique
if (feedMetadata.isNew()) {
Feed existing = feedProvider.findBySystemName(feedMetadata.getCategory().getSystemName(), feedMetadata.getSystemFeedName());
if (existing != null) {
throw new DuplicateFeedNameException(feedMetadata.getCategoryName(), feedMetadata.getFeedName());
}

Feed existing = feedProvider.findBySystemName(feedMetadata.getCategory().getSystemName(), feedMetadata.getSystemFeedName());
if (existing != null && !existing.getId().toString().equalsIgnoreCase(feedMetadata.getId())) {
throw new DuplicateFeedNameException(feedMetadata.getCategoryName(), feedMetadata.getFeedName());
}

if (feedMetadata.isNew()) {
// Ensure the template exists
FeedManagerTemplate domainTemplate = templateProvider.findById(templateProvider.resolveId(feedMetadata.getTemplateId()));
if (domainTemplate == null) {
Expand All @@ -780,7 +781,7 @@ public FeedMetadata saveDraftFeed(FeedMetadata feedMetadata) {
// Check services access to be able to create a feed
this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);

// Read all the feeds as System Service account to ensure the feed name is unique

if (feedMetadata.isNew()) {
Category domainCategory = categoryProvider.findById(categoryProvider.resolveId(feedMetadata.getCategory().getId()));

Expand Down

0 comments on commit 03a18d4

Please sign in to comment.