From 1297254cc33d3566461634999704fcecab5d8d76 Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 11 Jun 2021 12:47:35 -0600 Subject: [PATCH] small cleanups --- src/Umbraco.Core/Migrations/MigrationPlan.cs | 2 +- .../Models/Packaging/CompiledPackage.cs | 4 - .../Packaging/ICreatedPackagesRepository.cs | 2 - .../Packaging/InstallationSummary.cs | 6 ++ .../Packaging/PackageMigrationPlan.cs | 1 - .../Packaging/PendingPackageMigrations.cs | 0 .../Packaging/UninstallationSummary.cs | 24 ------ .../UmbracoBuilder.CoreServices.cs | 1 + .../UmbracoBuilder.Services.cs | 1 + .../Packaging/AutomaticPackgeMigrationPlan.cs | 3 +- .../Packaging/IImportPackageBuilder.cs | 2 +- .../Packaging/ImportPackageBuilder.cs | 2 +- .../ImportPackageBuilderExpression.cs | 5 +- .../Packaging/PackageDataInstallation.cs | 82 +++++++++++-------- .../Packaging/PackageInstallation.cs | 27 ++++-- .../Packaging/PackageMigrationBase.cs | 3 +- .../Services/Implement/PackagingService.cs | 2 +- .../Packaging/PackageDataInstallationTests.cs | 2 +- .../Umbraco.Core/RuntimeStateTests.cs | 1 + .../Controllers/ContentTypeController.cs | 2 +- 20 files changed, 87 insertions(+), 85 deletions(-) rename src/{Umbraco.Infrastructure => Umbraco.Core}/Packaging/PendingPackageMigrations.cs (100%) delete mode 100644 src/Umbraco.Core/Packaging/UninstallationSummary.cs diff --git a/src/Umbraco.Core/Migrations/MigrationPlan.cs b/src/Umbraco.Core/Migrations/MigrationPlan.cs index 48cc50e1c4..8a35e21c67 100644 --- a/src/Umbraco.Core/Migrations/MigrationPlan.cs +++ b/src/Umbraco.Core/Migrations/MigrationPlan.cs @@ -105,7 +105,7 @@ namespace Umbraco.Cms.Core.Migrations where TMigration : IMigration => To(targetState, typeof(TMigration)); - public virtual MigrationPlan To(Guid targetState) + public MigrationPlan To(Guid targetState) where TMigration : IMigration => To(targetState, typeof(TMigration)); diff --git a/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs b/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs index 0b49e42d2b..5f6c3991a0 100644 --- a/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs +++ b/src/Umbraco.Core/Models/Packaging/CompiledPackage.cs @@ -11,12 +11,8 @@ namespace Umbraco.Cms.Core.Models.Packaging public class CompiledPackage { public FileInfo PackageFile { get; set; } - public string Name { get; set; } - - // TODO: Do we want this? Maybe for logging or something? public InstallWarnings Warnings { get; set; } = new InstallWarnings(); - public IEnumerable Macros { get; set; } // TODO: make strongly typed public IEnumerable Templates { get; set; } // TODO: make strongly typed public IEnumerable Stylesheets { get; set; } // TODO: make strongly typed diff --git a/src/Umbraco.Core/Packaging/ICreatedPackagesRepository.cs b/src/Umbraco.Core/Packaging/ICreatedPackagesRepository.cs index 187e2a3415..ba99fdd9a7 100644 --- a/src/Umbraco.Core/Packaging/ICreatedPackagesRepository.cs +++ b/src/Umbraco.Core/Packaging/ICreatedPackagesRepository.cs @@ -5,8 +5,6 @@ namespace Umbraco.Cms.Core.Packaging /// public interface ICreatedPackagesRepository : IPackageDefinitionRepository { - // TODO: This will need to change, it will export the XML - /// /// Creates the package file and returns it's physical path /// diff --git a/src/Umbraco.Core/Packaging/InstallationSummary.cs b/src/Umbraco.Core/Packaging/InstallationSummary.cs index fd2b60ccee..fa906ad1cc 100644 --- a/src/Umbraco.Core/Packaging/InstallationSummary.cs +++ b/src/Umbraco.Core/Packaging/InstallationSummary.cs @@ -12,6 +12,11 @@ namespace Umbraco.Cms.Core.Packaging [DataContract(IsReference = true)] public class InstallationSummary { + public InstallationSummary(string packageName) + { + PackageName = packageName; + } + public InstallWarnings Warnings { get; set; } = new InstallWarnings(); public IEnumerable DataTypesInstalled { get; set; } = Enumerable.Empty(); @@ -24,6 +29,7 @@ namespace Umbraco.Cms.Core.Packaging public IEnumerable StylesheetsInstalled { get; set; } = Enumerable.Empty(); public IEnumerable ContentInstalled { get; set; } = Enumerable.Empty(); public IEnumerable MediaInstalled { get; set; } = Enumerable.Empty(); + public string PackageName { get; } public override string ToString() { diff --git a/src/Umbraco.Core/Packaging/PackageMigrationPlan.cs b/src/Umbraco.Core/Packaging/PackageMigrationPlan.cs index 915d0d9e84..97cdcafba6 100644 --- a/src/Umbraco.Core/Packaging/PackageMigrationPlan.cs +++ b/src/Umbraco.Core/Packaging/PackageMigrationPlan.cs @@ -11,7 +11,6 @@ namespace Umbraco.Cms.Core.Packaging /// public abstract class PackageMigrationPlan : MigrationPlan, IDiscoverable { - // TODO: Should this take a name from an attribute or an abstract property? protected PackageMigrationPlan(string name) : base(name) { // A call to From must be done first diff --git a/src/Umbraco.Infrastructure/Packaging/PendingPackageMigrations.cs b/src/Umbraco.Core/Packaging/PendingPackageMigrations.cs similarity index 100% rename from src/Umbraco.Infrastructure/Packaging/PendingPackageMigrations.cs rename to src/Umbraco.Core/Packaging/PendingPackageMigrations.cs diff --git a/src/Umbraco.Core/Packaging/UninstallationSummary.cs b/src/Umbraco.Core/Packaging/UninstallationSummary.cs deleted file mode 100644 index 463933003a..0000000000 --- a/src/Umbraco.Core/Packaging/UninstallationSummary.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using Umbraco.Cms.Core.Models; -using Umbraco.Cms.Core.Models.Packaging; - -namespace Umbraco.Cms.Core.Packaging -{ - // TODO: Probably can be killed - [Serializable] - [DataContract(IsReference = true)] - public class UninstallationSummary - { - public IEnumerable DataTypesUninstalled { get; set; } = Enumerable.Empty(); - public IEnumerable LanguagesUninstalled { get; set; } = Enumerable.Empty(); - public IEnumerable DictionaryItemsUninstalled { get; set; } = Enumerable.Empty(); - public IEnumerable MacrosUninstalled { get; set; } = Enumerable.Empty(); - public IEnumerable TemplatesUninstalled { get; set; } = Enumerable.Empty(); - public IEnumerable DocumentTypesUninstalled { get; set; } = Enumerable.Empty(); - public IEnumerable StylesheetsUninstalled { get; set; } = Enumerable.Empty(); - - } -} diff --git a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs index ce81c5fc9d..f2cd5cfad7 100644 --- a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs +++ b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.CoreServices.cs @@ -38,6 +38,7 @@ using Umbraco.Cms.Infrastructure.Media; using Umbraco.Cms.Infrastructure.Migrations; using Umbraco.Cms.Infrastructure.Migrations.Install; using Umbraco.Cms.Infrastructure.Migrations.PostMigrations; +using Umbraco.Cms.Infrastructure.Packaging; using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Infrastructure.Runtime; using Umbraco.Cms.Infrastructure.Search; diff --git a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs index 22464b663b..134ffc070c 100644 --- a/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs +++ b/src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Services.cs @@ -14,6 +14,7 @@ using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.Routing; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Services.Implement; +using Umbraco.Cms.Infrastructure.Packaging; using Umbraco.Extensions; namespace Umbraco.Cms.Infrastructure.DependencyInjection diff --git a/src/Umbraco.Infrastructure/Packaging/AutomaticPackgeMigrationPlan.cs b/src/Umbraco.Infrastructure/Packaging/AutomaticPackgeMigrationPlan.cs index bc191ee660..c509d4f9bc 100644 --- a/src/Umbraco.Infrastructure/Packaging/AutomaticPackgeMigrationPlan.cs +++ b/src/Umbraco.Infrastructure/Packaging/AutomaticPackgeMigrationPlan.cs @@ -1,10 +1,11 @@ using System; using System.Xml.Linq; +using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Migrations; using Umbraco.Extensions; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { /// /// Used to automatically indicate that a package has an embedded package data manifest that needs to be installed diff --git a/src/Umbraco.Infrastructure/Packaging/IImportPackageBuilder.cs b/src/Umbraco.Infrastructure/Packaging/IImportPackageBuilder.cs index b10d0dfca4..994ac643c6 100644 --- a/src/Umbraco.Infrastructure/Packaging/IImportPackageBuilder.cs +++ b/src/Umbraco.Infrastructure/Packaging/IImportPackageBuilder.cs @@ -3,7 +3,7 @@ using System.Xml.Linq; using Umbraco.Cms.Infrastructure.Migrations.Expressions; using Umbraco.Cms.Infrastructure.Migrations.Expressions.Common; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { public interface IImportPackageBuilder : IFluentBuilder { diff --git a/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilder.cs b/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilder.cs index 707747ab32..09c4ec74a5 100644 --- a/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilder.cs +++ b/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilder.cs @@ -5,7 +5,7 @@ using Umbraco.Cms.Infrastructure.Migrations; using Umbraco.Cms.Infrastructure.Migrations.Expressions; using Umbraco.Cms.Infrastructure.Migrations.Expressions.Common; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { internal class ImportPackageBuilder : ExpressionBuilderBase, IImportPackageBuilder, IExecutableBuilder { diff --git a/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs b/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs index edbfc7ecf0..441109f2ca 100644 --- a/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs +++ b/src/Umbraco.Infrastructure/Packaging/ImportPackageBuilderExpression.cs @@ -1,10 +1,11 @@ using System; using System.Xml.Linq; using Microsoft.Extensions.Logging; +using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Migrations; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { internal class ImportPackageBuilderExpression : MigrationExpressionBase { @@ -46,7 +47,7 @@ namespace Umbraco.Cms.Core.Packaging { xml = PackageDataManifest; } - + InstallationSummary installationSummary = _packagingService.InstallCompiledPackageData(xml); Logger.LogInformation($"Package migration executed. Summary: {installationSummary}"); diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs index 0a56dfa913..56228c4c5f 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs @@ -7,12 +7,14 @@ using System.Xml.Linq; using System.Xml.XPath; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Umbraco.Cms.Core; using Umbraco.Cms.Core.Collections; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.Entities; using Umbraco.Cms.Core.Models.Packaging; +using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.PropertyEditors; using Umbraco.Cms.Core.Scoping; using Umbraco.Cms.Core.Serialization; @@ -20,7 +22,7 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; using Umbraco.Extensions; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { public class PackageDataInstallation { @@ -83,7 +85,7 @@ namespace Umbraco.Cms.Core.Packaging { using (var scope = _scopeProvider.CreateScope()) { - var installationSummary = new InstallationSummary + var installationSummary = new InstallationSummary(compiledPackage.Name) { Warnings = compiledPackage.Warnings, DataTypesInstalled = ImportDataTypes(compiledPackage.DataTypes.ToList(), userId), @@ -133,10 +135,10 @@ namespace Umbraco.Cms.Core.Packaging int userId, IContentTypeBaseService typeService, IContentServiceBase service) - where T: class, IContentBase - where S: IContentTypeComposition + where T : class, IContentBase + where S : IContentTypeComposition { - return docs.SelectMany(x => ImportContentBase( + return docs.SelectMany(x => ImportContentBase( x.XmlData.Elements().Where(doc => (string)doc.Attribute("isDoc") == string.Empty), -1, importedDocumentTypes, @@ -160,8 +162,8 @@ namespace Umbraco.Cms.Core.Packaging int userId, IContentTypeBaseService typeService, IContentServiceBase service) - where T: class, IContentBase - where S: IContentTypeComposition + where T : class, IContentBase + where S : IContentTypeComposition { var contents = ParseContentBaseRootXml(roots, parentId, importedDocumentTypes, typeService, service).ToList(); @@ -193,8 +195,8 @@ namespace Umbraco.Cms.Core.Packaging IDictionary importedContentTypes, IContentTypeBaseService typeService, IContentServiceBase service) - where T: class, IContentBase - where S: IContentTypeComposition + where T : class, IContentBase + where S : IContentTypeComposition { var contents = new List(); foreach (var root in roots) @@ -207,8 +209,9 @@ namespace Umbraco.Cms.Core.Packaging importedContentTypes.Add(contentTypeAlias, contentType); } - var content = CreateContentFromXml(root, importedContentTypes[contentTypeAlias], default(T), parentId, service); - if (content == null) continue; + var content = CreateContentFromXml(root, importedContentTypes[contentTypeAlias], default, parentId, service); + if (content == null) + continue; contents.Add(content); @@ -217,7 +220,7 @@ namespace Umbraco.Cms.Core.Packaging if (children.Count > 0) { - contents.AddRange(CreateContentFromXml(children, content, importedContentTypes, typeService, service).WhereNotNull()); + contents.AddRange(CreateContentFromXml(children, content, importedContentTypes, typeService, service).WhereNotNull()); } } return contents; @@ -229,8 +232,8 @@ namespace Umbraco.Cms.Core.Packaging IDictionary importedContentTypes, IContentTypeBaseService typeService, IContentServiceBase service) - where T: class, IContentBase - where S: IContentTypeComposition + where T : class, IContentBase + where S : IContentTypeComposition { var list = new List(); foreach (var child in children) @@ -254,7 +257,7 @@ namespace Umbraco.Cms.Core.Packaging select grand).ToList(); if (grandChildren.Any()) - list.AddRange(CreateContentFromXml(grandChildren, content,importedContentTypes, typeService, service)); + list.AddRange(CreateContentFromXml(grandChildren, content, importedContentTypes, typeService, service)); } return list; @@ -266,8 +269,8 @@ namespace Umbraco.Cms.Core.Packaging T parent, int parentId, IContentServiceBase service) - where T: class, IContentBase - where S: IContentTypeComposition + where T : class, IContentBase + where S : IContentTypeComposition { var key = Guid.Empty; if (element.Attribute("key") != null && Guid.TryParse(element.Attribute("key").Value, out key)) @@ -417,7 +420,7 @@ namespace Umbraco.Cms.Core.Packaging /// An enumerable list of generated ContentTypes public IReadOnlyList ImportDocumentTypes(IEnumerable docTypeElements, int userId) { - return ImportDocumentTypes(docTypeElements.ToList(), true, userId, _contentTypeService); + return ImportDocumentTypes(docTypeElements.ToList(), true, userId, _contentTypeService); } /// @@ -428,7 +431,7 @@ namespace Umbraco.Cms.Core.Packaging /// Optional id of the User performing the operation. Default is zero (admin). /// An enumerable list of generated ContentTypes public IReadOnlyList ImportDocumentTypes(IReadOnlyCollection unsortedDocumentTypes, bool importStructure, int userId, IContentTypeBaseService service) - where T: class, IContentTypeComposition + where T : class, IContentTypeComposition { var importedContentTypes = new Dictionary(); @@ -515,7 +518,8 @@ namespace Umbraco.Cms.Core.Packaging var alias = documentType.Element("Info").Element("Alias").Value; var structureElement = documentType.Element("Structure"); //Ensure that we only update ContentTypes which has actual structure-elements - if (structureElement == null || structureElement.Elements().Any() == false) continue; + if (structureElement == null || structureElement.Elements().Any() == false) + continue; var updated = UpdateContentTypesStructure(importedContentTypes[alias], structureElement, importedContentTypes, service); updatedContentTypes.Add(updated); @@ -627,7 +631,7 @@ namespace Umbraco.Cms.Core.Packaging } else { - return new ContentType(_shortStringHelper, (IContentType) parent, alias) as T; + return new ContentType(_shortStringHelper, (IContentType)parent, alias) as T; } } @@ -731,7 +735,8 @@ namespace Umbraco.Cms.Core.Packaging var template = _fileService.GetTemplate(alias.ToSafeAlias(_shortStringHelper)); if (template != null) { - if (allowedTemplates.Any(x => x.Id == template.Id)) continue; + if (allowedTemplates.Any(x => x.Id == template.Id)) + continue; allowedTemplates.Add(template); } else @@ -758,7 +763,7 @@ namespace Umbraco.Cms.Core.Packaging } private void UpdateContentTypesTabs(T contentType, XElement tabElement) - where T: IContentTypeComposition + where T : IContentTypeComposition { if (tabElement == null) return; @@ -785,7 +790,7 @@ namespace Umbraco.Cms.Core.Packaging } private void UpdateContentTypesProperties(T contentType, XElement genericPropertiesElement) - where T: IContentTypeComposition + where T : IContentTypeComposition { var properties = genericPropertiesElement.Elements("GenericProperty"); foreach (var property in properties) @@ -830,9 +835,10 @@ namespace Umbraco.Cms.Core.Packaging property.Element("Name").Value, dataTypeDefinitionId, property.Element("Type").Value.Trim()); //convert to a label! - dataTypeDefinition = _dataTypeService.GetByEditorAlias(Cms.Core.Constants.PropertyEditors.Aliases.Label).FirstOrDefault(); + dataTypeDefinition = _dataTypeService.GetByEditorAlias(Constants.PropertyEditors.Aliases.Label).FirstOrDefault(); //if for some odd reason this isn't there then ignore - if (dataTypeDefinition == null) continue; + if (dataTypeDefinition == null) + continue; } var sortOrder = 0; @@ -878,7 +884,7 @@ namespace Umbraco.Cms.Core.Packaging } private T UpdateContentTypesStructure(T contentType, XElement structureElement, IReadOnlyDictionary importedContentTypes, IContentTypeBaseService service) - where T: IContentTypeComposition + where T : IContentTypeComposition { var allowedChildren = contentType.AllowedContentTypes.ToList(); int sortOrder = allowedChildren.Any() ? allowedChildren.Last().SortOrder : 0; @@ -895,7 +901,8 @@ namespace Umbraco.Cms.Core.Packaging continue; } - if (allowedChildren.Any(x => x.Id.IsValueCreated && x.Id.Value == allowedChild.Id)) continue; + if (allowedChildren.Any(x => x.Id.IsValueCreated && x.Id.Value == allowedChild.Id)) + continue; allowedChildren.Add(new ContentTypeSort(new Lazy(() => allowedChild.Id), sortOrder, allowedChild.Alias)); sortOrder++; @@ -911,7 +918,7 @@ namespace Umbraco.Cms.Core.Packaging /// /// private S FindContentTypeByAlias(string contentTypeAlias, IContentTypeBaseService typeService) - where S: IContentTypeComposition + where S : IContentTypeComposition { var contentType = typeService.Get(contentTypeAlias); @@ -1117,7 +1124,7 @@ namespace Umbraco.Cms.Core.Packaging private static bool DictionaryValueIsNew(IEnumerable translations, XElement valueElement) { return translations.All(t => - String.Compare(t.Language.IsoCode, valueElement.Attribute("LanguageCultureAlias").Value, + string.Compare(t.Language.IsoCode, valueElement.Attribute("LanguageCultureAlias").Value, StringComparison.InvariantCultureIgnoreCase) != 0 ); } @@ -1150,7 +1157,8 @@ namespace Umbraco.Cms.Core.Packaging { var isoCode = languageElement.AttributeValue("CultureAlias"); var existingLanguage = _localizationService.GetLanguageByIsoCode(isoCode); - if (existingLanguage != null) continue; + if (existingLanguage != null) + continue; var langauge = new Language(_globalSettings, isoCode) { CultureName = languageElement.AttributeValue("FriendlyName") @@ -1245,7 +1253,8 @@ namespace Umbraco.Cms.Core.Packaging sortOrder = int.Parse(sortOrderAttribute.Value); } - if (macro.Properties.Values.Any(x => string.Equals(x.Alias, propertyAlias, StringComparison.OrdinalIgnoreCase))) continue; + if (macro.Properties.Values.Any(x => string.Equals(x.Alias, propertyAlias, StringComparison.OrdinalIgnoreCase))) + continue; macro.Properties.Add(new MacroProperty(propertyAlias, propertyName, sortOrder, editorAlias)); sortOrder++; } @@ -1264,15 +1273,18 @@ namespace Umbraco.Cms.Core.Packaging foreach (var n in stylesheetElements) { var stylesheetName = n.Element("Name")?.Value; - if (stylesheetName.IsNullOrWhiteSpace()) continue; + if (stylesheetName.IsNullOrWhiteSpace()) + continue; var s = _fileService.GetStylesheetByName(stylesheetName); if (s == null) { var fileName = n.Element("FileName")?.Value; - if (fileName == null) continue; + if (fileName == null) + continue; var content = n.Element("Content")?.Value; - if (content == null) continue; + if (content == null) + continue; s = new Stylesheet(fileName) { Content = content }; _fileService.SaveStylesheet(s); diff --git a/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs index d7394582ce..5138a4c630 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageInstallation.cs @@ -2,9 +2,10 @@ using System; using System.Linq; using System.Xml.Linq; using Umbraco.Cms.Core.Models.Packaging; +using Umbraco.Cms.Core.Packaging; using Umbraco.Extensions; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { public class PackageInstallation : IPackageInstallation @@ -24,7 +25,8 @@ namespace Umbraco.Cms.Core.Packaging public CompiledPackage ReadPackage(XDocument packageXmlFile) { - if (packageXmlFile == null) throw new ArgumentNullException(nameof(packageXmlFile)); + if (packageXmlFile == null) + throw new ArgumentNullException(nameof(packageXmlFile)); var compiledPackage = _parser.ToCompiledPackage(packageXmlFile); return compiledPackage; @@ -40,13 +42,20 @@ namespace Umbraco.Cms.Core.Packaging InstallationSummary installationSummary = _packageDataInstallation.InstallPackageData(compiledPackage, userId); //make sure the definition is up to date with everything - foreach (var x in installationSummary.DataTypesInstalled) packageDefinition.DataTypes.Add(x.Id.ToInvariantString()); - foreach (var x in installationSummary.LanguagesInstalled) packageDefinition.Languages.Add(x.Id.ToInvariantString()); - foreach (var x in installationSummary.DictionaryItemsInstalled) packageDefinition.DictionaryItems.Add(x.Id.ToInvariantString()); - foreach (var x in installationSummary.MacrosInstalled) packageDefinition.Macros.Add(x.Id.ToInvariantString()); - foreach (var x in installationSummary.TemplatesInstalled) packageDefinition.Templates.Add(x.Id.ToInvariantString()); - foreach (var x in installationSummary.DocumentTypesInstalled) packageDefinition.DocumentTypes.Add(x.Id.ToInvariantString()); - foreach (var x in installationSummary.StylesheetsInstalled) packageDefinition.Stylesheets.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.DataTypesInstalled) + packageDefinition.DataTypes.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.LanguagesInstalled) + packageDefinition.Languages.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.DictionaryItemsInstalled) + packageDefinition.DictionaryItems.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.MacrosInstalled) + packageDefinition.Macros.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.TemplatesInstalled) + packageDefinition.Templates.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.DocumentTypesInstalled) + packageDefinition.DocumentTypes.Add(x.Id.ToInvariantString()); + foreach (var x in installationSummary.StylesheetsInstalled) + packageDefinition.Stylesheets.Add(x.Id.ToInvariantString()); var contentInstalled = installationSummary.ContentInstalled.ToList(); packageDefinition.ContentNodeId = contentInstalled.Count > 0 ? contentInstalled[0].Id.ToInvariantString() : null; diff --git a/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs b/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs index 03db5d17b1..ebe6f82a8f 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageMigrationBase.cs @@ -1,8 +1,9 @@ +using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Migrations; using Umbraco.Cms.Infrastructure.Migrations.Expressions.Execute; -namespace Umbraco.Cms.Core.Packaging +namespace Umbraco.Cms.Infrastructure.Packaging { public abstract class PackageMigrationBase : MigrationBase diff --git a/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs b/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs index fab118001a..93028af308 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/PackagingService.cs @@ -51,7 +51,7 @@ namespace Umbraco.Cms.Core.Services.Implement var importingPackageNotification = new ImportingPackageNotification(compiledPackage.Name); if (_eventAggregator.PublishCancelable(importingPackageNotification)) { - return new InstallationSummary(); + return new InstallationSummary(compiledPackage.Name); } var summary = _packageInstallation.InstallPackageData(compiledPackage, userId, out _); diff --git a/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/PackageDataInstallationTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/PackageDataInstallationTests.cs index 1b065d7dcb..f75c359498 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/PackageDataInstallationTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Core/Packaging/PackageDataInstallationTests.cs @@ -10,10 +10,10 @@ using Umbraco.Cms.Core.Composing; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.Packaging; -using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.PropertyEditors; using Umbraco.Cms.Core.Scoping; using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Infrastructure.Packaging; using Umbraco.Cms.Infrastructure.Persistence.Dtos; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Cms.Tests.Integration.Testing; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs index 317c0aa474..c9838361c6 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Core/RuntimeStateTests.cs @@ -9,6 +9,7 @@ using Umbraco.Cms.Core.DependencyInjection; using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.Migrations; +using Umbraco.Cms.Infrastructure.Packaging; using Umbraco.Cms.Tests.Common.Testing; using Umbraco.Cms.Tests.Integration.Testing; diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index 79ea6f6329..d6c045af0b 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -17,11 +17,11 @@ using Umbraco.Cms.Core.Hosting; using Umbraco.Cms.Core.Mapping; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Models.ContentEditing; -using Umbraco.Cms.Core.Packaging; using Umbraco.Cms.Core.PropertyEditors; using Umbraco.Cms.Core.Security; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; +using Umbraco.Cms.Infrastructure.Packaging; using Umbraco.Cms.Web.Common.ActionsResults; using Umbraco.Cms.Web.Common.Attributes; using Umbraco.Cms.Web.Common.Authorization;