diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs index ed160356d9..923c809a38 100644 --- a/src/Umbraco.Core/Services/ContentService.cs +++ b/src/Umbraco.Core/Services/ContentService.cs @@ -269,61 +269,7 @@ public class ContentService : RepositoryService, IContentService #region Rollback public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Constants.Security.SuperUserId) - { - EventMessages evtMsgs = EventMessagesFactory.Get(); - - // Get the current copy of the node - IContent? content = GetById(id); - - // Get the version - IContent? version = GetVersion(versionId); - - // Good old null checks - if (content == null || version == null || content.Trashed) - { - return new OperationResult(OperationResultType.FailedCannot, evtMsgs); - } - - // Store the result of doing the save of content for the rollback - OperationResult rollbackSaveResult; - - using (ICoreScope scope = ScopeProvider.CreateCoreScope()) - { - var rollingBackNotification = new ContentRollingBackNotification(content, evtMsgs); - if (scope.Notifications.PublishCancelable(rollingBackNotification)) - { - scope.Complete(); - return OperationResult.Cancel(evtMsgs); - } - - // Copy the changes from the version - content.CopyFrom(version, culture); - - // Save the content for the rollback - rollbackSaveResult = Save(content, userId); - - // Depending on the save result - is what we log & audit along with what we return - if (rollbackSaveResult.Success == false) - { - // Log the error/warning - _logger.LogError( - "User '{UserId}' was unable to rollback content '{ContentId}' to version '{VersionId}'", userId, id, versionId); - } - else - { - scope.Notifications.Publish( - new ContentRolledBackNotification(content, evtMsgs).WithStateFrom(rollingBackNotification)); - - // Logging & Audit message - _logger.LogInformation("User '{UserId}' rolled back content '{ContentId}' to version '{VersionId}'", userId, id, versionId); - Audit(AuditType.RollBack, userId, id, $"Content '{content.Name}' was rolled back to version '{versionId}'"); - } - - scope.Complete(); - } - - return rollbackSaveResult; - } + => VersionOperationService.Rollback(id, versionId, culture, userId); #endregion