From 94eb49cdb6fae72c4e5129d9ce5ef92a4942bc6e Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Mon, 23 May 2022 10:30:03 +0200 Subject: [PATCH] Merge IContentTypeWithHistoryCleanup with IContentType.cs --- 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, 18 insertions(+), 31 deletions(-) diff --git a/src/Umbraco.Core/Models/ContentType.cs b/src/Umbraco.Core/Models/ContentType.cs index 9c21cf5e80..1e011bbd07 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, IContentTypeWithHistoryCleanup + public class ContentType : ContentTypeCompositionBase, IContentType { public const bool SupportsPublishingConst = true; diff --git a/src/Umbraco.Core/Models/IContentType.cs b/src/Umbraco.Core/Models/IContentType.cs index e3fd83fcd3..4d693f9a50 100644 --- a/src/Umbraco.Core/Models/IContentType.cs +++ b/src/Umbraco.Core/Models/IContentType.cs @@ -4,19 +4,6 @@ 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 /// @@ -70,5 +57,11 @@ 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 bacab0b7cf..c45af69b23 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 IContentTypeWithHistoryCleanup targetWithHistoryCleanup) + if (target is IContentType targetWithHistoryCleanup) { MapHistoryCleanup(source, targetWithHistoryCleanup); } @@ -147,7 +147,7 @@ namespace Umbraco.Cms.Core.Models.Mapping : _fileService.GetTemplate(source.DefaultTemplate)); } - private static void MapHistoryCleanup(DocumentTypeSave source, IContentTypeWithHistoryCleanup target) + private static void MapHistoryCleanup(DocumentTypeSave source, IContentType 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 IContentTypeWithHistoryCleanup sourceWithHistoryCleanup) + if (source is IContentType sourceWithHistoryCleanup) { target.HistoryCleanup = new HistoryCleanupViewModel { diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs index c91f536b38..00f9dc2a18 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 IContentTypeWithHistoryCleanup withCleanup && withCleanup.HistoryCleanup is not null) + if (contentType is IContentType 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 f0bca5f1ea..a45c26a44d 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 IContentTypeWithHistoryCleanup withCleanup) + if (contentType is IContentType withCleanup) { UpdateHistoryCleanupPolicy(withCleanup, documentType.Element("HistoryCleanupPolicy")); } @@ -898,7 +898,7 @@ namespace Umbraco.Cms.Infrastructure.Packaging return contentType; } - private void UpdateHistoryCleanupPolicy(IContentTypeWithHistoryCleanup withCleanup, XElement? element) + private void UpdateHistoryCleanupPolicy(IContentType 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 9e2f0257b6..9859b1e69a 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 IContentTypeWithHistoryCleanup entityWithHistoryCleanup) + if (entity is IContentType entityWithHistoryCleanup) { ContentVersionCleanupPolicyDto dto = new ContentVersionCleanupPolicyDto() { diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs index 5866589c6f..6e01d2b260 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs @@ -169,9 +169,6 @@ 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(); @@ -210,9 +207,6 @@ 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 cc446e0ea6..e7ddd13e0b 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(() =>