Merge branch temp8 into feature/IContentType-removale-from-IContent

This commit is contained in:
Stephan
2019-01-17 13:33:55 +01:00
264 changed files with 6879 additions and 10999 deletions

View File

@@ -0,0 +1,9 @@
namespace Umbraco.Core.Models.Packaging
{
public enum ActionRunAt
{
Undefined = 0,
Install,
Uninstall
}
}

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
namespace Umbraco.Core.Models.Packaging
{
/// <summary>
/// The model of the package definition within an umbraco (zip) package file
/// </summary>
public class CompiledPackage : IPackageInfo
{
public FileInfo PackageFile { get; set; }
public string Name { get; set; }
public string Version { get; set; }
public string Url { get; set; }
public string License { get; set; }
public string LicenseUrl { get; set; }
public Version UmbracoVersion { get; set; }
public RequirementsType UmbracoVersionRequirementsType { get; set; }
public string Author { get; set; }
public string AuthorUrl { get; set; }
public string Readme { get; set; }
public string Control { get; set; }
public string IconUrl { get; set; }
public string Actions { get; set; } //fixme: Should we make this strongly typed to IEnumerable<PackageAction> ?
public PreInstallWarnings Warnings { get; set; } = new PreInstallWarnings();
public List<CompiledPackageFile> Files { get; set; } = new List<CompiledPackageFile>();
public IEnumerable<XElement> Macros { get; set; } //fixme: make strongly typed
public IEnumerable<XElement> Templates { get; set; } //fixme: make strongly typed
public IEnumerable<XElement> Stylesheets { get; set; } //fixme: make strongly typed
public IEnumerable<XElement> DataTypes { get; set; } //fixme: make strongly typed
public IEnumerable<XElement> Languages { get; set; } //fixme: make strongly typed
public IEnumerable<XElement> DictionaryItems { get; set; } //fixme: make strongly typed
public IEnumerable<XElement> DocumentTypes { get; set; } //fixme: make strongly typed
public IEnumerable<CompiledPackageDocument> Documents { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Xml.Linq;
namespace Umbraco.Core.Models.Packaging
{
public class CompiledPackageDocument
{
public static CompiledPackageDocument Create(XElement xml)
{
if (xml.Name.LocalName != "DocumentSet")
throw new ArgumentException("The xml isn't formatted correctly, a document element is defined by <DocumentSet>", nameof(xml));
return new CompiledPackageDocument
{
XmlData = xml,
ImportMode = xml.AttributeValue<string>("importMode")
};
}
public string ImportMode { get; set; } //this is never used
/// <summary>
/// The serialized version of the content
/// </summary>
public XElement XmlData { get; set; }
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Xml.Linq;
namespace Umbraco.Core.Models.Packaging
{
public class CompiledPackageFile
{
public static CompiledPackageFile Create(XElement xml)
{
if (xml.Name.LocalName != "file")
throw new ArgumentException("The xml isn't formatted correctly, a file element is defined by <file>", nameof(xml));
return new CompiledPackageFile
{
UniqueFileName = xml.Element("guid")?.Value,
OriginalName = xml.Element("orgName")?.Value,
OriginalPath = xml.Element("orgPath")?.Value
};
}
public string OriginalPath { get; set; }
public string UniqueFileName { get; set; }
public string OriginalName { get; set; }
}
}

View File

@@ -0,0 +1,19 @@
using System;
namespace Umbraco.Core.Models.Packaging
{
public interface IPackageInfo
{
string Name { get; }
string Version { get; }
string Url { get; }
string License { get; }
string LicenseUrl { get; }
Version UmbracoVersion { get; }
string Author { get; }
string AuthorUrl { get; }
string Readme { get; }
string Control { get; } //fixme - this needs to be an angular view
string IconUrl { get; }
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.Packaging
@@ -8,36 +9,19 @@ namespace Umbraco.Core.Models.Packaging
[DataContract(IsReference = true)]
public class InstallationSummary
{
public MetaData MetaData { get; set; }
public IEnumerable<IDataType> DataTypesInstalled { get; set; }
public IEnumerable<ILanguage> LanguagesInstalled { get; set; }
public IEnumerable<IDictionaryItem> DictionaryItemsInstalled { get; set; }
public IEnumerable<IMacro> MacrosInstalled { get; set; }
public IEnumerable<string> FilesInstalled { get; set; }
public IEnumerable<ITemplate> TemplatesInstalled { get; set; }
public IEnumerable<IContentType> ContentTypesInstalled { get; set; }
public IEnumerable<IFile> StylesheetsInstalled { get; set; }
public IEnumerable<IContent> ContentInstalled { get; set; }
public IEnumerable<PackageAction> Actions { get; set; }
public bool PackageInstalled { get; set; }
public IPackageInfo MetaData { get; set; }
public IEnumerable<IDataType> DataTypesInstalled { get; set; } = Enumerable.Empty<IDataType>();
public IEnumerable<ILanguage> LanguagesInstalled { get; set; } = Enumerable.Empty<ILanguage>();
public IEnumerable<IDictionaryItem> DictionaryItemsInstalled { get; set; } = Enumerable.Empty<IDictionaryItem>();
public IEnumerable<IMacro> MacrosInstalled { get; set; } = Enumerable.Empty<IMacro>();
public IEnumerable<string> FilesInstalled { get; set; } = Enumerable.Empty<string>();
public IEnumerable<ITemplate> TemplatesInstalled { get; set; } = Enumerable.Empty<ITemplate>();
public IEnumerable<IContentType> DocumentTypesInstalled { get; set; } = Enumerable.Empty<IContentType>();
public IEnumerable<IFile> StylesheetsInstalled { get; set; } = Enumerable.Empty<IFile>();
public IEnumerable<IContent> ContentInstalled { get; set; } = Enumerable.Empty<IContent>();
public IEnumerable<PackageAction> Actions { get; set; } = Enumerable.Empty<PackageAction>();
public IEnumerable<string> ActionErrors { get; set; } = Enumerable.Empty<string>();
}
internal static class InstallationSummaryExtentions
{
public static InstallationSummary InitEmpty(this InstallationSummary summary)
{
summary.Actions = new List<PackageAction>();
summary.ContentInstalled = new List<IContent>();
summary.ContentTypesInstalled = new List<IContentType>();
summary.DataTypesInstalled = new List<IDataType>();
summary.DictionaryItemsInstalled = new List<IDictionaryItem>();
summary.FilesInstalled = new List<string>();
summary.LanguagesInstalled = new List<ILanguage>();
summary.MacrosInstalled = new List<IMacro>();
summary.MetaData = new MetaData();
summary.TemplatesInstalled = new List<ITemplate>();
summary.PackageInstalled = false;
return summary;
}
}
}

View File

@@ -1,23 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.Packaging
{
[Serializable]
[DataContract(IsReference = true)]
public class MetaData
{
public string Name { get; set; }
public string Version { get; set; }
public string Url { get; set; }
public string License { get; set; }
public string LicenseUrl { get; set; }
public int ReqMajor { get; set; }
public int ReqMinor { get; set; }
public int ReqPatch { get; set; }
public string AuthorName { get; set; }
public string AuthorUrl { get; set; }
public string Readme { get; set; }
public string Control { get; set; }
}
}

View File

@@ -4,13 +4,9 @@ using System.Xml.Linq;
namespace Umbraco.Core.Models.Packaging
{
public enum ActionRunAt
{
Undefined = 0,
Install,
Uninstall
}
/// <summary>
/// Defines a package action declared within a package manifest
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
public class PackageAction

View File

@@ -0,0 +1,165 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.Packaging
{
[DataContract(Name = "packageInstance")]
public class PackageDefinition : IPackageInfo
{
/// <summary>
/// Converts a <see cref="CompiledPackage"/> model to a <see cref="PackageDefinition"/> model
/// </summary>
/// <param name="compiled"></param>
/// <returns></returns>
/// <remarks>
/// This is used only for conversions and will not 'get' a PackageDefinition from the repository with a valid ID
/// </remarks>
internal static PackageDefinition FromCompiledPackage(CompiledPackage compiled)
{
return new PackageDefinition
{
Actions = compiled.Actions,
Author = compiled.Author,
AuthorUrl = compiled.AuthorUrl,
Control = compiled.Control,
IconUrl = compiled.IconUrl,
License = compiled.License,
LicenseUrl = compiled.LicenseUrl,
Name = compiled.Name,
Readme = compiled.Readme,
UmbracoVersion = compiled.UmbracoVersion,
Url = compiled.Url,
Version = compiled.Version,
Files = compiled.Files.Select(x => x.OriginalPath).ToList()
};
}
[DataMember(Name = "id")]
public int Id { get; set; }
[DataMember(Name = "packageGuid")]
public Guid PackageId { get; set; }
[DataMember(Name = "name")]
[Required]
public string Name { get; set; } = string.Empty;
[DataMember(Name = "url")]
[Required]
[Url]
public string Url { get; set; } = string.Empty;
/// <summary>
/// The full path to the package's zip file when it was installed (or is being installed)
/// </summary>
[ReadOnly(true)]
[DataMember(Name = "packagePath")]
public string PackagePath { get; set; } = string.Empty;
[DataMember(Name = "version")]
[Required]
public string Version { get; set; } = "1.0.0";
/// <summary>
/// The minimum umbraco version that this package requires
/// </summary>
[DataMember(Name = "umbracoVersion")]
public Version UmbracoVersion { get; set; } = Configuration.UmbracoVersion.Current;
[DataMember(Name = "author")]
[Required]
public string Author { get; set; } = string.Empty;
[DataMember(Name = "authorUrl")]
[Required]
[Url]
public string AuthorUrl { get; set; } = string.Empty;
[DataMember(Name = "license")]
public string License { get; set; } = "MIT License";
[DataMember(Name = "licenseUrl")]
public string LicenseUrl { get; set; } = "http://opensource.org/licenses/MIT";
[DataMember(Name = "readme")]
public string Readme { get; set; } = string.Empty;
[DataMember(Name = "contentLoadChildNodes")]
public bool ContentLoadChildNodes { get; set; }
[DataMember(Name = "contentNodeId")]
public string ContentNodeId { get; set; } = string.Empty;
[DataMember(Name = "macros")]
public IList<string> Macros { get; set; } = new List<string>();
[DataMember(Name = "languages")]
public IList<string> Languages { get; set; } = new List<string>();
[DataMember(Name = "dictionaryItems")]
public IList<string> DictionaryItems { get; set; } = new List<string>();
[DataMember(Name = "templates")]
public IList<string> Templates { get; set; } = new List<string>();
[DataMember(Name = "documentTypes")]
public IList<string> DocumentTypes { get; set; } = new List<string>();
[DataMember(Name = "stylesheets")]
public IList<string> Stylesheets { get; set; } = new List<string>();
[DataMember(Name = "files")]
public IList<string> Files { get; set; } = new List<string>();
//fixme: Change this to angular view
[DataMember(Name = "loadControl")]
public string Control { get; set; } = string.Empty;
[DataMember(Name = "actions")]
public string Actions { get; set; } = "<actions></actions>";
[DataMember(Name = "dataTypes")]
public IList<string> DataTypes { get; set; } = new List<string>();
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; } = string.Empty;
public PackageDefinition Clone()
{
return new PackageDefinition
{
Id = Id,
PackagePath = PackagePath,
Name = Name,
Files = new List<string>(Files),
UmbracoVersion = (Version) UmbracoVersion.Clone(),
Version = Version,
Url = Url,
Readme = Readme,
AuthorUrl = AuthorUrl,
Author = Author,
LicenseUrl = LicenseUrl,
Actions = Actions,
PackageId = PackageId,
Control = Control,
DataTypes = new List<string>(DataTypes),
IconUrl = IconUrl,
License = License,
Templates = new List<string>(Templates),
Languages = new List<string>(Languages),
Macros = new List<string>(Macros),
Stylesheets = new List<string>(Stylesheets),
DocumentTypes = new List<string>(DocumentTypes),
DictionaryItems = new List<string>(DictionaryItems),
ContentNodeId = ContentNodeId,
ContentLoadChildNodes = ContentLoadChildNodes
};
}
}
}

View File

@@ -1,17 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.Packaging
{
[Serializable]
[DataContract(IsReference = true)]
internal class PreInstallWarnings
public class PreInstallWarnings
{
public KeyValuePair<string, string>[] UnsecureFiles { get; set; }
public KeyValuePair<string, string>[] FilesReplaced { get; set; }
public IEnumerable<IMacro> ConflictingMacroAliases { get; set; }
public IEnumerable<ITemplate> ConflictingTemplateAliases { get; set; }
public IEnumerable<IFile> ConflictingStylesheetNames { get; set; }
public IEnumerable<string> UnsecureFiles { get; set; } = Enumerable.Empty<string>();
public IEnumerable<string> FilesReplaced { get; set; } = Enumerable.Empty<string>();
//TODO: Shouldn't we detect other conflicting entities too ?
public IEnumerable<IMacro> ConflictingMacros { get; set; } = Enumerable.Empty<IMacro>();
public IEnumerable<ITemplate> ConflictingTemplates { get; set; } = Enumerable.Empty<ITemplate>();
public IEnumerable<IFile> ConflictingStylesheets { get; set; } = Enumerable.Empty<IFile>();
}
}

View File

@@ -0,0 +1,8 @@
namespace Umbraco.Core.Models.Packaging
{
public enum RequirementsType
{
Strict,
Legacy
}
}

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models.Packaging
{
[Serializable]
[DataContract(IsReference = true)]
public class UninstallationSummary
{
public IPackageInfo MetaData { get; set; }
public IEnumerable<IDataType> DataTypesUninstalled { get; set; } = Enumerable.Empty<IDataType>();
public IEnumerable<ILanguage> LanguagesUninstalled { get; set; } = Enumerable.Empty<ILanguage>();
public IEnumerable<IDictionaryItem> DictionaryItemsUninstalled { get; set; } = Enumerable.Empty<IDictionaryItem>();
public IEnumerable<IMacro> MacrosUninstalled { get; set; } = Enumerable.Empty<IMacro>();
public IEnumerable<string> FilesUninstalled { get; set; } = Enumerable.Empty<string>();
public IEnumerable<ITemplate> TemplatesUninstalled { get; set; } = Enumerable.Empty<ITemplate>();
public IEnumerable<IContentType> DocumentTypesUninstalled { get; set; } = Enumerable.Empty<IContentType>();
public IEnumerable<IFile> StylesheetsUninstalled { get; set; } = Enumerable.Empty<IFile>();
public IEnumerable<PackageAction> Actions { get; set; } = Enumerable.Empty<PackageAction>();
public IEnumerable<string> ActionErrors { get; set; } = Enumerable.Empty<string>();
}
}