AB3869 move packages to abstractions
This commit is contained in:
@@ -3,9 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
using File = System.IO.File;
|
||||
|
||||
@@ -14,13 +12,15 @@ namespace Umbraco.Core.Packaging
|
||||
/// <summary>
|
||||
/// Parses the xml document contained in a compiled (zip) Umbraco package
|
||||
/// </summary>
|
||||
internal class CompiledPackageXmlParser
|
||||
public class CompiledPackageXmlParser
|
||||
{
|
||||
private readonly ConflictingPackageData _conflictingPackageData;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
|
||||
public CompiledPackageXmlParser(ConflictingPackageData conflictingPackageData)
|
||||
public CompiledPackageXmlParser(ConflictingPackageData conflictingPackageData, IGlobalSettings globalSettings)
|
||||
{
|
||||
_conflictingPackageData = conflictingPackageData;
|
||||
_globalSettings = globalSettings;
|
||||
}
|
||||
|
||||
public CompiledPackage ToCompiledPackage(XDocument xml, FileInfo packageFile, string applicationRootFolder)
|
||||
@@ -133,12 +133,12 @@ namespace Umbraco.Core.Packaging
|
||||
return pathElement.TrimStart(new[] { '\\', '/', '~' }).Replace("/", "\\");
|
||||
}
|
||||
|
||||
private static string UpdatePathPlaceholders(string path)
|
||||
private string UpdatePathPlaceholders(string path)
|
||||
{
|
||||
if (path.Contains("[$"))
|
||||
{
|
||||
//this is experimental and undocumented...
|
||||
path = path.Replace("[$UMBRACO]", Current.Configs.Global().UmbracoPath);
|
||||
path = path.Replace("[$UMBRACO]", _globalSettings.UmbracoPath);
|
||||
path = path.Replace("[$CONFIG]", Constants.SystemDirectories.Config);
|
||||
path = path.Replace("[$DATA]", Constants.SystemDirectories.Data);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
|
||||
@@ -14,10 +14,12 @@ namespace Umbraco.Core.Packaging
|
||||
public class PackageDefinitionXmlParser
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
|
||||
public PackageDefinitionXmlParser(ILogger logger)
|
||||
public PackageDefinitionXmlParser(ILogger logger, IUmbracoVersion umbracoVersion)
|
||||
{
|
||||
_logger = logger;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
}
|
||||
|
||||
public PackageDefinition ToPackageDefinition(XElement xml)
|
||||
@@ -66,7 +68,7 @@ namespace Umbraco.Core.Packaging
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Warn<PackagesRepository>(e, "Could not add package actions to the package xml definition, the xml did not parse");
|
||||
_logger.Warn<PackageDefinitionXmlParser>(e, "Could not add package actions to the package xml definition, the xml did not parse");
|
||||
}
|
||||
|
||||
var packageXml = new XElement("package",
|
||||
@@ -76,7 +78,7 @@ namespace Umbraco.Core.Packaging
|
||||
new XAttribute("name", def.Name ?? string.Empty),
|
||||
new XAttribute("packagePath", def.PackagePath ?? string.Empty),
|
||||
new XAttribute("iconUrl", def.IconUrl ?? string.Empty),
|
||||
new XAttribute("umbVersion", def.UmbracoVersion),
|
||||
new XAttribute("umbVersion", def.UmbracoVersion ?? _umbracoVersion.Current),
|
||||
new XAttribute("packageGuid", def.PackageId),
|
||||
new XAttribute("view", def.PackageView ?? string.Empty),
|
||||
|
||||
@@ -104,11 +106,11 @@ namespace Umbraco.Core.Packaging
|
||||
new XElement("macros", string.Join(",", def.Macros ?? Array.Empty<string>())),
|
||||
new XElement("files", (def.Files ?? Array.Empty<string>()).Where(x => !x.IsNullOrWhiteSpace()).Select(x => new XElement("file", x))),
|
||||
new XElement("languages", string.Join(",", def.Languages ?? Array.Empty<string>())),
|
||||
new XElement("dictionaryitems", string.Join(",", def.DictionaryItems ?? Array.Empty<string>())));
|
||||
new XElement("dictionaryitems", string.Join(",", def.DictionaryItems ?? Array.Empty<string>())));
|
||||
|
||||
return packageXml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Umbraco.Core.Packaging
|
||||
/// <summary>
|
||||
/// Installs package files
|
||||
/// </summary>
|
||||
internal class PackageFileInstallation
|
||||
public class PackageFileInstallation
|
||||
{
|
||||
private readonly CompiledPackageXmlParser _parser;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
@@ -85,7 +85,16 @@ namespace Umbraco.Core.Composing.CompositionExtensions
|
||||
/// <returns></returns>
|
||||
private static PackagesRepository CreatePackageRepository(IFactory factory, string packageRepoFileName)
|
||||
=> new PackagesRepository(
|
||||
factory.GetInstance<IContentService>(), factory.GetInstance<IContentTypeService>(), factory.GetInstance<IDataTypeService>(), factory.GetInstance<IFileService>(), factory.GetInstance<IMacroService>(), factory.GetInstance<ILocalizationService>(), factory.GetInstance<IIOHelper>(), factory.GetInstance<IEntityXmlSerializer>(), factory.GetInstance<ILogger>(),
|
||||
factory.GetInstance<IContentService>(),
|
||||
factory.GetInstance<IContentTypeService>(),
|
||||
factory.GetInstance<IDataTypeService>(),
|
||||
factory.GetInstance<IFileService>(),
|
||||
factory.GetInstance<IMacroService>(),
|
||||
factory.GetInstance<ILocalizationService>(),
|
||||
factory.GetInstance<IIOHelper>(),
|
||||
factory.GetInstance<IUmbracoVersion>(),
|
||||
factory.GetInstance<IEntityXmlSerializer>(),
|
||||
factory.GetInstance<ILogger>(),
|
||||
packageRepoFileName);
|
||||
|
||||
private static LocalizedTextServiceFileSources SourcesFactory(IFactory container)
|
||||
|
||||
@@ -6,13 +6,10 @@ using System.Web;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Umbraco.Core.Collections;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
@@ -206,7 +206,6 @@
|
||||
<Compile Include="Models\Membership\UserGroup.cs" />
|
||||
<Compile Include="Models\Membership\UserGroupExtensions.cs" />
|
||||
<Compile Include="Models\ObjectTypes.cs" />
|
||||
<Compile Include="Models\Packaging\PackageDefinition.cs" />
|
||||
<Compile Include="Models\Property.cs" />
|
||||
<Compile Include="Models\PropertyCollection.cs" />
|
||||
<Compile Include="Models\PropertyType.cs" />
|
||||
@@ -216,6 +215,8 @@
|
||||
<Compile Include="Models\PublishedContent\VariationContextAccessorExtensions.cs" />
|
||||
<Compile Include="Models\Template.cs" />
|
||||
<Compile Include="Models\TemplateOnDisk.cs" />
|
||||
<Compile Include="Packaging\PackageDataInstallation.cs" />
|
||||
<Compile Include="Packaging\PackageInstallation.cs" />
|
||||
<Compile Include="Persistence\Mappers\SimpleContentTypeMapper.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\DelimitedValueValidator.cs" />
|
||||
<Compile Include="PropertyEditors\Validators\RegexValidator.cs" />
|
||||
@@ -325,14 +326,6 @@
|
||||
<Compile Include="Models\SimpleContentType.cs" />
|
||||
<Compile Include="PackageActions\AllowDoctype.cs" />
|
||||
<Compile Include="PackageActions\PublishRootDocument.cs" />
|
||||
<Compile Include="Packaging\CompiledPackageXmlParser.cs" />
|
||||
<Compile Include="Packaging\ICreatedPackagesRepository.cs" />
|
||||
<Compile Include="Packaging\IInstalledPackagesRepository.cs" />
|
||||
<Compile Include="Packaging\IPackageDefinitionRepository.cs" />
|
||||
<Compile Include="Packaging\IPackageInstallation.cs" />
|
||||
<Compile Include="Packaging\PackageDataInstallation.cs" />
|
||||
<Compile Include="Packaging\PackageDefinitionXmlParser.cs" />
|
||||
<Compile Include="Packaging\PackageFileInstallation.cs" />
|
||||
<Compile Include="Packaging\PackagesRepository.cs" />
|
||||
<Compile Include="Persistence\Dtos\AuditEntryDto.cs" />
|
||||
<Compile Include="Persistence\Dtos\ConsentDto.cs" />
|
||||
@@ -419,7 +412,6 @@
|
||||
<Compile Include="Models\Membership\UmbracoMembershipUser.cs" />
|
||||
<Compile Include="Models\Membership\User.cs" />
|
||||
<Compile Include="Models\MemberType.cs" />
|
||||
<Compile Include="Models\Packaging\InstallationSummary.cs" />
|
||||
<Compile Include="Models\PublishedContent\PublishedContentTypeFactory.cs" />
|
||||
<Compile Include="Models\PublishedContent\PublishedContentExtensionsForModels.cs" />
|
||||
<Compile Include="Models\PublishedContent\PublishedContentModel.cs" />
|
||||
@@ -473,8 +465,6 @@
|
||||
<Compile Include="Persistence\Dtos\UserStartNodeDto.cs" />
|
||||
<Compile Include="Models\UserExtensions.cs" />
|
||||
<Compile Include="ObjectJsonExtensions.cs" />
|
||||
<Compile Include="Models\Packaging\UninstallationSummary.cs" />
|
||||
<Compile Include="Packaging\PackageInstallation.cs" />
|
||||
<Compile Include="Persistence\BulkDataReader.cs" />
|
||||
<Compile Include="Persistence\DatabaseAnnotations\ConstraintAttribute.cs" />
|
||||
<Compile Include="Persistence\DatabaseAnnotations\ForeignKeyAttribute.cs" />
|
||||
@@ -889,5 +879,8 @@
|
||||
<Name>Umbraco.Abstractions</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\Packaging" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -41,6 +41,7 @@ namespace Umbraco.Tests.Packaging
|
||||
ServiceContext.ContentService, ServiceContext.ContentTypeService, ServiceContext.DataTypeService,
|
||||
ServiceContext.FileService, ServiceContext.MacroService, ServiceContext.LocalizationService,
|
||||
IOHelper,
|
||||
UmbracoVersion,
|
||||
Factory.GetInstance<IEntityXmlSerializer>(), Logger,
|
||||
"createdPackages.config",
|
||||
//temp paths
|
||||
|
||||
@@ -6,6 +6,7 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Packaging;
|
||||
@@ -40,7 +41,7 @@ namespace Umbraco.Tests.Packaging
|
||||
Directory.Delete(path, true);
|
||||
}
|
||||
|
||||
private CompiledPackageXmlParser Parser => new CompiledPackageXmlParser(new ConflictingPackageData(ServiceContext.MacroService, ServiceContext.FileService));
|
||||
private CompiledPackageXmlParser Parser => new CompiledPackageXmlParser(new ConflictingPackageData(ServiceContext.MacroService, ServiceContext.FileService),Factory.GetInstance<IGlobalSettings>());
|
||||
|
||||
private PackageDataInstallation PackageDataInstallation => new PackageDataInstallation(
|
||||
Logger, ServiceContext.FileService, ServiceContext.MacroService, ServiceContext.LocalizationService,
|
||||
|
||||
Reference in New Issue
Block a user