Beispiel #1
0
        protected async Task <(IAllowSync, IDeleteGraphSyncer?)> GetDeleteGraphSyncerIfDeleteAllowed(
            ContentItem contentItem,
            IContentItemVersion contentItemVersion,
            SyncOperation syncOperation)
        {
            try
            {
                IDeleteGraphSyncer deleteGraphSyncer = _serviceProvider.GetRequiredService <IDeleteGraphSyncer>();

                IAllowSync allowSync = await deleteGraphSyncer.DeleteAllowed(
                    contentItem,
                    contentItemVersion,
                    syncOperation);

                return(allowSync, deleteGraphSyncer);
            }
            catch (Exception exception)
            {
                string contentType = GetContentTypeDisplayName(contentItem);

                //todo: will get logged twice, but want to keep the param version
                _logger.LogError(exception, "Unable to check if the '{ContentItem}' {ContentType} can be {DeleteOperation} from the {GraphReplicaSetName} graph.",
                                 contentItem.DisplayText, contentType, syncOperation.ToString("PrP", null).ToLower(), contentItemVersion.GraphReplicaSetName);

                await _notifier.Add(GetSyncOperationCancelledUserMessage(syncOperation, contentItem.DisplayText, contentType),
                                    $"Unable to check if the '{contentItem.DisplayText}' {contentType} can be {syncOperation.ToString("PrP", null).ToLower()} from the {contentItemVersion.GraphReplicaSetName} graph.",
                                    exception : exception);

                throw;
            }
        }
Beispiel #2
0
        public async Task <IActionResult> TriggerSyncValidation(ValidationScope scope)
        {
            if (!await _authorizationService.AuthorizeAsync(User, Permissions.AdministerGraphs))
            {
                return(Forbid());
            }

            IValidateAndRepairResults?validateAndRepairResults = null;

            try
            {
                //todo: display page straight away : show progress (log) in page
                //todo: add name of user who triggered into logs (if not already sussable)
                _logger.LogInformation("User sync validation triggered");
                validateAndRepairResults = await _validateAndRepairGraph.ValidateGraph(scope);
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "User triggered sync validation failed.");
                await _notifier.Add("Unable to validate graph sync.", exception : e);
            }
            return(View(new TriggerSyncValidationViewModel
            {
                ValidateAndRepairResults = validateAndRepairResults,
                Scope = scope
            }));
        }
        public async Task DeleteItemsOfType(string contentTypeName)
        {
            try
            {
                //todo: does it need to be 2 phase?
                IDeleteTypeGraphSyncer publishedDeleteGraphSyncer = _serviceProvider.GetRequiredService <IDeleteTypeGraphSyncer>();
                IDeleteTypeGraphSyncer previewDeleteGraphSyncer   = _serviceProvider.GetRequiredService <IDeleteTypeGraphSyncer>();

                // delete all nodes by type
                await Task.WhenAll(
                    publishedDeleteGraphSyncer.DeleteNodesByType(GraphReplicaSetNames.Published, contentTypeName),
                    previewDeleteGraphSyncer.DeleteNodesByType(GraphReplicaSetNames.Preview, contentTypeName));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Graph resync failed after deleting the {ContentType} content type.",
                                 contentTypeName);
                _notifier.Add(NotifyType.Error, new LocalizedHtmlString(nameof(GraphSyncContentDefinitionHandler),
                                                                        $"Graph resync failed after deleting the {contentTypeName} content type."));
                throw;
            }
        }