// State Action Context:latest published no active version left // Pub Delete 0 0 1 // Pub+Draft Discard Draft 0 0 0 // Draft Delete 0 0 1 // Pub+Draft Delete 0 0 1 public override async Task RemovingAsync(RemoveContentContext context) { try { if (context.NoActiveVersionLeft) { if (!await _deleteOrchestrator.Delete(context.ContentItem)) { Cancel(context); } return; } if (!await _syncOrchestrator.DiscardDraft(context.ContentItem)) { Cancel(context); } } catch (Exception ex) { // we log the exception, even though some exceptions will have already been logged, // as there might have been an 'unexpected' exception thrown _logger.LogError(ex, "Exception removing (deleting or discarding draft)."); Cancel(context); } }
private async Task RemovePublishedVersionAsync(ContentItem contentItem, IEnumerable <ContentItem> evictionVersions) { ContentItem publishedVersion; if (evictionVersions == null) { publishedVersion = await _session.Query <ContentItem, ContentItemIndex>() .Where(x => x.ContentItemId == contentItem.ContentItemId && x.Published) .FirstOrDefaultAsync(); } else { publishedVersion = evictionVersions.FirstOrDefault(x => x.Published); } if (publishedVersion != null) { var removeContext = new RemoveContentContext(contentItem, true); await Handlers.InvokeAsync((handler, context) => handler.RemovingAsync(context), removeContext, _logger); publishedVersion.Published = false; _session.Save(publishedVersion); await ReversedHandlers.InvokeAsync((handler, context) => handler.RemovedAsync(context), removeContext, _logger); } }
public void Removing(RemoveContentContext <Language> context) { if (context.ContentItem.CultureCode == siteSettings.DefaultLanguage) { throw new NotSupportedException("Cannot delete default language."); } }
public override async Task RemovedAsync(RemoveContentContext context) { if (context.NoActiveVersionLeft) { await _attachedMediaFieldFileService.DeleteContentItemFolder(context.ContentItem); } }
public async Task DiscardDraftAsync(ContentItem contentItem) { if (contentItem.Published || !contentItem.Latest) { throw new InvalidOperationException("Not a draft version."); } var publishedItem = await GetAsync(contentItem.ContentItemId, VersionOptions.Published); var context = new RemoveContentContext(contentItem, publishedItem == null); await Handlers.InvokeAsync(handler => handler.RemovingAsync(context), _logger); contentItem.Latest = false; _session.Save(contentItem); await ReversedHandlers.InvokeAsync(handler => handler.RemovedAsync(context), _logger); if (publishedItem != null) { publishedItem.Latest = true; _session.Save(publishedItem); } }
protected void GamePartRemoved(RemoveContentContext context) { Int32 gId = ((dynamic)context.ContentItem).Id; _questionnairesServices.UnscheduleEmailTask(gId); //base.Removed(context); }
void IContentPartHandler.Removed(RemoveContentContext context, ContentPart part) { if (part is TPart) { Removed(context, (TPart)part); } }
public async Task RemoveAsync(ContentItem contentItem) { var activeVersions = await _session.Query <ContentItem, ContentItemIndex>() .Where(x => x.ContentItemId == contentItem.ContentItemId && (x.Published || x.Latest)).ListAsync(); if (!activeVersions.Any()) { return; } var context = new RemoveContentContext(contentItem, true); await Handlers.InvokeAsync((handler, context) => handler.RemovingAsync(context), context, _logger); foreach (var version in activeVersions) { version.Published = false; version.Latest = false; _session.Save(version); } await ReversedHandlers.InvokeAsync((handler, context) => handler.RemovedAsync(context), context, _logger); }
public void Remove(ContentItem contentItem) { var context = new RemoveContentContext(contentItem); Handlers.Invoke(handler => handler.Removing(context), Logger); Handlers.Invoke(handler => handler.Removed(context), Logger); }
public override void Removed(RemoveContentContext context, AutoroutePart instance) { if (!String.IsNullOrWhiteSpace(instance.Path)) { _entries.RemoveEntry(instance.ContentItem.ContentItemId, instance.Path); } }
private void AssignRemovingDates(RemoveContentContext context, CommonPart part) { var utcNow = _clock.UtcNow; part.ModifiedUtc = utcNow; part.VersionModifiedUtc = utcNow; }
void IContentHandler.Removed(RemoveContentContext context) { if (context.ContentItem.Is <TPart>()) { Removed(context, context.ContentItem.As <TPart>()); } }
void IContentStorageFilter.Removed(RemoveContentContext context) { if (context.ContentItem.Is <TPart>()) { Removed(context, context.ContentItem.As <TPart>()); } }
private async Task RemoveVersionsAsync(ContentItem contentItem, IEnumerable <ContentItem> evictionVersions) { IEnumerable <ContentItem> activeVersions; if (evictionVersions == null) { activeVersions = await _session.Query <ContentItem, ContentItemIndex>() .Where(x => x.ContentItemId == contentItem.ContentItemId && (x.Published || x.Latest)).ListAsync(); } else { activeVersions = evictionVersions.Where(x => x.Latest || x.Published); } if (activeVersions.Any()) { var removeContext = new RemoveContentContext(contentItem, true); await Handlers.InvokeAsync((handler, context) => handler.RemovingAsync(context), removeContext, _logger); foreach (var version in activeVersions) { version.Published = false; version.Latest = false; _session.Save(version); } await ReversedHandlers.InvokeAsync((handler, context) => handler.RemovedAsync(context), removeContext, _logger); } }
public override void Removed(RemoveContentContext context, AutoroutePart part) { if (!String.IsNullOrWhiteSpace(part.Path)) { _entries.RemoveEntry(part.ContentItem.ContentItemId, part.Path); } }
public override async Task RemovedAsync(RemoveContentContext context, RedirectPart part) { if (!string.IsNullOrWhiteSpace(part.FromUrl) && context.NoActiveVersionLeft) { // Update entries from the index table after the session is committed. await _entries.UpdateEntriesAsync(); } }
void RemoveChildren(RemoveContentContext context, TerritoryPart part) { // Only remove first level of children, because they will remove their children foreach (var item in part.Children) { _contentManager.Remove(item); } }
void RemoveTerritoriesInHierarchy(RemoveContentContext context, TerritoryHierarchyPart part) { // I need to only invoke this on the first level. Those TerritoryPart will Remove their children. foreach (var item in part.TopLevel) { _contentManager.Remove(item); } }
public override Task RemovedAsync(RemoveContentContext context) { if (context.NoActiveVersionLeft) { return(_indexingTaskManager.CreateTaskAsync(context.ContentItem, IndexingTaskTypes.Delete)); } return(Task.CompletedTask); }
public override void Removed(RemoveContentContext context) { // TODO: ignore if this index is not configured for the content type foreach (var index in _luceneIndexManager.List()) { _luceneIndexManager.DeleteDocuments(index, new string[] { context.ContentItem.ContentItemId }); } }
public override Task RemovedAsync(RemoveContentContext context, AliasPart instance) { if (context.NoActiveVersionLeft) { return(_tagCache.RemoveTagAsync($"alias:{instance.Alias}")); } return(Task.CompletedTask); }
public override Task RemovedAsync(RemoveContentContext context) { if (context.NoActiveVersionLeft) { return(_tagCache.RemoveTagAsync($"contentitemid:{context.ContentItem.ContentItemId}")); } return(Task.CompletedTask); }
public void RemoveContentItem(ContentPart part, RemoveContentContext context) { var settings = part.As <ReadOnlySettings>(); if (settings.ReadOnly) { //context. } }
public override Task RemovedAsync(RemoveContentContext context, RedirectPart part) { if (!string.IsNullOrWhiteSpace(part.FromUrl)) { _entries.RemoveEntry(part.ContentItem.ContentItemId, part.FromUrl); } return(Task.CompletedTask); }
public override Task RemovedAsync(RemoveContentContext context, LocalizationPart part) { if (!String.IsNullOrWhiteSpace(part.LocalizationSet) && part.Culture != null && context.NoActiveVersionLeft) { // Update entries from the index table after the session is committed. return(_entries.UpdateEntriesAsync()); } return(Task.CompletedTask); }
public override async Task RemovedAsync(RemoveContentContext context, AutoroutePart part) { if (!String.IsNullOrWhiteSpace(part.Path) && context.NoActiveVersionLeft) { await _entries.RemoveEntryAsync(part.ContentItem.ContentItemId, part.Path); // Evict any dependent item from cache await RemoveTagAsync(part); } }
public override void Removed(RemoveContentContext context, AutoroutePart part) { if (!String.IsNullOrWhiteSpace(part.Path)) { _entries.RemoveEntry(part.ContentItem.ContentItemId, part.Path); // Evict any dependent item from cache RemoveTag(part); } }
protected override void Removed(RemoveContentContext context) { var contentTags = context.ContentItem.As <TagsPart>(); if (contentTags != null) { _signals.Trigger(TagCloudService.VandelayTagcloudTagschanged); } base.Removed(context); }
protected override void Removed(RemoveContentContext context) { var contentTags = context.ContentItem.As <TagsPart>(); if (contentTags != null) { _signals.Trigger(LocalizedTagsService._localizedTagcloudTagsChanged); } base.Removed(context); }
public override Task RemovedAsync(RemoveContentContext context, LocalizationPart part) { _entries.RemoveEntry(new LocalizationEntry() { ContentItemId = part.ContentItem.ContentItemId, LocalizationSet = part.LocalizationSet, Culture = part.Culture.ToLowerInvariant() }); return(Task.CompletedTask); }
public virtual void Removed(RemoveContentContext context) {}