From 9719f8ac560468dcfa2f92869ac49fcdbd8a028d Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Mon, 23 May 2022 10:33:02 +0200 Subject: [PATCH] Revert "Merge IContentTypeWithHistoryCleanup with IContentType.cs" This reverts commit 94eb49cdb6fae72c4e5129d9ce5ef92a4942bc6e. --- src/Umbraco.Core/Models/ContentType.cs | 2 +- src/Umbraco.Core/Models/IContentType.cs | 19 +++++++++++++------ .../Mapping/ContentTypeMapDefinition.cs | 6 +++--- .../Services/EntityXmlSerializer.cs | 2 +- .../Packaging/PackageDataInstallation.cs | 4 ++-- .../Implement/ContentTypeRepository.cs | 2 +- .../Runtime/CoreRuntime.cs | 6 ++++++ .../Packaging/PackageDataInstallationTests.cs | 8 ++++---- 8 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index 1e011bbd07..9c21cf5e80 100644 --- a/src/Umbraco.Core/Models/ContentType.cs +++ b/src/Umbraco.Core/Models/ContentType.cs @@ -13,7 +13,7 @@ namespace Umbraco.Cms.Core.Models /// [Serializable] [DataContract(IsReference = true)] - public class ContentType : ContentTypeCompositionBase, IContentType + public class ContentType : ContentTypeCompositionBase, IContentTypeWithHistoryCleanup { public const bool SupportsPublishingConst = true; diff --git a/src/Umbraco.Core/Models/IContentType.cs b/src/Umbraco.Core/Models/IContentType.cs index 4d693f9a50..e3fd83fcd3 100644 --- a/src/Umbraco.Core/Models/IContentType.cs +++ b/src/Umbraco.Core/Models/IContentType.cs @@ -4,6 +4,19 @@ using Umbraco.Cms.Core.Models.ContentEditing; namespace Umbraco.Cms.Core.Models { + /// + /// Defines a content type that contains a history cleanup policy. + /// + [Obsolete("This will be merged into IContentType in Umbraco 10.")] + public interface IContentTypeWithHistoryCleanup : IContentType + { + /// + /// Gets or sets the history cleanup configuration. + /// + /// The history cleanup configuration. + HistoryCleanup? HistoryCleanup { get; set; } + } + /// /// Defines a ContentType, which Content is based on /// @@ -57,11 +70,5 @@ namespace Umbraco.Cms.Core.Models /// /// IContentType DeepCloneWithResetIdentities(string newAlias); - - /// - /// Gets or sets the history cleanup configuration. - /// - /// The history cleanup configuration. - HistoryCleanup? HistoryCleanup { get; set; } } } diff --git a/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs b/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs index c45af69b23..bacab0b7cf 100644 --- a/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs +++ b/src/Umbraco.Core/Models/Mapping/ContentTypeMapDefinition.cs @@ -131,7 +131,7 @@ namespace Umbraco.Cms.Core.Models.Mapping MapSaveToTypeBase(source, target, context); MapComposition(source, target, alias => _contentTypeService.Get(alias)); - if (target is IContentType targetWithHistoryCleanup) + if (target is IContentTypeWithHistoryCleanup targetWithHistoryCleanup) { MapHistoryCleanup(source, targetWithHistoryCleanup); } @@ -147,7 +147,7 @@ namespace Umbraco.Cms.Core.Models.Mapping : _fileService.GetTemplate(source.DefaultTemplate)); } - private static void MapHistoryCleanup(DocumentTypeSave source, IContentType target) + private static void MapHistoryCleanup(DocumentTypeSave source, IContentTypeWithHistoryCleanup target) { // If source history cleanup is null we don't have to map all properties if (source.HistoryCleanup is null) @@ -209,7 +209,7 @@ namespace Umbraco.Cms.Core.Models.Mapping { MapTypeToDisplayBase(source, target); - if (source is IContentType sourceWithHistoryCleanup) + if (source is IContentTypeWithHistoryCleanup sourceWithHistoryCleanup) { target.HistoryCleanup = new HistoryCleanupViewModel { diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index 00f9dc2a18..c91f536b38 100644 --- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs +++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs @@ -511,7 +511,7 @@ namespace Umbraco.Cms.Core.Services genericProperties, tabs); - if (contentType is IContentType withCleanup && withCleanup.HistoryCleanup is not null) + if (contentType is IContentTypeWithHistoryCleanup withCleanup && withCleanup.HistoryCleanup is not null) { xml.Add(SerializeCleanupPolicy(withCleanup.HistoryCleanup)); } diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs index a45c26a44d..f0bca5f1ea 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs @@ -890,7 +890,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging UpdateContentTypesPropertyGroups(contentType, documentType.Element("Tabs")); UpdateContentTypesProperties(contentType, documentType.Element("GenericProperties")); - if (contentType is IContentType withCleanup) + if (contentType is IContentTypeWithHistoryCleanup withCleanup) { UpdateHistoryCleanupPolicy(withCleanup, documentType.Element("HistoryCleanupPolicy")); } @@ -898,7 +898,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging return contentType; } - private void UpdateHistoryCleanupPolicy(IContentType withCleanup, XElement? element) + private void UpdateHistoryCleanupPolicy(IContentTypeWithHistoryCleanup withCleanup, XElement? element) { if (element == null) { diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs index 9859b1e69a..9e2f0257b6 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/ContentTypeRepository.cs @@ -302,7 +302,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement { // historyCleanup property is not mandatory for api endpoint, handle the case where it's not present. // DocumentTypeSave doesn't handle this for us like ContentType constructors do. - if (entity is IContentType entityWithHistoryCleanup) + if (entity is IContentTypeWithHistoryCleanup entityWithHistoryCleanup) { ContentVersionCleanupPolicyDto dto = new ContentVersionCleanupPolicyDto() { diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 6e01d2b260..5866589c6f 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -169,6 +169,9 @@ namespace Umbraco.Cms.Infrastructure.Runtime // Acquire the main domain - if this fails then anything that should be registered with MainDom will not operate AcquireMainDom(); + // TODO (V10): Remove this obsoleted notification publish. + await _eventAggregator.PublishAsync(new UmbracoApplicationMainDomAcquiredNotification(), cancellationToken); + // Notify for unattended install await _eventAggregator.PublishAsync(new RuntimeUnattendedInstallNotification(), cancellationToken); DetermineRuntimeLevel(); @@ -207,6 +210,9 @@ namespace Umbraco.Cms.Infrastructure.Runtime break; } + // TODO (V10): Remove this obsoleted notification publish + await _eventAggregator.PublishAsync(new UmbracoApplicationComponentsInstallingNotification(State.Level), cancellationToken); + // Initialize the components _components.Initialize(); diff --git a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs index e7ddd13e0b..cc446e0ea6 100644 --- a/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs +++ b/tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Packaging/PackageDataInstallationTests.cs @@ -776,7 +776,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging // Act var contentTypes = PackageDataInstallation .ImportDocumentType(withoutCleanupPolicy, 0) - .OfType(); + .OfType(); // Assert Assert.Multiple(() => @@ -795,7 +795,7 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging // Act var contentTypes = PackageDataInstallation .ImportDocumentType(docTypeElement, 0) - .OfType(); + .OfType(); // Assert Assert.Multiple(() => @@ -817,11 +817,11 @@ namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Packaging // Act var contentTypes = PackageDataInstallation .ImportDocumentType(withCleanupPolicy, 0) - .OfType(); + .OfType(); var contentTypesUpdated = PackageDataInstallation .ImportDocumentType(withoutCleanupPolicy, 0) - .OfType(); + .OfType(); // Assert Assert.Multiple(() =>