some cleanup
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Core.Models.Packaging
|
||||
{
|
||||
@@ -23,45 +21,7 @@ namespace Umbraco.Core.Models.Packaging
|
||||
public IEnumerable<IContent> ContentInstalled { get; set; } = Enumerable.Empty<IContent>();
|
||||
public IEnumerable<PackageAction> Actions { get; set; } = Enumerable.Empty<PackageAction>();
|
||||
public bool PackageInstalled { get; set; }
|
||||
|
||||
//public static InstallationSummary FromPackageDefinition(PackageDefinition def, IContentTypeService contentTypeService, IDataTypeService dataTypeService, IFileService fileService, ILocalizationService localizationService, IMacroService macroService)
|
||||
//{
|
||||
// var macros = TryGetIntegerIds(def.Macros).Select(macroService.GetById).ToList();
|
||||
// var templates = TryGetIntegerIds(def.Templates).Select(fileService.GetTemplate).ToList();
|
||||
// var contentTypes = TryGetIntegerIds(def.DocumentTypes).Select(contentTypeService.Get).ToList(); // fixme - media types?
|
||||
// var dataTypes = TryGetIntegerIds(def.DataTypes).Select(dataTypeService.GetDataType).ToList();
|
||||
// var dictionaryItems = TryGetIntegerIds(def.DictionaryItems).Select(localizationService.GetDictionaryItemById).ToList();
|
||||
// var languages = TryGetIntegerIds(def.Languages).Select(localizationService.GetLanguageById).ToList();
|
||||
|
||||
// for (var i = 0; i < def.Files.Count; i++)
|
||||
// {
|
||||
// var filePath = def.Files[i];
|
||||
// def.Files[i] = filePath.GetRelativePath();
|
||||
// }
|
||||
|
||||
// return new InstallationSummary
|
||||
// {
|
||||
// ContentTypesInstalled = contentTypes,
|
||||
// DataTypesInstalled = dataTypes,
|
||||
// DictionaryItemsInstalled = dictionaryItems,
|
||||
// FilesInstalled = def.Files,
|
||||
// LanguagesInstalled = languages,
|
||||
// MacrosInstalled = macros,
|
||||
// MetaData = def,
|
||||
// TemplatesInstalled = templates,
|
||||
// };
|
||||
//}
|
||||
|
||||
//private static IEnumerable<int> TryGetIntegerIds(IEnumerable<string> ids)
|
||||
//{
|
||||
// var intIds = new List<int>();
|
||||
// foreach (var id in ids)
|
||||
// {
|
||||
// if (int.TryParse(id, out var parsed))
|
||||
// intIds.Add(parsed);
|
||||
// }
|
||||
// return intIds;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace Umbraco.Core.Models.Packaging
|
||||
UmbracoVersion = compiled.UmbracoVersion,
|
||||
Url = compiled.Url,
|
||||
Version = compiled.Version,
|
||||
//fixme: Is OriginalPath correct here?
|
||||
Files = compiled.Files.Select(x => x.OriginalPath).ToList()
|
||||
};
|
||||
}
|
||||
@@ -54,13 +53,6 @@ namespace Umbraco.Core.Models.Packaging
|
||||
[Url]
|
||||
public string Url { get; set; } = string.Empty;
|
||||
|
||||
//fixme: remove this
|
||||
/// <summary>
|
||||
/// This is a generated GUID which is used to determine a temporary folder name for processing the package
|
||||
/// </summary>
|
||||
[DataMember(Name = "folder")]
|
||||
public Guid FolderId { get; set; }
|
||||
|
||||
[ReadOnly(true)]
|
||||
[DataMember(Name = "packagePath")]
|
||||
public string PackagePath { get; set; } = string.Empty;
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace Umbraco.Core.Packaging
|
||||
{
|
||||
Id = xml.AttributeValue<int>("id"),
|
||||
Name = xml.AttributeValue<string>("name") ?? string.Empty,
|
||||
FolderId = xml.AttributeValue<Guid>("folder"),
|
||||
PackagePath = xml.AttributeValue<string>("packagePath") ?? string.Empty,
|
||||
Version = xml.AttributeValue<string>("version") ?? string.Empty,
|
||||
Url = xml.AttributeValue<string>("url") ?? string.Empty,
|
||||
@@ -74,7 +73,6 @@ namespace Umbraco.Core.Packaging
|
||||
new XAttribute("version", def.Version ?? string.Empty),
|
||||
new XAttribute("url", def.Url ?? string.Empty),
|
||||
new XAttribute("name", def.Name ?? string.Empty),
|
||||
new XAttribute("folder", def.FolderId),
|
||||
new XAttribute("packagePath", def.PackagePath ?? string.Empty),
|
||||
new XAttribute("iconUrl", def.IconUrl ?? string.Empty),
|
||||
new XAttribute("umbVersion", def.UmbracoVersion),
|
||||
|
||||
@@ -131,7 +131,6 @@ namespace Umbraco.Core.Packaging
|
||||
var newId = maxId + 1;
|
||||
definition.Id = newId;
|
||||
definition.PackageId = definition.PackageId == default ? Guid.NewGuid() : definition.PackageId;
|
||||
definition.FolderId = Guid.NewGuid();
|
||||
var packageXml = _parser.ToXml(definition);
|
||||
packagesXml.Root.Add(packageXml);
|
||||
}
|
||||
@@ -155,13 +154,12 @@ namespace Umbraco.Core.Packaging
|
||||
{
|
||||
if (definition.Id == default) throw new ArgumentException("The package definition does not have an ID, it must be saved before being exported");
|
||||
if (definition.PackageId == default) throw new ArgumentException("the package definition does not have a GUID, it must be saved before being exported");
|
||||
if (definition.FolderId == default) throw new ArgumentException("the package definition does not have a folder GUID, it must be saved before being exported");
|
||||
|
||||
//ensure it's valid
|
||||
ValidatePackage(definition);
|
||||
|
||||
//Create a folder for building this package
|
||||
var temporaryPath = IOHelper.MapPath(_tempFolderPath.EnsureEndsWith('/') + definition.FolderId);
|
||||
var temporaryPath = IOHelper.MapPath(_tempFolderPath.EnsureEndsWith('/') + Guid.NewGuid());
|
||||
if (Directory.Exists(temporaryPath) == false)
|
||||
Directory.CreateDirectory(temporaryPath);
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ namespace Umbraco.Tests.Packaging
|
||||
Assert.IsTrue(result);
|
||||
Assert.AreEqual(1, def1.Id);
|
||||
Assert.AreNotEqual(default(Guid).ToString(), def1.PackageId);
|
||||
Assert.AreNotEqual(default(Guid).ToString(), def1.FolderId);
|
||||
|
||||
var def2 = new PackageDefinition
|
||||
{
|
||||
@@ -98,7 +97,6 @@ namespace Umbraco.Tests.Packaging
|
||||
Assert.IsTrue(result);
|
||||
Assert.AreEqual(2, def2.Id);
|
||||
Assert.AreNotEqual(default(Guid).ToString(), def2.PackageId);
|
||||
Assert.AreNotEqual(default(Guid).ToString(), def2.FolderId);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user