diff --git a/.gitattributes b/.gitattributes index c8987ade67..3241b6511c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -43,6 +43,7 @@ *.hs text=auto *.json text=auto *.xml text=auto +*.resx text=auto *.csproj text=auto merge=union *.vbproj text=auto merge=union diff --git a/.gitignore b/.gitignore index b87d1df346..022acb5db7 100644 --- a/.gitignore +++ b/.gitignore @@ -196,3 +196,4 @@ src/Umbraco.Tests.Integration/umbraco/logs/ src/Umbraco.Tests.Integration/Views/ src/Umbraco.Tests/TEMP/ +/src/Umbraco.Web.UI.NetCore/Umbraco/Data/* diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index 8a99f941b0..c545d6884e 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -8,6 +8,19 @@ # Variables & their default values variables: buildConfiguration: 'Release' + SA_PASSWORD: UmbracoIntegration123! + +resources: + containers: + - container: mssql + image: mcr.microsoft.com/mssql/server:2017-latest + env: + ACCEPT_EULA: Y + SA_PASSWORD: $(SA_PASSWORD) + MSSQL_PID: Developer + ports: + - 1433:1433 + options: --name mssql stages: - stage: Linux @@ -31,27 +44,48 @@ stages: command: test projects: '**/*.Tests.UnitTests.csproj' -- stage: macOS_X + - job: Integration_Tests + services: + mssql: mssql + timeoutInMinutes: 120 + displayName: 'Integration Tests' + pool: + vmImage: 'ubuntu-latest' + steps: + + - task: UseDotNet@2 + displayName: 'Use .Net Core sdk 3.1.x' + inputs: + version: 3.1.x + + - task: DotNetCoreCLI@2 + displayName: 'dotnet test' + inputs: + command: test + projects: '**/Umbraco.Tests.Integration.csproj' + env: + UmbracoIntegrationTestConnectionString: 'Server=localhost,1433;User Id=sa;Password=$(SA_PASSWORD);' + +- stage: MacOS dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel jobs: - - job: Unit_Tests - displayName: 'Unit Tests' - pool: - vmImage: 'macOS-latest' - steps: + - job: Unit_Tests + displayName: 'Unit Tests' + pool: + vmImage: 'macOS-latest' + steps: - - task: UseDotNet@2 - displayName: 'Use .Net Core sdk 3.1.x' - inputs: - version: 3.1.x - - - task: DotNetCoreCLI@2 - displayName: 'dotnet test' - inputs: - command: test - projects: '**/*.Tests.UnitTests.csproj' + - task: UseDotNet@2 + displayName: 'Use .Net Core sdk 3.1.x' + inputs: + version: 3.1.x + - task: DotNetCoreCLI@2 + displayName: 'dotnet test' + inputs: + command: test + projects: '**/*.Tests.UnitTests.csproj' - stage: Windows dependsOn: [] # this removes the implicit dependency on previous stage and causes this to run in parallel @@ -74,7 +108,6 @@ stages: command: test projects: '**\*.Tests.UnitTests.csproj' - - job: Integration_Tests timeoutInMinutes: 120 displayName: 'Integration Tests' @@ -87,11 +120,6 @@ stages: inputs: version: 3.1.x - - task: DotNetCoreCLI@2 - displayName: 'dotnet build' - inputs: - projects: '**\Umbraco.Tests.Integration.csproj' - - powershell: 'sqllocaldb start mssqllocaldb' displayName: 'Start MSSQL LocalDb' @@ -100,8 +128,6 @@ stages: inputs: command: test projects: '**\Umbraco.Tests.Integration.csproj' - arguments: '--no-build' - - job: Build_Artifacts displayName: 'Build Artifacts' diff --git a/src/Umbraco.Infrastructure/Configuration/Extensions/HealthCheckSettingsExtensions.cs b/src/Umbraco.Core/Configuration/Extensions/HealthCheckSettingsExtensions.cs similarity index 90% rename from src/Umbraco.Infrastructure/Configuration/Extensions/HealthCheckSettingsExtensions.cs rename to src/Umbraco.Core/Configuration/Extensions/HealthCheckSettingsExtensions.cs index 92c3608ac1..ae842cb040 100644 --- a/src/Umbraco.Infrastructure/Configuration/Extensions/HealthCheckSettingsExtensions.cs +++ b/src/Umbraco.Core/Configuration/Extensions/HealthCheckSettingsExtensions.cs @@ -1,9 +1,7 @@ using System; -using NCrontab; -using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; -namespace Umbraco.Infrastructure.Configuration.Extensions +namespace Umbraco.Core.Configuration.Extensions { public static class HealthCheckSettingsExtensions { diff --git a/src/Umbraco.Core/Configuration/LocalTempStorage.cs b/src/Umbraco.Core/Configuration/LocalTempStorage.cs index 0013fb68e4..50eab639d0 100644 --- a/src/Umbraco.Core/Configuration/LocalTempStorage.cs +++ b/src/Umbraco.Core/Configuration/LocalTempStorage.cs @@ -4,7 +4,6 @@ namespace Umbraco.Core.Configuration { Unknown = 0, Default, - AspNetTemp, EnvironmentTemp } } diff --git a/src/Umbraco.Core/Configuration/Models/UmbracoPluginSettings.cs b/src/Umbraco.Core/Configuration/Models/UmbracoPluginSettings.cs new file mode 100644 index 0000000000..907b29490d --- /dev/null +++ b/src/Umbraco.Core/Configuration/Models/UmbracoPluginSettings.cs @@ -0,0 +1,27 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Collections.Generic; + +namespace Umbraco.Core.Configuration.Models +{ + /// + /// Typed configuration options for the plugins. + /// + public class UmbracoPluginSettings + { + /// + /// Gets or sets the allowed file extensions (including the period ".") that should be accessible from the browser. + /// + public ISet BrowsableFileExtensions { get; set; } = new HashSet(new[] + { + ".html", // markup + ".css", // styles + ".js", // scripts + ".jpg", ".jpeg", ".gif", ".png", ".svg", // images + ".eot", ".ttf", ".woff", // fonts + ".xml", ".json", ".config", // configurations + ".lic" // license + }); + } +} diff --git a/src/Umbraco.Core/Constants-Configuration.cs b/src/Umbraco.Core/Constants-Configuration.cs index 2c9fe3caee..a60f29c39d 100644 --- a/src/Umbraco.Core/Constants-Configuration.cs +++ b/src/Umbraco.Core/Constants-Configuration.cs @@ -39,6 +39,7 @@ public const string ConfigMemberPassword = ConfigPrefix + "Security:MemberPassword"; public const string ConfigModelsBuilder = ConfigPrefix + "ModelsBuilder"; public const string ConfigNuCache = ConfigPrefix + "NuCache"; + public const string ConfigPlugins = ConfigPrefix + "Plugins"; public const string ConfigRequestHandler = ConfigPrefix + "RequestHandler"; public const string ConfigRuntime = ConfigPrefix + "Runtime"; public const string ConfigRuntimeMinification = ConfigPrefix + "RuntimeMinification"; diff --git a/src/Umbraco.Core/Constants-SystemDirectories.cs b/src/Umbraco.Core/Constants-SystemDirectories.cs index d4ca2a3c57..6145f4190b 100644 --- a/src/Umbraco.Core/Constants-SystemDirectories.cs +++ b/src/Umbraco.Core/Constants-SystemDirectories.cs @@ -1,15 +1,33 @@ -namespace Umbraco.Core +namespace Umbraco.Core { public static partial class Constants { public static class SystemDirectories { + /// + /// The aspnet bin folder + /// public const string Bin = "~/bin"; + // TODO: Shouldn't this exist underneath /Umbraco in the content root? public const string Config = "~/config"; - public const string Data = "~/App_Data"; + /// + /// The Umbraco folder that exists at the content root. + /// + /// + /// This is not the same as the Umbraco web folder which is configurable for serving front-end files. + /// + public const string Umbraco = "~/Umbraco"; + /// + /// The Umbraco data folder in the content root + /// + public const string Data = Umbraco + "/Data"; + + /// + /// The Umbraco temp data folder in the content root + /// public const string TempData = Data + "/TEMP"; public const string TempFileUploads = TempData + "/FileUploads"; @@ -18,8 +36,6 @@ public const string Install = "~/install"; - public const string AppCode = "~/App_Code"; - public const string AppPlugins = "/App_Plugins"; public const string MvcViews = "~/Views"; @@ -32,7 +48,10 @@ public const string Preview = Data + "/preview"; - public const string LogFiles= "~/Logs"; + /// + /// The default folder where Umbraco log files are stored + /// + public const string LogFiles = Umbraco + "/Logs"; } } } diff --git a/src/Umbraco.Infrastructure/Diagnostics/IMarchal.cs b/src/Umbraco.Core/Diagnostics/IMarchal.cs similarity index 58% rename from src/Umbraco.Infrastructure/Diagnostics/IMarchal.cs rename to src/Umbraco.Core/Diagnostics/IMarchal.cs index 30e6a9e619..cde4592b1b 100644 --- a/src/Umbraco.Infrastructure/Diagnostics/IMarchal.cs +++ b/src/Umbraco.Core/Diagnostics/IMarchal.cs @@ -7,6 +7,10 @@ namespace Umbraco.Core.Diagnostics /// public interface IMarchal { + /// + /// Retrieves a computer-independent description of an exception, and information about the state that existed for the thread when the exception occurred. + /// + /// A pointer to an EXCEPTION_POINTERS structure. IntPtr GetExceptionPointers(); } } diff --git a/src/Umbraco.Infrastructure/Diagnostics/MiniDump.cs b/src/Umbraco.Core/Diagnostics/MiniDump.cs similarity index 87% rename from src/Umbraco.Infrastructure/Diagnostics/MiniDump.cs rename to src/Umbraco.Core/Diagnostics/MiniDump.cs index 57e9b5204b..51f595bfb2 100644 --- a/src/Umbraco.Infrastructure/Diagnostics/MiniDump.cs +++ b/src/Umbraco.Core/Diagnostics/MiniDump.cs @@ -1,10 +1,8 @@ -using System; +using System; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; -using Umbraco.Core.Composing; using Umbraco.Core.Hosting; -using Umbraco.Core.IO; namespace Umbraco.Core.Diagnostics { @@ -12,7 +10,7 @@ namespace Umbraco.Core.Diagnostics // and https://blogs.msdn.microsoft.com/dondu/2010/10/31/writing-minidumps-from-exceptions-in-c/ // which itself got it from http://blog.kalmbach-software.de/2008/12/13/writing-minidumps-in-c/ - internal static class MiniDump + public static class MiniDump { private static readonly object LockO = new object(); @@ -92,7 +90,9 @@ namespace Umbraco.Core.Diagnostics exp.ExceptionPointers = IntPtr.Zero; if (withException) + { exp.ExceptionPointers = marchal.GetExceptionPointers(); + } var bRet = exp.ExceptionPointers == IntPtr.Zero ? MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint) options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) @@ -111,11 +111,14 @@ namespace Umbraco.Core.Diagnostics // filter everywhere in our code = not! var stacktrace = withException ? Environment.StackTrace : string.Empty; - var filepath = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data/MiniDump"); - if (Directory.Exists(filepath) == false) - Directory.CreateDirectory(filepath); + var directory = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump"); - var filename = Path.Combine(filepath, $"{DateTime.UtcNow:yyyyMMddTHHmmss}.{Guid.NewGuid().ToString("N").Substring(0, 4)}.dmp"); + if (Directory.Exists(directory) == false) + { + Directory.CreateDirectory(directory); + } + + var filename = Path.Combine(directory, $"{DateTime.UtcNow:yyyyMMddTHHmmss}.{Guid.NewGuid().ToString("N").Substring(0, 4)}.dmp"); using (var stream = new FileStream(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.Write)) { return Write(marchal, stream.SafeFileHandle, options, withException); @@ -127,9 +130,12 @@ namespace Umbraco.Core.Diagnostics { lock (LockO) { - var filepath = Path.Combine(hostingEnvironment.ApplicationPhysicalPath, "App_Data/MiniDump"); - if (Directory.Exists(filepath) == false) return true; - var count = Directory.GetFiles(filepath, "*.dmp").Length; + var directory = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.Data + "/MiniDump"); + if (Directory.Exists(directory) == false) + { + return true; + } + var count = Directory.GetFiles(directory, "*.dmp").Length; return count < 8; } } diff --git a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionary.cs b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs similarity index 98% rename from src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionary.cs rename to src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs index b0690c944b..1f23ec645c 100644 --- a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionary.cs +++ b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs @@ -17,7 +17,7 @@ namespace Umbraco.Core.Dictionary /// The ILocalizationService is the service used for interacting with this data from the database which isn't all that fast /// (even though there is caching involved, if there's lots of dictionary items the caching is not great) /// - public class DefaultCultureDictionary : ICultureDictionary + internal class DefaultCultureDictionary : ICultureDictionary { private readonly ILocalizationService _localizationService; private readonly IAppCache _requestCache; diff --git a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionaryFactory.cs b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs similarity index 92% rename from src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionaryFactory.cs rename to src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs index a2d1fa12d3..e2e30f3d76 100644 --- a/src/Umbraco.Infrastructure/Dictionary/UmbracoCultureDictionaryFactory.cs +++ b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Dictionary /// /// In the future this will allow use to potentially store dictionary items elsewhere and allows for maximum flexibility. /// - internal class DefaultCultureDictionaryFactory : ICultureDictionaryFactory + public class DefaultCultureDictionaryFactory : ICultureDictionaryFactory { private readonly ILocalizationService _localizationService; private readonly AppCaches _appCaches; diff --git a/src/Umbraco.Infrastructure/Editors/UserEditorAuthorizationHelper.cs b/src/Umbraco.Core/Editors/UserEditorAuthorizationHelper.cs similarity index 100% rename from src/Umbraco.Infrastructure/Editors/UserEditorAuthorizationHelper.cs rename to src/Umbraco.Core/Editors/UserEditorAuthorizationHelper.cs diff --git a/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs b/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs index 9e279c98e2..a22748094a 100644 --- a/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs +++ b/src/Umbraco.Core/HealthCheck/Checks/Permissions/FolderAndFilePermissionsCheck.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Options; @@ -71,7 +71,6 @@ namespace Umbraco.Core.HealthCheck.Checks.Permissions //so these need to be tested differently var pathsToCheckWithRestarts = new Dictionary { - { Constants.SystemDirectories.AppCode, PermissionCheckRequirement.Optional }, { Constants.SystemDirectories.Bin, PermissionCheckRequirement.Optional } }; diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollection.cs b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollection.cs similarity index 100% rename from src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollection.cs rename to src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollection.cs diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs b/src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs similarity index 100% rename from src/Umbraco.Infrastructure/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs rename to src/Umbraco.Core/HealthCheck/HealthCheckNotificationMethodCollectionBuilder.cs diff --git a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs b/src/Umbraco.Core/HealthCheck/HealthCheckResults.cs similarity index 85% rename from src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs rename to src/Umbraco.Core/HealthCheck/HealthCheckResults.cs index 37159b4a49..44955bfaae 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/HealthCheckResults.cs +++ b/src/Umbraco.Core/HealthCheck/HealthCheckResults.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using HeyRed.MarkdownSharp; using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.HealthCheck; @@ -120,33 +119,9 @@ namespace Umbraco.Infrastructure.HealthCheck return sb.ToString(); } - public string ResultsAsHtml(HealthCheckNotificationVerbosity verbosity) - { - var mark = new Markdown(); - var html = mark.Transform(ResultsAsMarkDown(verbosity)); - html = ApplyHtmlHighlighting(html); - return html; - } internal Dictionary> ResultsAsDictionary => _results; - private string ApplyHtmlHighlighting(string html) - { - const string SuccessHexColor = "5cb85c"; - const string WarningHexColor = "f0ad4e"; - const string ErrorHexColor = "d9534f"; - - html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Success, SuccessHexColor); - html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Warning, WarningHexColor); - return ApplyHtmlHighlightingForStatus(html, StatusResultType.Error, ErrorHexColor); - } - - private string ApplyHtmlHighlightingForStatus(string html, StatusResultType status, string color) - { - return html - .Replace("Result: '" + status + "'", "Result: " + status + ""); - } - private string SimpleHtmlToMarkDown(string html) { return html.Replace("", "**") diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/EmailNotificationMethod.cs similarity index 90% rename from src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs rename to src/Umbraco.Core/HealthCheck/NotificationMethods/EmailNotificationMethod.cs index 4d7444447f..d29f3ccb0b 100644 --- a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/EmailNotificationMethod.cs +++ b/src/Umbraco.Core/HealthCheck/NotificationMethods/EmailNotificationMethod.cs @@ -17,6 +17,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods private readonly ILocalizedTextService _textService; private readonly IRequestAccessor _requestAccessor; private readonly IEmailSender _emailSender; + private readonly IMarkdownToHtmlConverter _markdownToHtmlConverter; private readonly ContentSettings _contentSettings; @@ -25,7 +26,8 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods IRequestAccessor requestAccessor, IEmailSender emailSender, IOptions healthChecksSettings, - IOptions contentSettings) + IOptions contentSettings, + IMarkdownToHtmlConverter markdownToHtmlConverter) : base(healthChecksSettings) { var recipientEmail = Settings?["RecipientEmail"]; @@ -40,6 +42,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods _textService = textService ?? throw new ArgumentNullException(nameof(textService)); _requestAccessor = requestAccessor; _emailSender = emailSender; + _markdownToHtmlConverter = markdownToHtmlConverter; _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); } @@ -61,7 +64,7 @@ namespace Umbraco.Web.HealthCheck.NotificationMethods { DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), - results.ResultsAsHtml(Verbosity) + _markdownToHtmlConverter.ToHtml(results, Verbosity) }); // Include the umbraco Application URL host in the message subject so that diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs similarity index 100% rename from src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs rename to src/Umbraco.Core/HealthCheck/NotificationMethods/IHealthCheckNotificationMethod.cs diff --git a/src/Umbraco.Core/HealthCheck/NotificationMethods/IMarkdownToHtmlConverter.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/IMarkdownToHtmlConverter.cs new file mode 100644 index 0000000000..20d8f0f07e --- /dev/null +++ b/src/Umbraco.Core/HealthCheck/NotificationMethods/IMarkdownToHtmlConverter.cs @@ -0,0 +1,10 @@ +using Umbraco.Core.HealthCheck; +using Umbraco.Infrastructure.HealthCheck; + +namespace Umbraco.Web.HealthCheck.NotificationMethods +{ + public interface IMarkdownToHtmlConverter + { + string ToHtml(HealthCheckResults results, HealthCheckNotificationVerbosity verbosity); + } +} diff --git a/src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs b/src/Umbraco.Core/HealthCheck/NotificationMethods/NotificationMethodBase.cs similarity index 100% rename from src/Umbraco.Infrastructure/HealthCheck/NotificationMethods/NotificationMethodBase.cs rename to src/Umbraco.Core/HealthCheck/NotificationMethods/NotificationMethodBase.cs diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs index 188fb87b55..60d582c6c9 100644 --- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs +++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs @@ -5,6 +5,7 @@ namespace Umbraco.Core.Hosting public interface IHostingEnvironment { string SiteName { get; } + string ApplicationId { get; } /// @@ -35,8 +36,6 @@ namespace Umbraco.Core.Hosting /// /// Maps a virtual path to a physical path to the application's web root /// - /// - /// /// /// Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however /// in netcore the web root is /www therefore this will Map to a physical path within www. @@ -46,8 +45,6 @@ namespace Umbraco.Core.Hosting /// /// Maps a virtual path to a physical path to the application's root (not always equal to the web root) /// - /// - /// /// /// Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however /// in netcore the web root is /www therefore this will Map to a physical path within www. @@ -58,7 +55,6 @@ namespace Umbraco.Core.Hosting /// Converts a virtual path to an absolute URL path based on the application's web root /// /// The virtual path. Must start with either ~/ or / else an exception is thrown. - /// /// /// This maps the virtual path syntax to the web root. For example when hosting in a virtual directory called "site" and the value "~/pages/test" is passed in, it will /// map to "/site/pages/test" where "/site" is the value of . diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/StarterKitInstallStep.cs b/src/Umbraco.Core/Install/InstallSteps/StarterKitInstallStep.cs similarity index 98% rename from src/Umbraco.Infrastructure/Install/InstallSteps/StarterKitInstallStep.cs rename to src/Umbraco.Core/Install/InstallSteps/StarterKitInstallStep.cs index 4cd25c16bb..e3cd56c5c1 100644 --- a/src/Umbraco.Infrastructure/Install/InstallSteps/StarterKitInstallStep.cs +++ b/src/Umbraco.Core/Install/InstallSteps/StarterKitInstallStep.cs @@ -3,10 +3,9 @@ using System.IO; using System.Linq; using System.Threading.Tasks; using Umbraco.Core.Security; -using Umbraco.Net; using Umbraco.Core.Services; +using Umbraco.Net; using Umbraco.Web.Install.Models; -using Umbraco.Web.Security; namespace Umbraco.Web.Install.InstallSteps { diff --git a/src/Umbraco.Infrastructure/Install/Models/InstallInstructions.cs b/src/Umbraco.Core/Install/Models/InstallInstructions.cs similarity index 100% rename from src/Umbraco.Infrastructure/Install/Models/InstallInstructions.cs rename to src/Umbraco.Core/Install/Models/InstallInstructions.cs diff --git a/src/Umbraco.Core/Logging/ILoggingConfiguration.cs b/src/Umbraco.Core/Logging/ILoggingConfiguration.cs index d21a08e688..6590f9fc65 100644 --- a/src/Umbraco.Core/Logging/ILoggingConfiguration.cs +++ b/src/Umbraco.Core/Logging/ILoggingConfiguration.cs @@ -1,10 +1,10 @@ -namespace Umbraco.Core.Logging +namespace Umbraco.Core.Logging { public interface ILoggingConfiguration { /// - /// The physical path where logs are stored + /// Gets the physical path where logs are stored /// string LogDirectory { get; } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/DailyMotion.cs b/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs similarity index 86% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/DailyMotion.cs rename to src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs index 78ea0b8662..f56a29c2d5 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/DailyMotion.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/DailyMotion.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders { @"dailymotion.com/video/.*" }; - + public override Dictionary RequestParams => new Dictionary() { //ApiUrl/?format=xml @@ -24,5 +25,9 @@ namespace Umbraco.Web.Media.EmbedProviders return GetXmlProperty(xmlDocument, "/oembed/html"); } + + public DailyMotion(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProviderBase.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs similarity index 88% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProviderBase.cs rename to src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs index 539c01f69b..cc7f5d2349 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProviderBase.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/EmbedProviderBase.cs @@ -1,16 +1,23 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Net; using System.Net.Http; using System.Text; using System.Xml; using Umbraco.Core.Media; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { public abstract class EmbedProviderBase : IEmbedProvider { + private readonly IJsonSerializer _jsonSerializer; + + protected EmbedProviderBase(IJsonSerializer jsonSerializer) + { + _jsonSerializer = jsonSerializer; + } + private static HttpClient _httpClient; public abstract string ApiEndpoint { get; } @@ -58,7 +65,7 @@ namespace Umbraco.Web.Media.EmbedProviders public virtual T GetJsonResponse(string url) where T : class { var response = DownloadResponse(url); - return JsonConvert.DeserializeObject(response); + return _jsonSerializer.Deserialize(response); } public virtual XmlDocument GetXmlResponse(string url) diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollection.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollection.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollection.cs rename to src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollection.cs diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs b/src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs rename to src/Umbraco.Core/Media/EmbedProviders/EmbedProvidersCollectionBuilder.cs diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs b/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs similarity index 90% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs rename to src/Umbraco.Core/Media/EmbedProviders/Flickr.cs index d067060014..a6ead2df3a 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Flickr.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Flickr.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Net; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -27,5 +28,9 @@ namespace Umbraco.Web.Media.EmbedProviders return string.Format("\"{3}\"", imageUrl, imageWidth, imageHeight, WebUtility.HtmlEncode(imageTitle)); } + + public Flickr(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/GettyImages.cs b/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs similarity index 86% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/GettyImages.cs rename to src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs index 34b383614d..0db0a97b8e 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/GettyImages.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/GettyImages.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -23,5 +24,9 @@ namespace Umbraco.Web.Media.EmbedProviders return oembed.GetHtml(); } + + public GettyImages(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Giphy.cs b/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs similarity index 83% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Giphy.cs rename to src/Umbraco.Core/Media/EmbedProviders/Giphy.cs index 1069de749c..319afda5b6 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Giphy.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Giphy.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -28,5 +25,9 @@ namespace Umbraco.Web.Media.EmbedProviders return oembed.GetHtml(); } + + public Giphy(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Hulu.cs b/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs similarity index 85% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Hulu.cs rename to src/Umbraco.Core/Media/EmbedProviders/Hulu.cs index 150439832a..4deea8c23d 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Hulu.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Hulu.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders { @"hulu.com/watch/.*" }; - + public override Dictionary RequestParams => new Dictionary(); public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0) @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return oembed.GetHtml(); } + + public Hulu(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Issuu.cs b/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs similarity index 86% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Issuu.cs rename to src/Umbraco.Core/Media/EmbedProviders/Issuu.cs index 2b33473453..3baaf7ea35 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Issuu.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Issuu.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders { @"issuu.com/.*/docs/.*" }; - + public override Dictionary RequestParams => new Dictionary() { //ApiUrl/?format=xml @@ -24,5 +25,9 @@ namespace Umbraco.Web.Media.EmbedProviders return GetXmlProperty(xmlDocument, "/oembed/html"); } + + public Issuu(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Kickstarter.cs b/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs similarity index 84% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Kickstarter.cs rename to src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs index 4de45ae2e3..ef75b6ebe8 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Kickstarter.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Kickstarter.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return oembed.GetHtml(); } + + public Kickstarter(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs b/src/Umbraco.Core/Media/EmbedProviders/OEmbedResponse.cs similarity index 78% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs rename to src/Umbraco.Core/Media/EmbedProviders/OEmbedResponse.cs index cc3e34931e..8178a97742 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/OEmbedResponse.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/OEmbedResponse.cs @@ -1,11 +1,12 @@ using System.Net; -using Newtonsoft.Json; +using System.Runtime.Serialization; namespace Umbraco.Web.Media.EmbedProviders { /// /// Wrapper class for OEmbed response /// + [DataContract] public class OEmbedResponse { public string Type { get; set; } @@ -14,25 +15,25 @@ namespace Umbraco.Web.Media.EmbedProviders public string Title { get; set; } - [JsonProperty("author_name")] + [DataMember(Name ="author_name")] public string AuthorName { get; set; } - [JsonProperty("author_url")] + [DataMember(Name ="author_url")] public string AuthorUrl { get; set; } - [JsonProperty("provider_name")] + [DataMember(Name ="provider_name")] public string ProviderName { get; set; } - [JsonProperty("provider_url")] + [DataMember(Name ="provider_url")] public string ProviderUrl { get; set; } - [JsonProperty("thumbnail_url")] + [DataMember(Name ="thumbnail_url")] public string ThumbnailUrl { get; set; } - [JsonProperty("thumbnail_height")] + [DataMember(Name ="thumbnail_height")] public double? ThumbnailHeight { get; set; } - [JsonProperty("thumbnail_width")] + [DataMember(Name ="thumbnail_width")] public double? ThumbnailWidth { get; set; } public string Html { get; set; } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Slideshare.cs b/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs similarity index 85% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Slideshare.cs rename to src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs index 6d3a010c7a..7fa149d145 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Slideshare.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Slideshare.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return GetXmlProperty(xmlDocument, "/oembed/html"); } + + public Slideshare(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/SoundCloud.cs b/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs similarity index 84% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/SoundCloud.cs rename to src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs index 080437a246..43cc92b0b4 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/SoundCloud.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/SoundCloud.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders { @"soundcloud.com\/*" }; - + public override Dictionary RequestParams => new Dictionary(); public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0) @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return GetXmlProperty(xmlDocument, "/oembed/html"); } + + public Soundcloud(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Ted.cs b/src/Umbraco.Core/Media/EmbedProviders/Ted.cs similarity index 85% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Ted.cs rename to src/Umbraco.Core/Media/EmbedProviders/Ted.cs index aa14423349..cd4b78d065 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Ted.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Ted.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders { @"ted.com\/talks\/*" }; - + public override Dictionary RequestParams => new Dictionary(); public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0) @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return GetXmlProperty(xmlDocument, "/oembed/html"); } + + public Ted(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Twitter.cs b/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs similarity index 85% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Twitter.cs rename to src/Umbraco.Core/Media/EmbedProviders/Twitter.cs index 9286934a4d..2bb4203411 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Twitter.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Twitter.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return oembed.GetHtml(); } + + public Twitter(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Vimeo.cs b/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs similarity index 85% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Vimeo.cs rename to src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs index 806f40a10c..709ba61b3b 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Vimeo.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Vimeo.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -10,7 +11,7 @@ namespace Umbraco.Web.Media.EmbedProviders { @"vimeo\.com/" }; - + public override Dictionary RequestParams => new Dictionary(); public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0) @@ -20,5 +21,9 @@ namespace Umbraco.Web.Media.EmbedProviders return GetXmlProperty(xmlDocument, "/oembed/html"); } + + public Vimeo(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/EmbedProviders/Youtube.cs b/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs similarity index 86% rename from src/Umbraco.Infrastructure/Media/EmbedProviders/Youtube.cs rename to src/Umbraco.Core/Media/EmbedProviders/Youtube.cs index 4e6f437047..30b83caa88 100644 --- a/src/Umbraco.Infrastructure/Media/EmbedProviders/Youtube.cs +++ b/src/Umbraco.Core/Media/EmbedProviders/Youtube.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Serialization; namespace Umbraco.Web.Media.EmbedProviders { @@ -11,7 +12,7 @@ namespace Umbraco.Web.Media.EmbedProviders @"youtu.be/.*", @"youtube.com/watch.*" }; - + public override Dictionary RequestParams => new Dictionary() { //ApiUrl/?format=json @@ -25,5 +26,9 @@ namespace Umbraco.Web.Media.EmbedProviders return oembed.GetHtml(); } + + public YouTube(IJsonSerializer jsonSerializer) : base(jsonSerializer) + { + } } } diff --git a/src/Umbraco.Infrastructure/Media/Exif/BitConverterEx.cs b/src/Umbraco.Core/Media/Exif/BitConverterEx.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/BitConverterEx.cs rename to src/Umbraco.Core/Media/Exif/BitConverterEx.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifBitConverter.cs b/src/Umbraco.Core/Media/Exif/ExifBitConverter.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifBitConverter.cs rename to src/Umbraco.Core/Media/Exif/ExifBitConverter.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifEnums.cs b/src/Umbraco.Core/Media/Exif/ExifEnums.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifEnums.cs rename to src/Umbraco.Core/Media/Exif/ExifEnums.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifExceptions.cs b/src/Umbraco.Core/Media/Exif/ExifExceptions.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifExceptions.cs rename to src/Umbraco.Core/Media/Exif/ExifExceptions.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifExtendedProperty.cs b/src/Umbraco.Core/Media/Exif/ExifExtendedProperty.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifExtendedProperty.cs rename to src/Umbraco.Core/Media/Exif/ExifExtendedProperty.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifFileTypeDescriptor.cs b/src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifFileTypeDescriptor.cs rename to src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifInterOperability.cs b/src/Umbraco.Core/Media/Exif/ExifInterOperability.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifInterOperability.cs rename to src/Umbraco.Core/Media/Exif/ExifInterOperability.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifProperty.cs b/src/Umbraco.Core/Media/Exif/ExifProperty.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifProperty.cs rename to src/Umbraco.Core/Media/Exif/ExifProperty.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifPropertyCollection.cs b/src/Umbraco.Core/Media/Exif/ExifPropertyCollection.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifPropertyCollection.cs rename to src/Umbraco.Core/Media/Exif/ExifPropertyCollection.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifPropertyFactory.cs b/src/Umbraco.Core/Media/Exif/ExifPropertyFactory.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifPropertyFactory.cs rename to src/Umbraco.Core/Media/Exif/ExifPropertyFactory.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifTag.cs b/src/Umbraco.Core/Media/Exif/ExifTag.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifTag.cs rename to src/Umbraco.Core/Media/Exif/ExifTag.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ExifTagFactory.cs b/src/Umbraco.Core/Media/Exif/ExifTagFactory.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ExifTagFactory.cs rename to src/Umbraco.Core/Media/Exif/ExifTagFactory.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/IFD.cs b/src/Umbraco.Core/Media/Exif/IFD.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/IFD.cs rename to src/Umbraco.Core/Media/Exif/IFD.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFile.cs b/src/Umbraco.Core/Media/Exif/ImageFile.cs similarity index 94% rename from src/Umbraco.Infrastructure/Media/Exif/ImageFile.cs rename to src/Umbraco.Core/Media/Exif/ImageFile.cs index acd8ce8eec..f59f9dc73f 100644 --- a/src/Umbraco.Infrastructure/Media/Exif/ImageFile.cs +++ b/src/Umbraco.Core/Media/Exif/ImageFile.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -using System.Drawing; using System.IO; using System.Text; using Umbraco.Web.Media.TypeDetector; @@ -52,11 +51,6 @@ namespace Umbraco.Web.Media.Exif #endregion #region Instance Methods - /// - /// Converts the to a . - /// - /// Returns a containing image data. - public abstract Image ToImage (); /// /// Saves the to the specified file. diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectory.cs b/src/Umbraco.Core/Media/Exif/ImageFileDirectory.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectory.cs rename to src/Umbraco.Core/Media/Exif/ImageFileDirectory.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectoryEntry.cs b/src/Umbraco.Core/Media/Exif/ImageFileDirectoryEntry.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ImageFileDirectoryEntry.cs rename to src/Umbraco.Core/Media/Exif/ImageFileDirectoryEntry.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/ImageFileFormat.cs b/src/Umbraco.Core/Media/Exif/ImageFileFormat.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/ImageFileFormat.cs rename to src/Umbraco.Core/Media/Exif/ImageFileFormat.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/JFIFEnums.cs b/src/Umbraco.Core/Media/Exif/JFIFEnums.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/JFIFEnums.cs rename to src/Umbraco.Core/Media/Exif/JFIFEnums.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/JFIFExtendedProperty.cs b/src/Umbraco.Core/Media/Exif/JFIFExtendedProperty.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/JFIFExtendedProperty.cs rename to src/Umbraco.Core/Media/Exif/JFIFExtendedProperty.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/JFIFThumbnail.cs b/src/Umbraco.Core/Media/Exif/JFIFThumbnail.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/JFIFThumbnail.cs rename to src/Umbraco.Core/Media/Exif/JFIFThumbnail.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGExceptions.cs b/src/Umbraco.Core/Media/Exif/JPEGExceptions.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/JPEGExceptions.cs rename to src/Umbraco.Core/Media/Exif/JPEGExceptions.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGFile.cs b/src/Umbraco.Core/Media/Exif/JPEGFile.cs similarity index 99% rename from src/Umbraco.Infrastructure/Media/Exif/JPEGFile.cs rename to src/Umbraco.Core/Media/Exif/JPEGFile.cs index 35c3788abd..83e6a81eec 100644 --- a/src/Umbraco.Infrastructure/Media/Exif/JPEGFile.cs +++ b/src/Umbraco.Core/Media/Exif/JPEGFile.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Text; @@ -260,15 +259,6 @@ namespace Umbraco.Web.Media.Exif Save(stream, true); } - /// - /// Returns a System.Drawing.Image created with image data. - /// - public override Image ToImage() - { - MemoryStream stream = new MemoryStream(); - Save(stream); - return Image.FromStream(stream); - } #endregion #region Private Helper Methods diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGMarker.cs b/src/Umbraco.Core/Media/Exif/JPEGMarker.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/JPEGMarker.cs rename to src/Umbraco.Core/Media/Exif/JPEGMarker.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/JPEGSection.cs b/src/Umbraco.Core/Media/Exif/JPEGSection.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/JPEGSection.cs rename to src/Umbraco.Core/Media/Exif/JPEGSection.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/MathEx.cs b/src/Umbraco.Core/Media/Exif/MathEx.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/MathEx.cs rename to src/Umbraco.Core/Media/Exif/MathEx.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/SvgFile.cs b/src/Umbraco.Core/Media/Exif/SvgFile.cs similarity index 86% rename from src/Umbraco.Infrastructure/Media/Exif/SvgFile.cs rename to src/Umbraco.Core/Media/Exif/SvgFile.cs index 8916ac0801..1213bb513f 100644 --- a/src/Umbraco.Infrastructure/Media/Exif/SvgFile.cs +++ b/src/Umbraco.Core/Media/Exif/SvgFile.cs @@ -1,6 +1,4 @@ -using System; -using System.Drawing; -using System.IO; +using System.IO; using System.Linq; using System.Xml.Linq; @@ -29,9 +27,5 @@ namespace Umbraco.Web.Media.Exif { } - public override Image ToImage() - { - throw new NotImplementedException(); - } } } diff --git a/src/Umbraco.Infrastructure/Media/Exif/TIFFFile.cs b/src/Umbraco.Core/Media/Exif/TIFFFile.cs similarity index 93% rename from src/Umbraco.Infrastructure/Media/Exif/TIFFFile.cs rename to src/Umbraco.Core/Media/Exif/TIFFFile.cs index 4f5301d526..19575eaff2 100644 --- a/src/Umbraco.Infrastructure/Media/Exif/TIFFFile.cs +++ b/src/Umbraco.Core/Media/Exif/TIFFFile.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.IO; namespace Umbraco.Web.Media.Exif @@ -162,16 +161,6 @@ namespace Umbraco.Web.Media.Exif } } - /// - /// Converts the to a . - /// - /// Returns a containing image data. - public override Image ToImage() - { - MemoryStream stream = new MemoryStream(); - Save(stream); - return Image.FromStream(stream); - } #endregion } } diff --git a/src/Umbraco.Infrastructure/Media/Exif/TIFFHeader.cs b/src/Umbraco.Core/Media/Exif/TIFFHeader.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/TIFFHeader.cs rename to src/Umbraco.Core/Media/Exif/TIFFHeader.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/TIFFStrip.cs b/src/Umbraco.Core/Media/Exif/TIFFStrip.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/TIFFStrip.cs rename to src/Umbraco.Core/Media/Exif/TIFFStrip.cs diff --git a/src/Umbraco.Infrastructure/Media/Exif/Utility.cs b/src/Umbraco.Core/Media/Exif/Utility.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/Exif/Utility.cs rename to src/Umbraco.Core/Media/Exif/Utility.cs diff --git a/src/Umbraco.Core/Media/ExifImageDimensionExtractor.cs b/src/Umbraco.Core/Media/ExifImageDimensionExtractor.cs new file mode 100644 index 0000000000..441d2d6170 --- /dev/null +++ b/src/Umbraco.Core/Media/ExifImageDimensionExtractor.cs @@ -0,0 +1,26 @@ +using System; +using System.IO; +using Umbraco.Web.Media.Exif; + +namespace Umbraco.Core.Media +{ + public static class ExifImageDimensionExtractor + { + public static bool TryGetDimensions(Stream stream, out int width, out int height) + { + var jpgInfo = ImageFile.FromStream(stream); + height = -1; + width = -1; + if (jpgInfo != null + && jpgInfo.Format != ImageFileFormat.Unknown + && jpgInfo.Properties.ContainsKey(ExifTag.PixelYDimension) + && jpgInfo.Properties.ContainsKey(ExifTag.PixelXDimension)) + { + height = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelYDimension].Value); + width = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelXDimension].Value); + } + + return height > 0 && width > 0; + } + } +} diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/JpegDetector.cs b/src/Umbraco.Core/Media/TypeDetector/JpegDetector.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/TypeDetector/JpegDetector.cs rename to src/Umbraco.Core/Media/TypeDetector/JpegDetector.cs diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/RasterizedTypeDetector.cs b/src/Umbraco.Core/Media/TypeDetector/RasterizedTypeDetector.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/TypeDetector/RasterizedTypeDetector.cs rename to src/Umbraco.Core/Media/TypeDetector/RasterizedTypeDetector.cs diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/SvgDetector.cs b/src/Umbraco.Core/Media/TypeDetector/SvgDetector.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/TypeDetector/SvgDetector.cs rename to src/Umbraco.Core/Media/TypeDetector/SvgDetector.cs diff --git a/src/Umbraco.Infrastructure/Media/TypeDetector/TIFFDetector.cs b/src/Umbraco.Core/Media/TypeDetector/TIFFDetector.cs similarity index 100% rename from src/Umbraco.Infrastructure/Media/TypeDetector/TIFFDetector.cs rename to src/Umbraco.Core/Media/TypeDetector/TIFFDetector.cs diff --git a/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs b/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs index 6689e133fc..5f5bc3cebd 100644 --- a/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs +++ b/src/Umbraco.Core/Models/ContentEditing/ContentItemBasic.cs @@ -91,6 +91,7 @@ namespace Umbraco.Web.Models.ContentEditing private IEnumerable _properties; + [DataMember(Name = "properties")] public virtual IEnumerable Properties { get => _properties; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockListConfiguration.cs b/src/Umbraco.Core/PropertyEditors/BlockListConfiguration.cs similarity index 76% rename from src/Umbraco.Infrastructure/PropertyEditors/BlockListConfiguration.cs rename to src/Umbraco.Core/PropertyEditors/BlockListConfiguration.cs index 1af3aa1303..f0aa1f0b77 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockListConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/BlockListConfiguration.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using System; +using System; +using System.Runtime.Serialization; using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors @@ -12,37 +12,38 @@ namespace Umbraco.Web.PropertyEditors [ConfigurationField("blocks", "Available Blocks", "views/propertyeditors/blocklist/prevalue/blocklist.blockconfiguration.html", Description = "Define the available blocks.")] public BlockConfiguration[] Blocks { get; set; } + [DataContract] public class BlockConfiguration { - [JsonProperty("backgroundColor")] + [DataMember(Name ="backgroundColor")] public string BackgroundColor { get; set; } - [JsonProperty("iconColor")] + [DataMember(Name ="iconColor")] public string IconColor { get; set; } - [JsonProperty("thumbnail")] + [DataMember(Name ="thumbnail")] public string Thumbnail { get; set; } - [JsonProperty("contentElementTypeKey")] + [DataMember(Name ="contentElementTypeKey")] public Guid ContentElementTypeKey { get; set; } - [JsonProperty("settingsElementTypeKey")] + [DataMember(Name ="settingsElementTypeKey")] public Guid? SettingsElementTypeKey { get; set; } - [JsonProperty("view")] + [DataMember(Name ="view")] public string View { get; set; } - [JsonProperty("stylesheet")] + [DataMember(Name ="stylesheet")] public string Stylesheet { get; set; } - [JsonProperty("label")] + [DataMember(Name ="label")] public string Label { get; set; } - [JsonProperty("editorSize")] + [DataMember(Name ="editorSize")] public string EditorSize { get; set; } - [JsonProperty("forceHideContentEditorInOverlay")] + [DataMember(Name ="forceHideContentEditorInOverlay")] public bool ForceHideContentEditorInOverlay { get; set; } } @@ -51,10 +52,10 @@ namespace Umbraco.Web.PropertyEditors public class NumberRange { - [JsonProperty("min")] + [DataMember(Name ="min")] public int? Min { get; set; } - [JsonProperty("max")] + [DataMember(Name ="max")] public int? Max { get; set; } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DataEditor.cs b/src/Umbraco.Core/PropertyEditors/DataEditor.cs similarity index 92% rename from src/Umbraco.Infrastructure/PropertyEditors/DataEditor.cs rename to src/Umbraco.Core/PropertyEditors/DataEditor.cs index d74f285553..ef533aa083 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DataEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataEditor.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Runtime.Serialization; using Microsoft.Extensions.Logging; using Umbraco.Core.Composing; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -26,13 +27,21 @@ namespace Umbraco.Core.PropertyEditors /// /// Initializes a new instance of the class. /// - public DataEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, EditorType type = EditorType.PropertyValue) + public DataEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + EditorType type = EditorType.PropertyValue) { LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); DataTypeService = dataTypeService ?? throw new ArgumentNullException(nameof(dataTypeService)); LocalizationService = localizationService ?? throw new ArgumentNullException(nameof(localizationService)); LocalizedTextService = localizedTextService ?? throw new ArgumentNullException(nameof(localizedTextService)); ShortStringHelper = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper)); + JsonSerializer = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer)); // defaults @@ -58,6 +67,7 @@ namespace Umbraco.Core.PropertyEditors protected DataEditorAttribute Attribute { get; } protected IShortStringHelper ShortStringHelper { get; } + public IJsonSerializer JsonSerializer { get; } protected ILocalizedTextService LocalizedTextService { get; } protected ILocalizationService LocalizationService { get; } protected ILoggerFactory LoggerFactory { get; } @@ -65,7 +75,7 @@ namespace Umbraco.Core.PropertyEditors /// [DataMember(Name = "alias", IsRequired = true)] - public string Alias { get; internal set; } + public string Alias { get; set; } /// [IgnoreDataMember] @@ -174,7 +184,7 @@ namespace Umbraco.Core.PropertyEditors if (Attribute == null) throw new InvalidOperationException($"The editor is not attributed with {nameof(DataEditorAttribute)}"); - return new DataValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + return new DataValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DataValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs similarity index 93% rename from src/Umbraco.Infrastructure/PropertyEditors/DataValueEditor.cs rename to src/Umbraco.Core/PropertyEditors/DataValueEditor.cs index fec245009f..237af042cf 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DataValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DataValueEditor.cs @@ -3,14 +3,13 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Globalization; using System.Linq; +using System.Runtime.Serialization; using System.Xml.Linq; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -19,20 +18,28 @@ namespace Umbraco.Core.PropertyEditors /// /// Represents a value editor. /// + [DataContract] public class DataValueEditor : IDataValueEditor { private readonly ILocalizedTextService _localizedTextService; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _jsonSerializer; protected IDataTypeService DataTypeService { get; } protected ILocalizationService LocalizationService { get; } /// /// Initializes a new instance of the class. /// - public DataValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) // for tests, and manifest + public DataValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) // for tests, and manifest { _localizedTextService = localizedTextService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; ValueType = ValueTypes.String; Validators = new List(); DataTypeService = dataTypeService; @@ -42,11 +49,18 @@ namespace Umbraco.Core.PropertyEditors /// /// Initializes a new instance of the class. /// - public DataValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) + public DataValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) { if (attribute == null) throw new ArgumentNullException(nameof(attribute)); _localizedTextService = localizedTextService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; var view = attribute.View; if (string.IsNullOrWhiteSpace(view)) @@ -72,13 +86,14 @@ namespace Umbraco.Core.PropertyEditors /// The view can be three things: (1) the full virtual path, or (2) the relative path to the current Umbraco /// folder, or (3) a view name which maps to views/propertyeditors/{view}/{view}.html. /// - [JsonProperty("view", Required = Required.Always)] + [Required] + [DataMember(Name = "view")] public string View { get; set; } /// /// The value type which reflects how it is validated and stored in the database /// - [JsonProperty("valueType")] + [DataMember(Name = "valueType")] public string ValueType { get; set; } /// @@ -111,7 +126,7 @@ namespace Umbraco.Core.PropertyEditors /// /// A collection of validators for the pre value editor /// - [JsonProperty("validation")] + [DataMember(Name = "validation")] public List Validators { get; private set; } = new List(); /// @@ -127,7 +142,7 @@ namespace Umbraco.Core.PropertyEditors /// /// If this is true than the editor will be displayed full width without a label /// - [JsonProperty("hideLabel")] + [DataMember(Name = "hideLabel")] public bool HideLabel { get; set; } /// @@ -142,8 +157,8 @@ namespace Umbraco.Core.PropertyEditors /// internal Attempt TryConvertValueToCrlType(object value) { - if (value is JValue) - value = value.ToString(); + // if (value is JValue) + // value = value.ToString(); //this is a custom check to avoid any errors, if it's a string and it's empty just make it null if (value is string s && string.IsNullOrWhiteSpace(s)) @@ -250,7 +265,7 @@ namespace Umbraco.Core.PropertyEditors { try { - var json = JsonConvert.DeserializeObject(asString); + var json = _jsonSerializer.Deserialize(asString); return json; } catch diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DateValueEditor.cs b/src/Umbraco.Core/PropertyEditors/DateValueEditor.cs similarity index 70% rename from src/Umbraco.Infrastructure/PropertyEditors/DateValueEditor.cs rename to src/Umbraco.Core/PropertyEditors/DateValueEditor.cs index 8973dd812b..b6208197c7 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DateValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DateValueEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -13,8 +14,14 @@ namespace Umbraco.Web.PropertyEditors /// internal class DateValueEditor : DataValueEditor { - public DateValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public DateValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { Validators.Add(new DateTimeValidator()); } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DecimalPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs similarity index 88% rename from src/Umbraco.Infrastructure/PropertyEditors/DecimalPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs index 8d2280b23b..4aea9f944f 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DecimalPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/DecimalPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -26,8 +27,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/IntegerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs similarity index 72% rename from src/Umbraco.Infrastructure/PropertyEditors/IntegerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs index 417ec112d7..43b988a49f 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/IntegerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/IntegerPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -18,8 +19,14 @@ namespace Umbraco.Web.PropertyEditors ValueType = ValueTypes.Integer)] public class IntegerPropertyEditor : DataEditor { - public IntegerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public IntegerPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IShortStringHelper shortStringHelper, + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MemberGroupPickerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/MemberGroupPickerPropertyEditor.cs similarity index 81% rename from src/Umbraco.Infrastructure/PropertyEditors/MemberGroupPickerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/MemberGroupPickerPropertyEditor.cs index eb50d02284..34448b3816 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MemberGroupPickerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/MemberGroupPickerPropertyEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MemberPickerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/MemberPickerPropertyEditor.cs similarity index 83% rename from src/Umbraco.Infrastructure/PropertyEditors/MemberPickerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/MemberPickerPropertyEditor.cs index 3676340aee..b572f47cfd 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MemberPickerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/MemberPickerPropertyEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } protected override IConfigurationEditor CreateConfigurationEditor() => new MemberPickerConfiguration(); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs similarity index 85% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs index 2da9e184c3..619fd89692 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/ContentTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -23,8 +24,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", false); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs similarity index 86% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs index d416cf111a..5110dfdc79 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentPickerParameterEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -24,8 +25,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiPicker", "1"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs similarity index 82% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs index 613d6a6a5e..ff08420cd9 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleContentTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", true); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs similarity index 81% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs index 73a3b42610..a2750447a8 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultipleMediaPickerParameterEditor.cs @@ -1,6 +1,7 @@ -using Umbraco.Core; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging; +using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -25,8 +26,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { DefaultConfiguration.Add("multiPicker", "1"); } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs similarity index 84% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs index 16cd596fc8..22571db975 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyGroupParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", true); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs similarity index 84% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs index e9576fab02..251d982777 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePropertyTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", "1"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs similarity index 84% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs index 345afa3b46..aabef3e1b0 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyGroupParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", "0"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs similarity index 83% rename from src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs rename to src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs index be682a35d3..c3178d3138 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditors/PropertyTypeParameterEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,8 +18,9 @@ namespace Umbraco.Web.PropertyEditors.ParameterEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { // configure DefaultConfiguration.Add("multiple", "0"); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextConfiguration.cs b/src/Umbraco.Core/PropertyEditors/RichTextConfiguration.cs similarity index 92% rename from src/Umbraco.Infrastructure/PropertyEditors/RichTextConfiguration.cs rename to src/Umbraco.Core/PropertyEditors/RichTextConfiguration.cs index c6d4e3ce70..c1fb61bde8 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextConfiguration.cs +++ b/src/Umbraco.Core/PropertyEditors/RichTextConfiguration.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json.Linq; -using Umbraco.Core; +using Umbraco.Core; using Umbraco.Core.PropertyEditors; namespace Umbraco.Web.PropertyEditors @@ -11,7 +10,7 @@ namespace Umbraco.Web.PropertyEditors { // TODO: Make these strongly typed, for now this works though [ConfigurationField("editor", "Editor", "views/propertyeditors/rte/rte.prevalues.html", HideLabel = true)] - public JObject Editor { get; set; } + public object Editor { get; set; } [ConfigurationField("hideLabel", "Hide Label", "boolean")] public bool HideLabel { get; set; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TextOnlyValueEditor.cs b/src/Umbraco.Core/PropertyEditors/TextOnlyValueEditor.cs similarity index 80% rename from src/Umbraco.Infrastructure/PropertyEditors/TextOnlyValueEditor.cs rename to src/Umbraco.Core/PropertyEditors/TextOnlyValueEditor.cs index ec48cf8b57..aeac87079c 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TextOnlyValueEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/TextOnlyValueEditor.cs @@ -1,6 +1,7 @@ using System; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -12,8 +13,14 @@ namespace Umbraco.Web.PropertyEditors /// public class TextOnlyValueEditor : DataValueEditor { - public TextOnlyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, DataEditorAttribute attribute, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public TextOnlyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + DataEditorAttribute attribute, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/UserPickerPropertyEditor.cs b/src/Umbraco.Core/PropertyEditors/UserPickerPropertyEditor.cs similarity index 82% rename from src/Umbraco.Infrastructure/PropertyEditors/UserPickerPropertyEditor.cs rename to src/Umbraco.Core/PropertyEditors/UserPickerPropertyEditor.cs index 891fb54ee3..f22c3d94dc 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/UserPickerPropertyEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/UserPickerPropertyEditor.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } protected override IConfigurationEditor CreateConfigurationEditor() => new UserPickerConfiguration(); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs b/src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs rename to src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorElementTypeValidationResult.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs b/src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs rename to src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorPropertyTypeValidationResult.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorValidationResult.cs b/src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorValidationResult.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/Validation/ComplexEditorValidationResult.cs rename to src/Umbraco.Core/PropertyEditors/Validation/ComplexEditorValidationResult.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs similarity index 100% rename from src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs rename to src/Umbraco.Core/PropertyEditors/ValueConverters/MemberPickerValueConverter.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/VoidEditor.cs b/src/Umbraco.Core/PropertyEditors/VoidEditor.cs similarity index 73% rename from src/Umbraco.Infrastructure/PropertyEditors/VoidEditor.cs rename to src/Umbraco.Core/PropertyEditors/VoidEditor.cs index e26cd4129a..d2e84b7952 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/VoidEditor.cs +++ b/src/Umbraco.Core/PropertyEditors/VoidEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.Composing; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -14,6 +15,8 @@ namespace Umbraco.Core.PropertyEditors [HideFromTypeFinder] public class VoidEditor : DataEditor { + private readonly IJsonSerializer _jsonSerializer; + /// /// Initializes a new instance of the class. /// @@ -21,8 +24,15 @@ namespace Umbraco.Core.PropertyEditors /// A logger factory. /// The default alias of the editor is "Umbraco.Void". When a suffix is provided, /// it is appended to the alias. Eg if the suffix is "Foo" the alias is "Umbraco.Void.Foo". - public VoidEditor(string aliasSuffix, ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public VoidEditor( + string aliasSuffix, + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { Alias = "Umbraco.Void"; if (string.IsNullOrWhiteSpace(aliasSuffix)) return; @@ -34,8 +44,8 @@ namespace Umbraco.Core.PropertyEditors /// /// A logger factory. /// The alias of the editor is "Umbraco.Void". - public VoidEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : this(null, loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public VoidEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : this(null, loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } } } diff --git a/src/Umbraco.Core/Runtime/MainDom.cs b/src/Umbraco.Core/Runtime/MainDom.cs index c413557a27..f1f6ee3afc 100644 --- a/src/Umbraco.Core/Runtime/MainDom.cs +++ b/src/Umbraco.Core/Runtime/MainDom.cs @@ -157,7 +157,15 @@ namespace Umbraco.Core.Runtime _logger.LogInformation("Acquiring."); // Get the lock - var acquired = _mainDomLock.AcquireLockAsync(LockTimeoutMilliseconds).GetAwaiter().GetResult(); + var acquired = false; + try + { + acquired = _mainDomLock.AcquireLockAsync(LockTimeoutMilliseconds).GetAwaiter().GetResult(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error while acquiring"); + } if (!acquired) { diff --git a/src/Umbraco.Infrastructure/Services/Implement/IInstallationService.cs b/src/Umbraco.Core/Services/IInstallationService.cs similarity index 100% rename from src/Umbraco.Infrastructure/Services/Implement/IInstallationService.cs rename to src/Umbraco.Core/Services/IInstallationService.cs diff --git a/src/Umbraco.Infrastructure/HealthCheck/MarkdownToHtmlConverter.cs b/src/Umbraco.Infrastructure/HealthCheck/MarkdownToHtmlConverter.cs new file mode 100644 index 0000000000..39c5fe0bf2 --- /dev/null +++ b/src/Umbraco.Infrastructure/HealthCheck/MarkdownToHtmlConverter.cs @@ -0,0 +1,35 @@ +using HeyRed.MarkdownSharp; +using Umbraco.Core.HealthCheck; +using Umbraco.Infrastructure.HealthCheck; +using Umbraco.Web.HealthCheck.NotificationMethods; + +namespace Umbraco.Web.HealthCheck +{ + public class MarkdownToHtmlConverter : IMarkdownToHtmlConverter + { + public string ToHtml(HealthCheckResults results, HealthCheckNotificationVerbosity verbosity) + { + var mark = new Markdown(); + var html = mark.Transform(results.ResultsAsMarkDown(verbosity)); + html = ApplyHtmlHighlighting(html); + return html; + } + + private string ApplyHtmlHighlighting(string html) + { + const string SuccessHexColor = "5cb85c"; + const string WarningHexColor = "f0ad4e"; + const string ErrorHexColor = "d9534f"; + + html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Success, SuccessHexColor); + html = ApplyHtmlHighlightingForStatus(html, StatusResultType.Warning, WarningHexColor); + return ApplyHtmlHighlightingForStatus(html, StatusResultType.Error, ErrorHexColor); + } + + private string ApplyHtmlHighlightingForStatus(string html, StatusResultType status, string color) + { + return html + .Replace("Result: '" + status + "'", "Result: " + status + ""); + } + } +} diff --git a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs index 5c8bd0bc2f..cd89ebc046 100644 --- a/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs +++ b/src/Umbraco.Infrastructure/HostedServices/HealthCheckNotifier.cs @@ -9,12 +9,12 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Core; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Extensions; using Umbraco.Core.Configuration.Models; using Umbraco.Core.HealthCheck; using Umbraco.Core.Logging; using Umbraco.Core.Scoping; using Umbraco.Core.Sync; -using Umbraco.Infrastructure.Configuration.Extensions; using Umbraco.Infrastructure.HealthCheck; using Umbraco.Web.HealthCheck; using Umbraco.Web.HealthCheck.NotificationMethods; diff --git a/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs b/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs index 80570ae5de..b7699b7d0e 100644 --- a/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs +++ b/src/Umbraco.Infrastructure/Install/InstallSteps/NewInstallStep.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Specialized; using System.Net.Http; using System.Text; @@ -24,7 +24,7 @@ namespace Umbraco.Web.Install.InstallSteps /// display a simple continue installation view. /// [InstallSetupStep(InstallationType.NewInstall, "User", 20, "")] - internal class NewInstallStep : InstallSetupStep + public class NewInstallStep : InstallSetupStep { private readonly IUserService _userService; private readonly DatabaseBuilder _databaseBuilder; diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs index 84270b95bf..5481f22cb6 100644 --- a/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs +++ b/src/Umbraco.Infrastructure/Logging/Serilog/LoggerConfigExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Text; using Serilog; @@ -127,7 +127,7 @@ namespace Umbraco.Core.Logging.Serilog /// Outputs a CLEF format JSON log at /App_Data/Logs/ /// /// A Serilog LoggerConfiguration - /// + /// The logging configuration /// The log level you wish the JSON file to collect - default is Verbose (highest) /// The number of days to keep log files. Default is set to null which means all logs are kept public static LoggerConfiguration OutputDefaultJsonFile( @@ -135,13 +135,13 @@ namespace Umbraco.Core.Logging.Serilog IHostingEnvironment hostingEnvironment, ILoggingConfiguration loggingConfiguration, LogEventLevel minimumLevel = LogEventLevel.Verbose, int? retainedFileCount = null) { - //.clef format (Compact log event format, that can be imported into local SEQ & will make searching/filtering logs easier) - //Ends with ..txt as Date is inserted before file extension substring + // .clef format (Compact log event format, that can be imported into local SEQ & will make searching/filtering logs easier) + // Ends with ..txt as Date is inserted before file extension substring logConfig.WriteTo.File(new CompactJsonFormatter(), Path.Combine(hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.LogFiles) ,$"UmbracoTraceLog.{Environment.MachineName}..json"), shared: true, - rollingInterval: RollingInterval.Day, //Create a new JSON file every day - retainedFileCountLimit: retainedFileCount, //Setting to null means we keep all files - default is 31 days + rollingInterval: RollingInterval.Day, // Create a new JSON file every day + retainedFileCountLimit: retainedFileCount, // Setting to null means we keep all files - default is 31 days restrictedToMinimumLevel: minimumLevel); return logConfig; diff --git a/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs b/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs index 94b868f145..1bbd9042b0 100644 --- a/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs +++ b/src/Umbraco.Infrastructure/Manifest/DataEditorConverter.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using Umbraco.Core.Composing; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; @@ -22,11 +21,19 @@ namespace Umbraco.Core.Manifest private readonly ILocalizationService _localizationService; private readonly ILocalizedTextService _textService; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _jsonSerializer; /// /// Initializes a new instance of the class. /// - public DataEditorConverter(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService textService, IShortStringHelper shortStringHelper) + public DataEditorConverter( + ILoggerFactory loggerFactory, + IIOHelper ioHelper, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService textService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) { _loggerFactory = loggerFactory; _ioHelper = ioHelper; @@ -34,6 +41,7 @@ namespace Umbraco.Core.Manifest _localizationService = localizationService; _textService = textService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; } /// @@ -61,7 +69,7 @@ namespace Umbraco.Core.Manifest type = EditorType.MacroParameter; } - return new DataEditor(_loggerFactory, _dataTypeService, _localizationService, _textService, _shortStringHelper, type); + return new DataEditor(_loggerFactory, _dataTypeService, _localizationService, _textService, _shortStringHelper, _jsonSerializer, type); } /// @@ -88,7 +96,7 @@ namespace Umbraco.Core.Manifest // explicitly assign a value editor of type ValueEditor // (else the deserializer will try to read it before setting it) // (and besides it's an interface) - target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper); + target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper, _jsonSerializer); // in the manifest, validators are a simple dictionary eg // { @@ -160,7 +168,7 @@ namespace Umbraco.Core.Manifest if (jobject.Property("view") != null) { // explicitly assign a value editor of type ParameterValueEditor - target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper); + target.ExplicitValueEditor = new DataValueEditor(_dataTypeService, _localizationService, _textService, _shortStringHelper, _jsonSerializer); // move the 'view' property jobject["editor"] = new JObject { ["view"] = jobject["view"] }; diff --git a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs index eec83dffef..15ddcebb7e 100644 --- a/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs +++ b/src/Umbraco.Infrastructure/Manifest/ManifestParser.cs @@ -196,7 +196,7 @@ namespace Umbraco.Core.Manifest if (string.IsNullOrWhiteSpace(text)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(text)); var manifest = JsonConvert.DeserializeObject(text, - new DataEditorConverter(_loggerFactory, _ioHelper, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper), + new DataEditorConverter(_loggerFactory, _ioHelper, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, _jsonSerializer), new ValueValidatorConverter(_validators), new DashboardAccessRuleConverter()); diff --git a/src/Umbraco.Infrastructure/Media/IImageDimensionExtractor.cs b/src/Umbraco.Infrastructure/Media/IImageDimensionExtractor.cs new file mode 100644 index 0000000000..3da7f37393 --- /dev/null +++ b/src/Umbraco.Infrastructure/Media/IImageDimensionExtractor.cs @@ -0,0 +1,9 @@ +using System.IO; + +namespace Umbraco.Web.Media +{ + public interface IImageDimensionExtractor + { + public ImageSize GetDimensions(Stream stream); + } +} diff --git a/src/Umbraco.Infrastructure/Media/ImageHelper.cs b/src/Umbraco.Infrastructure/Media/ImageDimensionExtractor.cs similarity index 58% rename from src/Umbraco.Infrastructure/Media/ImageHelper.cs rename to src/Umbraco.Infrastructure/Media/ImageDimensionExtractor.cs index ee01ec4a1c..538c559cf6 100644 --- a/src/Umbraco.Infrastructure/Media/ImageHelper.cs +++ b/src/Umbraco.Infrastructure/Media/ImageDimensionExtractor.cs @@ -2,11 +2,11 @@ using System.Drawing; using System.IO; using Umbraco.Core; -using Umbraco.Web.Media.Exif; +using Umbraco.Core.Media; namespace Umbraco.Web.Media { - public static class ImageHelper + internal class ImageDimensionExtractor : IImageDimensionExtractor { /// /// Gets the dimensions of an image. @@ -16,24 +16,14 @@ namespace Umbraco.Web.Media /// First try with EXIF as it is faster and does not load the entire image /// in memory. Fallback to GDI which means loading the image in memory and thus /// use potentially large amounts of memory. - public static Size GetDimensions(Stream stream) + public ImageSize GetDimensions(Stream stream) { //Try to load with exif try { - var jpgInfo = ImageFile.FromStream(stream); - - if (jpgInfo != null - && jpgInfo.Format != ImageFileFormat.Unknown - && jpgInfo.Properties.ContainsKey(ExifTag.PixelYDimension) - && jpgInfo.Properties.ContainsKey(ExifTag.PixelXDimension)) + if (ExifImageDimensionExtractor.TryGetDimensions(stream, out var width, out var height)) { - var height = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelYDimension].Value); - var width = Convert.ToInt32(jpgInfo.Properties[ExifTag.PixelXDimension].Value); - if (height > 0 && width > 0) - { - return new Size(width, height); - } + return new ImageSize(width, height); } } catch @@ -48,7 +38,7 @@ namespace Umbraco.Web.Media { var fileWidth = image.Width; var fileHeight = image.Height; - return new Size(fileWidth, fileHeight); + return new ImageSize(fileWidth, fileHeight); } } catch (Exception) @@ -56,7 +46,7 @@ namespace Umbraco.Web.Media //We will just swallow, just means we can't read via GDI, we don't want to log an error either } - return new Size(Constants.Conventions.Media.DefaultSize, Constants.Conventions.Media.DefaultSize); + return new ImageSize(Constants.Conventions.Media.DefaultSize, Constants.Conventions.Media.DefaultSize); } } } diff --git a/src/Umbraco.Infrastructure/Media/ImageSize.cs b/src/Umbraco.Infrastructure/Media/ImageSize.cs new file mode 100644 index 0000000000..6d073ac196 --- /dev/null +++ b/src/Umbraco.Infrastructure/Media/ImageSize.cs @@ -0,0 +1,15 @@ +namespace Umbraco.Web.Media +{ + public struct ImageSize + { + public int Width { get; } + public int Height { get; } + + + public ImageSize(int width, int height) + { + Width = width; + Height = height; + } + } +} diff --git a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs index deeed7a07c..44d5f5c8c3 100644 --- a/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs +++ b/src/Umbraco.Infrastructure/Media/UploadAutoFillProperties.cs @@ -1,5 +1,4 @@ using System; -using System.Drawing; using System.IO; using Microsoft.Extensions.Logging; using Umbraco.Core; @@ -18,15 +17,18 @@ namespace Umbraco.Web.Media private readonly IMediaFileSystem _mediaFileSystem; private readonly ILogger _logger; private readonly IImageUrlGenerator _imageUrlGenerator; + private readonly IImageDimensionExtractor _imageDimensionExtractor; public UploadAutoFillProperties( IMediaFileSystem mediaFileSystem, ILogger logger, - IImageUrlGenerator imageUrlGenerator) + IImageUrlGenerator imageUrlGenerator, + IImageDimensionExtractor imageDimensionExtractor) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _imageUrlGenerator = imageUrlGenerator ?? throw new ArgumentNullException(nameof(imageUrlGenerator)); + _imageDimensionExtractor = imageDimensionExtractor ?? throw new ArgumentNullException(nameof(imageDimensionExtractor)); } /// @@ -71,7 +73,7 @@ namespace Umbraco.Web.Media using (var filestream = _mediaFileSystem.OpenFile(filepath)) { var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.'); - var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null; + var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (ImageSize?)_imageDimensionExtractor.GetDimensions(filestream) : null; SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment); } } @@ -105,12 +107,12 @@ namespace Umbraco.Web.Media else { var extension = (Path.GetExtension(filepath) ?? "").TrimStart('.'); - var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (Size?)ImageHelper.GetDimensions(filestream) : null; + var size = _imageUrlGenerator.IsSupportedImageFormat(extension) ? (ImageSize?)_imageDimensionExtractor.GetDimensions(filestream) : null; SetProperties(content, autoFillConfig, size, filestream.Length, extension, culture, segment); } } - private static void SetProperties(IContentBase content, ImagingAutoFillUploadField autoFillConfig, Size? size, long length, string extension, string culture, string segment) + private static void SetProperties(IContentBase content, ImagingAutoFillUploadField autoFillConfig, ImageSize? size, long length, string extension, string culture, string segment) { if (content == null) throw new ArgumentNullException(nameof(content)); if (autoFillConfig == null) throw new ArgumentNullException(nameof(autoFillConfig)); diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs index b27bc48c8e..98e9bcb4bb 100644 --- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs +++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Xml.Linq; @@ -462,7 +462,7 @@ namespace Umbraco.Core.Migrations.Install { Message = "The database configuration failed with the following message: " + ex.Message + - "\n Please check log file for additional information (can be found in '/App_Data/Logs/')", + $"\n Please check log file for additional information (can be found in '{Constants.SystemDirectories.LogFiles}')", Success = false, Percentage = "90" }; diff --git a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs index 483529036b..0b9572cb20 100644 --- a/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs +++ b/src/Umbraco.Infrastructure/Packaging/PackageDataInstallation.cs @@ -8,7 +8,6 @@ using System.Xml.XPath; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Core.Collections; -using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; @@ -17,7 +16,6 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; using Umbraco.Core.Serialization; using Umbraco.Core.Services; -using Umbraco.Core.Services.Implement; using Umbraco.Core.Strings; namespace Umbraco.Core.Packaging @@ -36,6 +34,7 @@ namespace Umbraco.Core.Packaging private readonly GlobalSettings _globalSettings; private readonly ILocalizedTextService _localizedTextService; private readonly IConfigurationEditorJsonSerializer _serializer; + private readonly IJsonSerializer _jsonSerializer; private readonly IEntityService _entityService; private readonly IContentTypeService _contentTypeService; private readonly IContentService _contentService; @@ -43,7 +42,7 @@ namespace Umbraco.Core.Packaging public PackageDataInstallation(ILogger logger, ILoggerFactory loggerFactory, IFileService fileService, IMacroService macroService, ILocalizationService localizationService, IDataTypeService dataTypeService, IEntityService entityService, IContentTypeService contentTypeService, IContentService contentService, PropertyEditorCollection propertyEditors, IScopeProvider scopeProvider, IShortStringHelper shortStringHelper, IOptions globalSettings, - ILocalizedTextService localizedTextService, IConfigurationEditorJsonSerializer serializer) + ILocalizedTextService localizedTextService, IConfigurationEditorJsonSerializer serializer, IJsonSerializer jsonSerializer) { _logger = logger; _loggerFactory = loggerFactory; @@ -57,6 +56,7 @@ namespace Umbraco.Core.Packaging _globalSettings = globalSettings.Value; _localizedTextService = localizedTextService; _serializer = serializer; + _jsonSerializer = jsonSerializer; _entityService = entityService; _contentTypeService = contentTypeService; _contentService = contentService; @@ -916,7 +916,7 @@ namespace Umbraco.Core.Packaging var editorAlias = dataTypeElement.Attribute("Id")?.Value?.Trim(); if (!_propertyEditors.TryGet(editorAlias, out var editor)) - editor = new VoidEditor(_loggerFactory, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper) { Alias = editorAlias }; + editor = new VoidEditor(_loggerFactory, _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, _jsonSerializer) { Alias = editorAlias }; var dataType = new DataType(editor, _serializer) { diff --git a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs index 4ec233e17f..89fce803b2 100644 --- a/src/Umbraco.Infrastructure/Persistence/LocalDb.cs +++ b/src/Umbraco.Infrastructure/Persistence/LocalDb.cs @@ -937,7 +937,7 @@ namespace Umbraco.Core.Persistence /// This is a C# implementation of T-SQL QUOTEDNAME. /// is optional, it can be '[' (default), ']', '\'' or '"'. /// - private static string QuotedName(string name, char quote = '[') + internal static string QuotedName(string name, char quote = '[') { switch (quote) { diff --git a/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs index 7b98bd150e..5c3c984677 100644 --- a/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs +++ b/src/Umbraco.Infrastructure/Persistence/UmbracoDatabaseFactory.cs @@ -327,16 +327,5 @@ namespace Umbraco.Core.Persistence //db?.Dispose(); Volatile.Write(ref _initialized, false); } - - // during tests, the thread static var can leak between tests - // this method provides a way to force-reset the variable - internal void ResetForTests() - { - // TODO: remove all this eventually - //var db = _umbracoDatabaseAccessor.UmbracoDatabase; - //_umbracoDatabaseAccessor.UmbracoDatabase = null; - //db?.Dispose(); - //_databaseScopeAccessor.Scope = null; - } } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs index b1e5fb0199..81281a3302 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockEditorPropertyEditor.cs @@ -1,14 +1,15 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Blocks; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using static Umbraco.Core.Models.Blocks.BlockItemData; @@ -35,8 +36,9 @@ namespace Umbraco.Web.PropertyEditors IContentTypeService contentTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _localizedTextService = localizedTextService; _propertyEditors = propertyEditors; @@ -49,7 +51,7 @@ namespace Umbraco.Web.PropertyEditors #region Value Editor - protected override IDataValueEditor CreateValueEditor() => new BlockEditorPropertyValueEditor(Attribute, PropertyEditors, _dataTypeService, _contentTypeService, _localizedTextService, LoggerFactory.CreateLogger(), LocalizationService,ShortStringHelper); + protected override IDataValueEditor CreateValueEditor() => new BlockEditorPropertyValueEditor(Attribute, PropertyEditors, _dataTypeService, _contentTypeService, _localizedTextService, LoggerFactory.CreateLogger(), LocalizationService,ShortStringHelper, JsonSerializer); internal class BlockEditorPropertyValueEditor : DataValueEditor, IDataValueReference { @@ -58,8 +60,8 @@ namespace Umbraco.Web.PropertyEditors private readonly ILogger _logger; private readonly BlockEditorValues _blockEditorValues; - public BlockEditorPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService textService, ILogger logger, ILocalizationService localizationService, IShortStringHelper shortStringHelper) - : base(dataTypeService, localizationService, textService, shortStringHelper, attribute) + public BlockEditorPropertyValueEditor(DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizedTextService textService, ILogger logger, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, textService, shortStringHelper, jsonSerializer, attribute) { _propertyEditors = propertyEditors; _dataTypeService = dataTypeService; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs index 6a23d0da00..1657b4098d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/BlockListPropertyEditor.cs @@ -1,12 +1,9 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Linq; +using System; using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.IO; -using Umbraco.Core.Models.Blocks; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -34,8 +31,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizedTextService localizedTextService, IIOHelper ioHelper, ILocalizationService localizationService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, propertyEditors, dataTypeService, contentTypeService, localizedTextService, localizationService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, propertyEditors, dataTypeService, contentTypeService, localizedTextService, localizationService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs index 09600d86ae..27d729e319 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/CheckBoxListPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -28,8 +29,8 @@ namespace Umbraco.Web.PropertyEditors /// /// The constructor will setup the property editor based on the attribute if one is found /// - public CheckBoxListPropertyEditor(ILoggerFactory loggerFactory, ILocalizedTextService textService, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IIOHelper ioHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public CheckBoxListPropertyEditor(ILoggerFactory loggerFactory, ILocalizedTextService textService, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IIOHelper ioHelper, ILocalizedTextService localizedTextService, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _textService = textService; _dataTypeService = dataTypeService; @@ -43,6 +44,6 @@ namespace Umbraco.Web.PropertyEditors protected override IConfigurationEditor CreateConfigurationEditor() => new ValueListConfigurationEditor(_textService, _ioHelper); /// - protected override IDataValueEditor CreateValueEditor() => new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _localizedTextService, _shortStringHelper, JsonSerializer, Attribute); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs index e2cc93bd7c..f5776b7c28 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerConfigurationEditor.cs @@ -1,19 +1,23 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Runtime.Serialization; using System.Text.RegularExpressions; -using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; namespace Umbraco.Web.PropertyEditors { internal class ColorPickerConfigurationEditor : ConfigurationEditor { - public ColorPickerConfigurationEditor(IIOHelper ioHelper) : base(ioHelper) + private readonly IJsonSerializer _jsonSerializer; + + public ColorPickerConfigurationEditor(IIOHelper ioHelper, IJsonSerializer jsonSerializer) : base(ioHelper) { + _jsonSerializer = jsonSerializer; var items = Fields.First(x => x.Key == "items"); // customize the items field @@ -67,7 +71,7 @@ namespace Umbraco.Web.PropertyEditors { try { - var o = JsonConvert.DeserializeObject(item.Value); + var o = _jsonSerializer.Deserialize(item.Value); o.SortOrder = sortOrder; return o; } @@ -82,15 +86,16 @@ namespace Umbraco.Web.PropertyEditors } // represents an item we are exchanging with the editor + [DataContract] private class ItemValue { - [JsonProperty("value")] + [DataMember(Name ="value")] public string Color { get; set; } - [JsonProperty("label")] + [DataMember(Name ="label")] public string Label { get; set; } - [JsonProperty("sortOrder")] + [DataMember(Name ="sortOrder")] public int SortOrder { get; set; } } @@ -131,7 +136,7 @@ namespace Umbraco.Web.PropertyEditors if (id >= nextId) nextId = id + 1; var label = item.Property("label")?.Value?.Value(); - value = JsonConvert.SerializeObject(new { value, label }); + value = _jsonSerializer.Serialize(new { value, label }); output.Items.Add(new ValueListConfiguration.ValueListItem { Id = id, Value = value }); } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs index 575609a934..aec8e4b137 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ColorPickerPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -17,13 +18,13 @@ namespace Umbraco.Web.PropertyEditors { private readonly IIOHelper _ioHelper; - public ColorPickerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public ColorPickerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } /// - protected override IConfigurationEditor CreateConfigurationEditor() => new ColorPickerConfigurationEditor(_ioHelper); + protected override IConfigurationEditor CreateConfigurationEditor() => new ColorPickerConfigurationEditor(_ioHelper, JsonSerializer); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs index 4c172ccb2e..c95f14e8e0 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ContentPickerPropertyEditor.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -32,8 +33,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizedTextService localizedTextService, ILoggerFactory loggerFactory, IIOHelper ioHelper, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService,localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _dataTypeService = dataTypeService; _localizationService = localizationService; @@ -46,11 +48,12 @@ namespace Umbraco.Web.PropertyEditors return new ContentPickerConfigurationEditor(_ioHelper); } - protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new ContentPickerPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, JsonSerializer, Attribute); internal class ContentPickerPropertyValueEditor : DataValueEditor, IDataValueReference { - public ContentPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public ContentPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs index db4c6734a8..40ece10a1e 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/DateTimePropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -24,8 +25,8 @@ namespace Umbraco.Web.PropertyEditors /// Initializes a new instance of the class. /// /// - public DateTimePropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public DateTimePropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs index 66f605bc36..186730775e 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/DropDownFlexiblePropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -21,8 +22,15 @@ namespace Umbraco.Web.PropertyEditors private readonly IShortStringHelper _shortStringHelper; private readonly IIOHelper _ioHelper; - public DropDownFlexiblePropertyEditor(ILocalizedTextService textService, ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IIOHelper ioHelper) - : base(loggerFactory, dataTypeService, localizationService, textService, shortStringHelper) + public DropDownFlexiblePropertyEditor( + ILocalizedTextService textService, + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IShortStringHelper shortStringHelper, + IIOHelper ioHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, textService, shortStringHelper, jsonSerializer) { _textService = textService; _dataTypeService = dataTypeService; @@ -33,7 +41,7 @@ namespace Umbraco.Web.PropertyEditors protected override IDataValueEditor CreateValueEditor() { - return new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _textService, _shortStringHelper, Attribute); + return new MultipleValueEditor(LoggerFactory.CreateLogger(), _dataTypeService, _localizationService, _textService, _shortStringHelper, JsonSerializer, Attribute); } protected override IConfigurationEditor CreateConfigurationEditor() => new DropDownFlexibleConfigurationEditor(_textService, _ioHelper); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs index 2cdfd4f7eb..120a522cd7 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/EmailAddressPropertyEditor.cs @@ -3,6 +3,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -27,8 +28,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs index 448e2043c0..b425432b01 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyEditor.cs @@ -7,9 +7,9 @@ using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; -using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Media; @@ -39,8 +39,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, - UploadAutoFillProperties uploadAutoFillProperties) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + UploadAutoFillProperties uploadAutoFillProperties, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _contentSettings = contentSettings.Value; @@ -56,7 +57,7 @@ namespace Umbraco.Web.PropertyEditors /// The corresponding property value editor. protected override IDataValueEditor CreateValueEditor() { - var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Options.Create(_contentSettings)); + var editor = new FileUploadPropertyValueEditor(Attribute, _mediaFileSystem, _dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Options.Create(_contentSettings), JsonSerializer); editor.Validators.Add(new UploadFileTypeValidator(_localizedTextService, Options.Create(_contentSettings))); return editor; } @@ -162,7 +163,7 @@ namespace Umbraco.Web.PropertyEditors /// /// The event sender. /// The event arguments. - internal void MediaServiceSaving(IMediaService sender, Core.Events.SaveEventArgs args) + public void MediaServiceSaving(IMediaService sender, Core.Events.SaveEventArgs args) { foreach (var entity in args.SavedEntities) AutoFillProperties(entity); @@ -173,7 +174,7 @@ namespace Umbraco.Web.PropertyEditors /// /// The event sender. /// The event arguments. - internal void ContentServiceSaving(IContentService sender, Core.Events.SaveEventArgs args) + public void ContentServiceSaving(IContentService sender, Core.Events.SaveEventArgs args) { foreach (var entity in args.SavedEntities) AutoFillProperties(entity); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs index db675e2e42..8ccb59988d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/FileUploadPropertyValueEditor.cs @@ -6,6 +6,7 @@ using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -26,8 +27,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, - IOptions contentSettings) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + IOptions contentSettings, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs index e6db6a4328..2bac76e6f9 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/GridPropertyEditor.cs @@ -10,6 +10,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Templates; @@ -47,8 +48,9 @@ namespace Umbraco.Web.PropertyEditors HtmlLocalLinkParser localLinkParser, IIOHelper ioHelper, IShortStringHelper shortStringHelper, - IImageUrlGenerator imageUrlGenerator) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _ioHelper = ioHelper; @@ -64,7 +66,7 @@ namespace Umbraco.Web.PropertyEditors /// Overridden to ensure that the value is validated /// /// - protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator); + protected override IDataValueEditor CreateValueEditor() => new GridPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, _imageSourceParser, _pastedImages, _localLinkParser, ShortStringHelper, _imageUrlGenerator, JsonSerializer); protected override IConfigurationEditor CreateConfigurationEditor() => new GridConfigurationEditor(_ioHelper); @@ -87,14 +89,15 @@ namespace Umbraco.Web.PropertyEditors RichTextEditorPastedImages pastedImages, HtmlLocalLinkParser localLinkParser, IShortStringHelper shortStringHelper, - IImageUrlGenerator imageUrlGenerator) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; _pastedImages = pastedImages; - _richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, backOfficeSecurityAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator); - _mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute); + _richTextPropertyValueEditor = new RichTextPropertyEditor.RichTextPropertyValueEditor(attribute, backOfficeSecurityAccessor, dataTypeService, localizationService, localizedTextService, shortStringHelper, imageSourceParser, localLinkParser, pastedImages, imageUrlGenerator, jsonSerializer); + _mediaPickerPropertyValueEditor = new MediaPickerPropertyEditor.MediaPickerPropertyValueEditor(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute); _imageUrlGenerator = imageUrlGenerator; } diff --git a/src/Umbraco.Core/PropertyEditors/ImageCropperConfiguration.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperConfiguration.cs similarity index 100% rename from src/Umbraco.Core/PropertyEditors/ImageCropperConfiguration.cs rename to src/Umbraco.Infrastructure/PropertyEditors/ImageCropperConfiguration.cs diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs index 3434ee5bcb..1f35b9d88a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyEditor.cs @@ -1,17 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; -using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Media; @@ -50,8 +50,9 @@ namespace Umbraco.Web.PropertyEditors IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService, - UploadAutoFillProperties uploadAutoFillProperties) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + UploadAutoFillProperties uploadAutoFillProperties, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); _contentSettings = contentSettings.Value ?? throw new ArgumentNullException(nameof(contentSettings)); @@ -76,7 +77,7 @@ namespace Umbraco.Web.PropertyEditors /// Creates the corresponding property value editor. /// /// The corresponding property value editor. - protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, LoggerFactory.CreateLogger(), _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings); + protected override IDataValueEditor CreateValueEditor() => new ImageCropperPropertyValueEditor(Attribute, LoggerFactory.CreateLogger(), _mediaFileSystem, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _contentSettings, JsonSerializer); /// /// Creates the corresponding preValue editor. diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs index 6a1f3072d4..c058856ebd 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ImageCropperPropertyValueEditor.cs @@ -9,6 +9,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.ValueConverters; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using File = System.IO.File; @@ -32,8 +33,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, - ContentSettings contentSettings) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + ContentSettings contentSettings, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _mediaFileSystem = mediaFileSystem ?? throw new ArgumentNullException(nameof(mediaFileSystem)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs index 639a9c928d..78c5087c66 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/LabelPropertyEditor.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using Umbraco.Core.IO; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -21,14 +22,14 @@ namespace Umbraco.Core.PropertyEditors /// /// Initializes a new instance of the class. /// - public LabelPropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public LabelPropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } /// - protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(DataTypeService, LocalizationService,LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new LabelPropertyValueEditor(DataTypeService, LocalizationService,LocalizedTextService, ShortStringHelper, Attribute, JsonSerializer); /// protected override IConfigurationEditor CreateConfigurationEditor() => new LabelConfigurationEditor(_ioHelper); @@ -36,8 +37,8 @@ namespace Umbraco.Core.PropertyEditors // provides the property value editor internal class LabelPropertyValueEditor : DataValueEditor { - public LabelPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public LabelPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute, IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs index e01258eb80..d7fd2d9340 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/ListViewPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -24,15 +25,21 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - /// public ListViewPropertyEditor( ILoggerFactory loggerFactory, IIOHelper iioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base( + loggerFactory, + dataTypeService, + localizationService, + localizedTextService, + shortStringHelper, + jsonSerializer) { _iioHelper = iioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs index ab4e6f3d97..97386de326 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MarkdownPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -30,8 +31,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs index 476674b1ff..e69ff5be9d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MediaPickerPropertyEditor.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -33,8 +34,9 @@ namespace Umbraco.Web.PropertyEditors ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, - ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } @@ -42,12 +44,18 @@ namespace Umbraco.Web.PropertyEditors /// protected override IConfigurationEditor CreateConfigurationEditor() => new MediaPickerConfigurationEditor(_ioHelper); - protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MediaPickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); public class MediaPickerPropertyValueEditor : DataValueEditor, IDataValueReference { - public MediaPickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService,localizationService, localizedTextService, shortStringHelper,attribute) + public MediaPickerPropertyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService,localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs index fc80aabdd9..b7ec4813b2 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs @@ -4,6 +4,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,20 +21,33 @@ namespace Umbraco.Web.PropertyEditors { private readonly IIOHelper _ioHelper; - public MultiNodeTreePickerPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public MultiNodeTreePickerPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } protected override IConfigurationEditor CreateConfigurationEditor() => new MultiNodePickerConfigurationEditor(_ioHelper); - protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MultiNodeTreePickerPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); public class MultiNodeTreePickerPropertyValueEditor : DataValueEditor, IDataValueReference { - public MultiNodeTreePickerPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultiNodeTreePickerPropertyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs index afd749eed3..fdb908e2be 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerPropertyEditor.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Logging; using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.PublishedCache; @@ -26,8 +27,19 @@ namespace Umbraco.Web.PropertyEditors private readonly IUmbracoContextAccessor _umbracoContextAccessor; private readonly IPublishedUrlProvider _publishedUrlProvider; - public MultiUrlPickerPropertyEditor(ILoggerFactory loggerFactory, Lazy entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, IUmbracoContextAccessor umbracoContextAccessor, IPublishedUrlProvider publishedUrlProvider) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, EditorType.PropertyValue) + public MultiUrlPickerPropertyEditor( + ILoggerFactory loggerFactory, + Lazy entityService, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + IUmbracoContextAccessor umbracoContextAccessor, + IPublishedUrlProvider publishedUrlProvider, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, EditorType.PropertyValue) { _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); @@ -38,6 +50,6 @@ namespace Umbraco.Web.PropertyEditors protected override IConfigurationEditor CreateConfigurationEditor() => new MultiUrlPickerConfigurationEditor(_ioHelper); - protected override IDataValueEditor CreateValueEditor() => new MultiUrlPickerValueEditor(_entityService.Value, _publishedSnapshotAccessor, LoggerFactory.CreateLogger(), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute, _umbracoContextAccessor, _publishedUrlProvider); + protected override IDataValueEditor CreateValueEditor() => new MultiUrlPickerValueEditor(_entityService.Value, _publishedSnapshotAccessor, LoggerFactory.CreateLogger(), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute, _umbracoContextAccessor, _publishedUrlProvider, JsonSerializer); } } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs index 380408c2b1..a4427cd26d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultiUrlPickerValueEditor.cs @@ -1,14 +1,15 @@ -using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.Models.Entities; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.Models.ContentEditing; @@ -25,8 +26,19 @@ namespace Umbraco.Web.PropertyEditors private readonly IPublishedUrlProvider _publishedUrlProvider; private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - public MultiUrlPickerValueEditor(IEntityService entityService, IPublishedSnapshotAccessor publishedSnapshotAccessor, ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute, IUmbracoContextAccessor umbracoContextAccessor, IPublishedUrlProvider publishedUrlProvider) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultiUrlPickerValueEditor( + IEntityService entityService, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + ILogger logger, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + DataEditorAttribute attribute, + IUmbracoContextAccessor umbracoContextAccessor, + IPublishedUrlProvider publishedUrlProvider, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _entityService = entityService ?? throw new ArgumentNullException(nameof(entityService)); _publishedSnapshotAccessor = publishedSnapshotAccessor ?? throw new ArgumentNullException(nameof(publishedSnapshotAccessor)); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs index b4e1287315..c9aeb0e59a 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringPropertyEditor.cs @@ -11,6 +11,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -36,8 +37,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public MultipleTextStringPropertyEditor(ILoggerFactory loggerFactory, IIOHelper ioHelper, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public MultipleTextStringPropertyEditor( + ILoggerFactory loggerFactory, + IIOHelper ioHelper, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; _dataTypeService = dataTypeService; @@ -46,7 +54,7 @@ namespace Umbraco.Web.PropertyEditors } /// - protected override IDataValueEditor CreateValueEditor() => new MultipleTextStringPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new MultipleTextStringPropertyValueEditor(_dataTypeService, _localizationService, _localizedTextService, ShortStringHelper, JsonSerializer, Attribute); /// protected override IConfigurationEditor CreateConfigurationEditor() => new MultipleTextStringConfigurationEditor(_ioHelper); @@ -58,8 +66,14 @@ namespace Umbraco.Web.PropertyEditors { private readonly ILocalizedTextService _localizedTextService; - public MultipleTextStringPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultipleTextStringPropertyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _localizedTextService = localizedTextService; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs index a960ac51ad..5f82ed940f 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/MultipleValueEditor.cs @@ -5,6 +5,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -20,8 +21,16 @@ namespace Umbraco.Web.PropertyEditors { private readonly ILogger _logger; - public MultipleValueEditor(ILogger logger, IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + public MultipleValueEditor( + ILogger logger, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, + DataEditorAttribute attribute + ) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _logger = logger; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs index 98f8771699..8afc08c423 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/NestedContentPropertyEditor.cs @@ -9,6 +9,7 @@ using Umbraco.Core.IO; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -42,8 +43,9 @@ namespace Umbraco.Web.PropertyEditors IContentTypeService contentTypeService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, - ILocalizedTextService localizedTextService) - : base (loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base (loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _propertyEditors = propertyEditors; _contentTypeService = contentTypeService; @@ -62,7 +64,7 @@ namespace Umbraco.Web.PropertyEditors #region Value Editor - protected override IDataValueEditor CreateValueEditor() => new NestedContentPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, _contentTypeService, ShortStringHelper, Attribute, PropertyEditors, LoggerFactory.CreateLogger()); + protected override IDataValueEditor CreateValueEditor() => new NestedContentPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, _contentTypeService, ShortStringHelper, Attribute, PropertyEditors, LoggerFactory.CreateLogger(), JsonSerializer); internal class NestedContentPropertyValueEditor : DataValueEditor, IDataValueReference { @@ -82,8 +84,9 @@ namespace Umbraco.Web.PropertyEditors IShortStringHelper shortStringHelper, DataEditorAttribute attribute, PropertyEditorCollection propertyEditors, - ILogger logger) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + ILogger logger, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { _propertyEditors = propertyEditors; _contentTypeService = contentTypeService; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs index 6a863b1dd1..444e99bd23 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RadioButtonsPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -30,8 +31,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs index 049f020db4..e97b8c0520 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/RichTextPropertyEditor.cs @@ -8,6 +8,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Examine; @@ -50,8 +51,9 @@ namespace Umbraco.Web.PropertyEditors IShortStringHelper shortStringHelper, IIOHelper ioHelper, ILocalizedTextService localizedTextService, - IImageUrlGenerator imageUrlGenerator) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; @@ -65,7 +67,7 @@ namespace Umbraco.Web.PropertyEditors /// Create a custom value editor /// /// - protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator); + protected override IDataValueEditor CreateValueEditor() => new RichTextPropertyValueEditor(Attribute, _backOfficeSecurityAccessor, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, _imageSourceParser, _localLinkParser, _pastedImages, _imageUrlGenerator, JsonSerializer); protected override IConfigurationEditor CreateConfigurationEditor() => new RichTextConfigurationEditor(_ioHelper); @@ -92,8 +94,9 @@ namespace Umbraco.Web.PropertyEditors HtmlImageSourceParser imageSourceParser, HtmlLocalLinkParser localLinkParser, RichTextEditorPastedImages pastedImages, - IImageUrlGenerator imageUrlGenerator) - : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute) + IImageUrlGenerator imageUrlGenerator, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer, attribute) { _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _imageSourceParser = imageSourceParser; diff --git a/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs index bb62c3461d..48197691a2 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/SliderPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -28,8 +29,9 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs index 708f4d8c9f..a2fb340d14 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TagsPropertyEditor.cs @@ -8,6 +8,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -34,21 +35,22 @@ namespace Umbraco.Web.PropertyEditors IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _validators = validators; _ioHelper = ioHelper; } - protected override IDataValueEditor CreateValueEditor() => new TagPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new TagPropertyValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); protected override IConfigurationEditor CreateConfigurationEditor() => new TagConfigurationEditor(_validators, _ioHelper, LocalizedTextService); internal class TagPropertyValueEditor : DataValueEditor { - public TagPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, DataEditorAttribute attribute) - : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, attribute) + public TagPropertyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, DataEditorAttribute attribute) + : base(dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer, attribute) { } /// diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs index 8d173e58bc..d65f6f3a1d 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TextAreaPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -28,8 +29,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public TextAreaPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService,shortStringHelper) + public TextAreaPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IIOHelper ioHelper, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _dataTypeService = dataTypeService; _localizationService = localizationService; @@ -39,7 +47,7 @@ namespace Umbraco.Web.PropertyEditors } /// - protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(_dataTypeService, _localizationService, Attribute, _localizedTextService, _shortStringHelper); + protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(_dataTypeService, _localizationService, Attribute, _localizedTextService, _shortStringHelper, JsonSerializer); /// protected override IConfigurationEditor CreateConfigurationEditor() => new TextAreaConfigurationEditor(_ioHelper); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs index 1ec87abe9b..350dd4a1ff 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TextboxPropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -27,8 +28,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public TextboxPropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper) + public TextboxPropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService,localizedTextService, shortStringHelper, jsonSerializer) { _dataTypeService = dataTypeService; _localizationService = localizationService; @@ -38,7 +46,7 @@ namespace Umbraco.Web.PropertyEditors } /// - protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(_dataTypeService, _localizationService, Attribute, _localizedTextService, _shortStringHelper); + protected override IDataValueEditor CreateValueEditor() => new TextOnlyValueEditor(DataTypeService, LocalizationService, Attribute, LocalizedTextService, ShortStringHelper, JsonSerializer); /// protected override IConfigurationEditor CreateConfigurationEditor() => new TextboxConfigurationEditor(_ioHelper); diff --git a/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs index db72887fff..3c9599c643 100644 --- a/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs +++ b/src/Umbraco.Infrastructure/PropertyEditors/TrueFalsePropertyEditor.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.IO; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -25,8 +26,15 @@ namespace Umbraco.Web.PropertyEditors /// /// Initializes a new instance of the class. /// - public TrueFalsePropertyEditor(ILoggerFactory loggerFactory, IDataTypeService dataTypeService, ILocalizationService localizationService, IIOHelper ioHelper, IShortStringHelper shortStringHelper, ILocalizedTextService localizedTextService) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public TrueFalsePropertyEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + IIOHelper ioHelper, + IShortStringHelper shortStringHelper, + ILocalizedTextService localizedTextService, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { _ioHelper = ioHelper; } diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs index dc71c475d1..c9a67a8543 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs @@ -1,6 +1,7 @@ using System; using Examine; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Core.Cache; using Umbraco.Core.Composing; @@ -9,6 +10,7 @@ using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Grid; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Dashboards; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Dictionary; using Umbraco.Core.Events; using Umbraco.Core.Hosting; @@ -25,6 +27,7 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; using Umbraco.Core.PropertyEditors.ValueConverters; using Umbraco.Core.Scoping; +using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Services.Implement; @@ -56,14 +59,7 @@ using Umbraco.Web.Sections; using Umbraco.Web.Services; using Umbraco.Web.Templates; using Umbraco.Web.Trees; -using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator; using TextStringValueConverter = Umbraco.Core.PropertyEditors.ValueConverters.TextStringValueConverter; -using Microsoft.Extensions.Logging; -using Umbraco.Core.DependencyInjection; -using Umbraco.Core.Configuration.HealthChecks; -using Umbraco.Core.HealthCheck; -using Umbraco.Core.HealthCheck.Checks; -using Umbraco.Core.Security; namespace Umbraco.Core.Runtime { @@ -303,6 +299,7 @@ namespace Umbraco.Core.Runtime builder.Services.AddUnique(); // register *all* checks, except those marked [HideFromTypeFinder] of course + builder.Services.AddUnique(); builder.HealthChecks() .Add(() => builder.TypeLoader.GetTypes()); @@ -382,6 +379,7 @@ namespace Umbraco.Core.Runtime builder.Services.AddUnique(); builder.Services.AddUnique(); + builder.Services.AddUnique(); } } } diff --git a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs index 41bdaa9e01..c73a817327 100644 --- a/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs +++ b/src/Umbraco.Infrastructure/Runtime/SqlMainDomLock.cs @@ -7,7 +7,7 @@ using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Umbraco.Core.Configuration; +using NPoco; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Hosting; using Umbraco.Core.Persistence; @@ -42,7 +42,7 @@ namespace Umbraco.Core.Runtime loggerFactory, globalSettings, connectionStrings, - new Lazy(() => new MapperCollection(Enumerable.Empty())), + new Lazy(() => new Persistence.Mappers.MapperCollection(Enumerable.Empty())), dbProviderFactoryCreator); MainDomKey = MainDomKeyPrefix + "-" + (NetworkHelper.MachineName + MainDom.GetMainDomId(_hostingEnvironment)).GenerateHash(); @@ -57,7 +57,9 @@ namespace Umbraco.Core.Runtime } if (!(_dbFactory.SqlContext.SqlSyntax is SqlServerSyntaxProvider sqlServerSyntaxProvider)) + { throw new NotSupportedException("SqlMainDomLock is only supported for Sql Server"); + } _sqlServerSyntax = sqlServerSyntaxProvider; @@ -65,11 +67,13 @@ namespace Umbraco.Core.Runtime var tempId = Guid.NewGuid().ToString(); - using var db = _dbFactory.CreateDatabase(); - using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted); + IUmbracoDatabase db = null; try { + db = _dbFactory.CreateDatabase(); + db.BeginTransaction(IsolationLevel.ReadCommitted); + try { // wait to get a write lock @@ -110,7 +114,8 @@ namespace Umbraco.Core.Runtime } finally { - transaction.Complete(); + db?.CompleteTransaction(); + db?.Dispose(); } @@ -172,11 +177,11 @@ namespace Umbraco.Core.Runtime return; } - - using var db = _dbFactory.CreateDatabase(); - using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted); + IUmbracoDatabase db = null; try { + db = _dbFactory.CreateDatabase(); + db.BeginTransaction(IsolationLevel.ReadCommitted); // get a read lock _sqlServerSyntax.ReadLock(db, Constants.Locks.MainDom); @@ -202,7 +207,8 @@ namespace Umbraco.Core.Runtime } finally { - transaction.Complete(); + db?.CompleteTransaction(); + db?.Dispose(); } } @@ -221,34 +227,47 @@ namespace Umbraco.Core.Runtime return Task.Run(() => { - using var db = _dbFactory.CreateDatabase(); - - var watch = new Stopwatch(); - watch.Start(); - while (true) + try { - // poll very often, we need to take over as fast as we can - // local testing shows the actual query to be executed from client/server is approx 300ms but would change depending on environment/IO - Thread.Sleep(1000); + using var db = _dbFactory.CreateDatabase(); - var acquired = TryAcquire(db, tempId, updatedTempId); - if (acquired.HasValue) - return acquired.Value; - - if (watch.ElapsedMilliseconds >= millisecondsTimeout) + var watch = new Stopwatch(); + watch.Start(); + while (true) { - return AcquireWhenMaxWaitTimeElapsed(db); + // poll very often, we need to take over as fast as we can + // local testing shows the actual query to be executed from client/server is approx 300ms but would change depending on environment/IO + Thread.Sleep(1000); + + var acquired = TryAcquire(db, tempId, updatedTempId); + if (acquired.HasValue) + return acquired.Value; + + if (watch.ElapsedMilliseconds >= millisecondsTimeout) + { + return AcquireWhenMaxWaitTimeElapsed(db); + } } } + catch (Exception ex) + { + _logger.LogError(ex, "An error occurred trying to acquire and waiting for existing SqlMainDomLock to shutdown"); + return false; + } + }, _cancellationTokenSource.Token); } private bool? TryAcquire(IUmbracoDatabase db, string tempId, string updatedTempId) { - using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted); + // Creates a separate transaction to the DB instance so we aren't allocating tons of new DB instances for each transaction + // since this is executed in a tight loop + + ITransaction transaction = null; try { + transaction = db.GetTransaction(IsolationLevel.ReadCommitted); // get a read lock _sqlServerSyntax.ReadLock(db, Constants.Locks.MainDom); @@ -294,7 +313,8 @@ namespace Umbraco.Core.Runtime } finally { - transaction.Complete(); + transaction?.Complete(); + transaction?.Dispose(); } return null; // continue @@ -302,6 +322,9 @@ namespace Umbraco.Core.Runtime private bool AcquireWhenMaxWaitTimeElapsed(IUmbracoDatabase db) { + // Creates a separate transaction to the DB instance so we aren't allocating tons of new DB instances for each transaction + // since this is executed in a tight loop + // if the timeout has elapsed, it either means that the other main dom is taking too long to shutdown, // or it could mean that the previous appdomain was terminated and didn't clear out the main dom SQL row // and it's just been left as an orphan row. @@ -311,10 +334,12 @@ namespace Umbraco.Core.Runtime _logger.LogDebug("Timeout elapsed, assuming orphan row, acquiring MainDom."); - using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted); + ITransaction transaction = null; try { + transaction = db.GetTransaction(IsolationLevel.ReadCommitted); + _sqlServerSyntax.WriteLock(db, Constants.Locks.MainDom); // so now we update the row with our appdomain id @@ -337,7 +362,8 @@ namespace Umbraco.Core.Runtime } finally { - transaction.Complete(); + transaction?.Complete(); + transaction?.Dispose(); } } @@ -390,11 +416,12 @@ namespace Umbraco.Core.Runtime if (_dbFactory.Configured) { - using var db = _dbFactory.CreateDatabase(); - using var transaction = db.GetTransaction(IsolationLevel.ReadCommitted); - + IUmbracoDatabase db = null; try { + db = _dbFactory.CreateDatabase(); + db.BeginTransaction(IsolationLevel.ReadCommitted); + // get a write lock _sqlServerSyntax.WriteLock(db, Constants.Locks.MainDom); @@ -421,7 +448,15 @@ namespace Umbraco.Core.Runtime } finally { - transaction.Complete(); + try + { + db?.CompleteTransaction(); + db?.Dispose(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Unexpected error during dispose when completing transaction."); + } } } } diff --git a/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs b/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs index eb6a94c4ee..042128558b 100644 --- a/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs +++ b/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs @@ -6,11 +6,11 @@ using Umbraco.Core.Events; using Umbraco.Core.Exceptions; using Umbraco.Core.IO; using Umbraco.Core.Models; -using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; +using Umbraco.Core.Serialization; using Umbraco.Core.Strings; namespace Umbraco.Core.Services.Implement @@ -29,11 +29,14 @@ namespace Umbraco.Core.Services.Implement private readonly ILocalizedTextService _localizedTextService; private readonly ILocalizationService _localizationService; private readonly IShortStringHelper _shortStringHelper; + private readonly IJsonSerializer _jsonSerializer; public DataTypeService(IScopeProvider provider, ILoggerFactory loggerFactory, IEventMessagesFactory eventMessagesFactory, IDataTypeRepository dataTypeRepository, IDataTypeContainerRepository dataTypeContainerRepository, IAuditRepository auditRepository, IEntityRepository entityRepository, IContentTypeRepository contentTypeRepository, - IIOHelper ioHelper, ILocalizedTextService localizedTextService, ILocalizationService localizationService, IShortStringHelper shortStringHelper) + IIOHelper ioHelper, ILocalizedTextService localizedTextService, ILocalizationService localizationService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) : base(provider, loggerFactory, eventMessagesFactory) { _dataTypeRepository = dataTypeRepository; @@ -45,6 +48,7 @@ namespace Umbraco.Core.Services.Implement _localizedTextService = localizedTextService; _localizationService = localizationService; _shortStringHelper = shortStringHelper; + _jsonSerializer = jsonSerializer; } #region Containers @@ -324,7 +328,7 @@ namespace Umbraco.Core.Services.Implement .Where(x => x.Editor is MissingPropertyEditor); foreach (var dataType in dataTypesWithMissingEditors) { - dataType.Editor = new LabelPropertyEditor(LoggerFactory, _ioHelper, this, _localizedTextService, _localizationService, _shortStringHelper); + dataType.Editor = new LabelPropertyEditor(LoggerFactory, _ioHelper, this, _localizedTextService, _localizationService, _shortStringHelper, _jsonSerializer); } } diff --git a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj index edb68c6b93..9f63604b0e 100644 --- a/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj +++ b/src/Umbraco.PublishedCache.NuCache/Umbraco.PublishedCache.NuCache.csproj @@ -21,12 +21,15 @@ - - <_Parameter1>Umbraco.Tests - + + <_Parameter1>Umbraco.Tests + + + <_Parameter1>Umbraco.Tests.UnitTests + <_Parameter1>Umbraco.Tests.Integration - + <_Parameter1>Umbraco.Tests.Benchmarks diff --git a/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs b/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs index a781c6ccea..a600d2d962 100644 --- a/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs +++ b/src/Umbraco.Tests.Common/Builders/DataEditorBuilder.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -46,7 +47,9 @@ namespace Umbraco.Tests.Common.Builders Mock.Of(), Mock.Of(), Mock.Of(), - Mock.Of()) + Mock.Of(), + Mock.Of() + ) { DefaultConfiguration = defaultConfiguration, ExplicitConfigurationEditor = explicitConfigurationEditor, diff --git a/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs b/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs index cee0931060..61f6c3df78 100644 --- a/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs +++ b/src/Umbraco.Tests.Common/Builders/DataValueEditorBuilder.cs @@ -4,6 +4,7 @@ using System; using Moq; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -56,7 +57,9 @@ namespace Umbraco.Tests.Common.Builders Mock.Of(), Mock.Of(), Mock.Of(), - Mock.Of()) + Mock.Of(), + Mock.Of() + ) { Configuration = configuration, View = view, diff --git a/src/Umbraco.Tests.Common/TestHelperBase.cs b/src/Umbraco.Tests.Common/TestHelperBase.cs index 24759f9ffb..ed3e28ee21 100644 --- a/src/Umbraco.Tests.Common/TestHelperBase.cs +++ b/src/Umbraco.Tests.Common/TestHelperBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Reflection; using Microsoft.Extensions.DependencyInjection; @@ -48,7 +48,7 @@ namespace Umbraco.Tests.Common public TypeLoader GetMockedTypeLoader() { - return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), Mock.Of()); + return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), Mock.Of()); } // public Configs GetConfigs() => GetConfigsFactory().Create(); diff --git a/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs b/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs index 78aa0c7bc6..b80a2996ca 100644 --- a/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs +++ b/src/Umbraco.Tests.Common/TestHelpers/MockedValueEditors.cs @@ -1,5 +1,6 @@ using Moq; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -16,6 +17,7 @@ namespace Umbraco.Tests.TestHelpers.Entities Mock.Of(), Mock.Of(), Mock.Of(), + new JsonNetSerializer(), new DataEditorAttribute(name, name, name) { ValueType = valueType diff --git a/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs b/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs index 958b7e558b..e7f6cc4442 100644 --- a/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests.Common/TestHelpers/SolidPublishedSnapshot.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging; using Moq; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -412,11 +411,12 @@ namespace Umbraco.Tests.Common.PublishedContent static AutoPublishedContentType() { - var serializer = new ConfigurationEditorJsonSerializer(); + var configurationEditorJsonSerializer = new ConfigurationEditorJsonSerializer(); + var jsonSerializer = new JsonNetSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(Mock.Of(), dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), jsonSerializer), configurationEditorJsonSerializer) { Id = 666 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests/Testing/TestDatabase.cs b/src/Umbraco.Tests.Common/TestHelpers/TestDatabase.cs similarity index 99% rename from src/Umbraco.Tests/Testing/TestDatabase.cs rename to src/Umbraco.Tests.Common/TestHelpers/TestDatabase.cs index 7d58433a52..d1e5669100 100644 --- a/src/Umbraco.Tests/Testing/TestDatabase.cs +++ b/src/Umbraco.Tests.Common/TestHelpers/TestDatabase.cs @@ -11,7 +11,6 @@ using NPoco.DatabaseTypes; using NPoco.Linq; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.SqlSyntax; -using Umbraco.Persistance.SqlCe; namespace Umbraco.Tests.Testing { @@ -33,8 +32,8 @@ namespace Umbraco.Tests.Testing /// public TestDatabase(DatabaseType databaseType = null, ISqlSyntaxProvider syntaxProvider = null) { - DatabaseType = databaseType ?? new SqlServerCEDatabaseType(); - SqlContext = new SqlContext(syntaxProvider ?? new SqlCeSyntaxProvider(), DatabaseType, Mock.Of()); + DatabaseType = databaseType ?? new SqlServerDatabaseType(); + SqlContext = new SqlContext(syntaxProvider ?? new SqlServerSyntaxProvider(), DatabaseType, Mock.Of()); } /// diff --git a/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs b/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs index fe1d604dd9..6e86e97770 100644 --- a/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs +++ b/src/Umbraco.Tests.Integration/GlobalSetupTeardown.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Text; @@ -23,7 +23,8 @@ public class TestsSetup [OneTimeTearDown] public void TearDown() { - LocalDbTestDatabase.KillLocalDb(); + LocalDbTestDatabase.Instance?.Finish(); + SqlDeveloperTestDatabase.Instance?.Finish(); Console.WriteLine("TOTAL TESTS DURATION: {0}", _stopwatch.Elapsed); } } diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs index d60f49971a..93769eaaed 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs @@ -132,11 +132,12 @@ namespace Umbraco.Tests.Integration.TestServerTest public override void ConfigureServices(IServiceCollection services) { + services.AddTransient(); var typeLoader = services.AddTypeLoader(GetType().Assembly, TestHelper.GetWebHostEnvironment(), TestHelper.GetHostingEnvironment(), TestHelper.ConsoleLoggerFactory, AppCaches.NoCache, Configuration, TestHelper.Profiler); var builder = new UmbracoBuilder(services, Configuration, typeLoader); - + builder .AddConfiguration() .AddTestCore(TestHelper) // This is the important one! diff --git a/src/Umbraco.Tests.Integration/Testing/BaseTestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/BaseTestDatabase.cs new file mode 100644 index 0000000000..02a3da676a --- /dev/null +++ b/src/Umbraco.Tests.Integration/Testing/BaseTestDatabase.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; +using System.Diagnostics; +using System.Linq; +using System.Threading; +using Microsoft.Extensions.Logging; +using Umbraco.Core.Configuration; +using Umbraco.Core.Migrations.Install; +using Umbraco.Core.Persistence; + +namespace Umbraco.Tests.Integration.Testing +{ + public abstract class BaseTestDatabase + { + protected ILoggerFactory _loggerFactory; + protected IUmbracoDatabaseFactory _databaseFactory; + protected IEnumerable _testDatabases; + + protected UmbracoDatabase.CommandInfo[] _cachedDatabaseInitCommands; + + protected BlockingCollection _prepareQueue; + protected BlockingCollection _readySchemaQueue; + protected BlockingCollection _readyEmptyQueue; + + protected abstract void Initialize(); + + public TestDbMeta AttachEmpty() + { + if (_prepareQueue == null) + { + Initialize(); + } + + return _readyEmptyQueue.Take(); + } + + public TestDbMeta AttachSchema() + { + if (_prepareQueue == null) + { + Initialize(); + } + + return _readySchemaQueue.Take(); + } + + public void Detach(TestDbMeta meta) + { + _prepareQueue.TryAdd(meta); + } + + protected void PrepareDatabase() + { + Retry(10, () => + { + while (_prepareQueue.IsCompleted == false) + { + TestDbMeta meta; + try + { + meta = _prepareQueue.Take(); + } + catch (InvalidOperationException) + { + continue; + } + + using (var conn = new SqlConnection(meta.ConnectionString)) + using (var cmd = conn.CreateCommand()) + { + conn.Open(); + ResetTestDatabase(cmd); + + if (!meta.IsEmpty) + { + RebuildSchema(cmd, meta); + } + } + + if (!meta.IsEmpty) + { + _readySchemaQueue.TryAdd(meta); + } + else + { + _readyEmptyQueue.TryAdd(meta); + } + } + }); + } + + protected void RebuildSchema(IDbCommand command, TestDbMeta meta) + { + if (_cachedDatabaseInitCommands != null) + { + foreach (var dbCommand in _cachedDatabaseInitCommands) + { + + if (dbCommand.Text.StartsWith("SELECT ")) + { + continue; + } + + command.CommandText = dbCommand.Text; + command.Parameters.Clear(); + + foreach (var parameterInfo in dbCommand.Parameters) + { + AddParameter(command, parameterInfo); + } + + command.ExecuteNonQuery(); + } + } + else + { + _databaseFactory.Configure(meta.ConnectionString, Core.Constants.DatabaseProviders.SqlServer); + + using (var database = (UmbracoDatabase)_databaseFactory.CreateDatabase()) + { + database.LogCommands = true; + + using (var transaction = database.GetTransaction()) + { + var schemaCreator = new DatabaseSchemaCreator(database, _loggerFactory.CreateLogger(), _loggerFactory, new UmbracoVersion()); + schemaCreator.InitializeDatabaseSchema(); + + transaction.Complete(); + + _cachedDatabaseInitCommands = database.Commands.ToArray(); + } + } + } + } + + protected static void SetCommand(SqlCommand command, string sql, params object[] args) + { + command.CommandType = CommandType.Text; + command.CommandText = sql; + command.Parameters.Clear(); + + for (var i = 0; i < args.Length; i++) + { + command.Parameters.AddWithValue("@" + i, args[i]); + } + } + + protected static void AddParameter(IDbCommand cmd, UmbracoDatabase.ParameterInfo parameterInfo) + { + var p = cmd.CreateParameter(); + p.ParameterName = parameterInfo.Name; + p.Value = parameterInfo.Value; + p.DbType = parameterInfo.DbType; + p.Size = parameterInfo.Size; + cmd.Parameters.Add(p); + } + + protected static void ResetTestDatabase(IDbCommand cmd) + { + // https://stackoverflow.com/questions/536350 + + cmd.CommandType = CommandType.Text; + cmd.CommandText = @" + declare @n char(1); + set @n = char(10); + declare @stmt nvarchar(max); + -- check constraints + select @stmt = isnull( @stmt + @n, '' ) + + 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']' + from sys.check_constraints; + -- foreign keys + select @stmt = isnull( @stmt + @n, '' ) + + 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']' + from sys.foreign_keys; + -- tables + select @stmt = isnull( @stmt + @n, '' ) + + 'drop table [' + schema_name(schema_id) + '].[' + name + ']' + from sys.tables; + exec sp_executesql @stmt; + "; + + // rudimentary retry policy since a db can still be in use when we try to drop + Retry(10, () => cmd.ExecuteNonQuery()); + } + + protected static void Retry(int maxIterations, Action action) + { + for (var i = 0; i < maxIterations; i++) + { + try + { + action(); + return; + } + catch (SqlException) + { + + //Console.Error.WriteLine($"SqlException occured, but we try again {i+1}/{maxIterations}.\n{e}"); + // This can occur when there's a transaction deadlock which means (i think) that the database is still in use and hasn't been closed properly yet + // so we need to just wait a little bit + Thread.Sleep(100 * i); + if (i == maxIterations - 1) + { + Debugger.Launch(); + throw; + } + } + catch (InvalidOperationException) + { + // Ignore + } + } + } + } +} diff --git a/src/Umbraco.Tests.Integration/Testing/ITestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/ITestDatabase.cs new file mode 100644 index 0000000000..28d7e9c8bc --- /dev/null +++ b/src/Umbraco.Tests.Integration/Testing/ITestDatabase.cs @@ -0,0 +1,9 @@ +namespace Umbraco.Tests.Integration.Testing +{ + public interface ITestDatabase + { + TestDbMeta AttachEmpty(); + TestDbMeta AttachSchema(); + void Detach(TestDbMeta id); + } +} diff --git a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs index dacfd950e0..39d74f8869 100644 --- a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs +++ b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs @@ -49,8 +49,10 @@ namespace Umbraco.Tests.Integration.Testing // we don't want persisted nucache files in tests builder.Services.AddTransient(factory => new PublishedSnapshotServiceOptions { IgnoreLocalDb = true }); + #if IS_WINDOWS // ensure all lucene indexes are using RAM directory (no file system) builder.Services.AddUnique(); + #endif // replace this service so that it can lookup the correct file locations builder.Services.AddUnique(GetLocalizedTextService); diff --git a/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs index 39f9ca5592..a9a842cdcd 100644 --- a/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs +++ b/src/Umbraco.Tests.Integration/Testing/LocalDbTestDatabase.cs @@ -1,18 +1,8 @@ -using System; +using System; using System.Collections.Concurrent; -using System.Configuration; -using System.Data; -using System.Data.Common; -using System.Data.SqlClient; -using System.Diagnostics; using System.IO; -using System.Linq; using System.Threading; using Microsoft.Extensions.Logging; -using Umbraco.Core; -using Umbraco.Core.Configuration; -using Umbraco.Core.Configuration.Models; -using Umbraco.Core.Migrations.Install; using Umbraco.Core.Persistence; namespace Umbraco.Tests.Integration.Testing @@ -20,197 +10,104 @@ namespace Umbraco.Tests.Integration.Testing /// /// Manages a pool of LocalDb databases for integration testing /// - public class LocalDbTestDatabase + public class LocalDbTestDatabase : BaseTestDatabase, ITestDatabase { public const string InstanceName = "UmbracoTests"; public const string DatabaseName = "UmbracoTests"; - private readonly ILoggerFactory _loggerFactory; private readonly LocalDb _localDb; - private readonly IUmbracoVersion _umbracoVersion; - private static LocalDb.Instance _instance; + private static LocalDb.Instance _localDbInstance; private static string _filesPath; - private readonly IUmbracoDatabaseFactory _dbFactory; - private UmbracoDatabase.CommandInfo[] _dbCommands; - private string _currentCstr; - private static DatabasePool _emptyPool; - private static DatabasePool _schemaPool; - private DatabasePool _currentPool; + + private const int _threadCount = 2; + + public static LocalDbTestDatabase Instance { get; private set; } //It's internal because `Umbraco.Core.Persistence.LocalDb` is internal internal LocalDbTestDatabase(ILoggerFactory loggerFactory, LocalDb localDb, string filesPath, IUmbracoDatabaseFactory dbFactory) { - _umbracoVersion = new UmbracoVersion(); _loggerFactory = loggerFactory; + _databaseFactory = dbFactory; + _localDb = localDb; _filesPath = filesPath; - _dbFactory = dbFactory; - _instance = _localDb.GetInstance(InstanceName); - if (_instance != null) return; + Instance = this; // For GlobalSetupTeardown.cs + + _testDatabases = new[] + { + // With Schema + TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-1", false), + TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-2", false), + + // Empty (for migration testing etc) + TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-3", true), + TestDbMeta.CreateWithoutConnectionString($"{DatabaseName}-4", true), + }; + + _localDbInstance = _localDb.GetInstance(InstanceName); + if (_localDbInstance != null) + { + return; + } if (_localDb.CreateInstance(InstanceName) == false) + { throw new Exception("Failed to create a LocalDb instance."); - _instance = _localDb.GetInstance(InstanceName); + } + + _localDbInstance = _localDb.GetInstance(InstanceName); } - public string ConnectionString => _currentCstr ?? _instance.GetAttachedConnectionString("XXXXXX", _filesPath); - - private void Create() + protected override void Initialize() { var tempName = Guid.NewGuid().ToString("N"); - _instance.CreateDatabase(tempName, _filesPath); - _instance.DetachDatabase(tempName); + _localDbInstance.CreateDatabase(tempName, _filesPath); + _localDbInstance.DetachDatabase(tempName); + _prepareQueue = new BlockingCollection(); + _readySchemaQueue = new BlockingCollection(); + _readyEmptyQueue = new BlockingCollection(); - // there's probably a sweet spot to be found for size / parallel... - - var s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.EmptyPoolSize"]; - var emptySize = s == null ? 1 : int.Parse(s); - s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.EmptyPoolThreadCount"]; - var emptyParallel = s == null ? 1 : int.Parse(s); - s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.SchemaPoolSize"]; - var schemaSize = s == null ? 1 : int.Parse(s); - s = ConfigurationManager.AppSettings["Umbraco.Tests.LocalDbTestDatabase.SchemaPoolThreadCount"]; - var schemaParallel = s == null ? 1 : int.Parse(s); - - _emptyPool = new DatabasePool(_localDb, _instance, DatabaseName + "-Empty", tempName, _filesPath, emptySize, emptyParallel); - _schemaPool = new DatabasePool(_localDb, _instance, DatabaseName + "-Schema", tempName, _filesPath, schemaSize, schemaParallel, delete: true, prepare: RebuildSchema); - } - - public int AttachEmpty() - { - if (_emptyPool == null) - Create(); - - _currentCstr = _emptyPool.AttachDatabase(out var id); - _currentPool = _emptyPool; - return id; - } - - public int AttachSchema() - { - if (_schemaPool == null) - Create(); - - _currentCstr = _schemaPool.AttachDatabase(out var id); - _currentPool = _schemaPool; - return id; - } - - public void Detach(int id) - { - _currentPool.DetachDatabase(id); - } - - private void RebuildSchema(DbConnection conn, IDbCommand cmd) - { - - if (_dbCommands != null) + foreach (var meta in _testDatabases) { - foreach (var dbCommand in _dbCommands) - { - - if (dbCommand.Text.StartsWith("SELECT ")) continue; - - cmd.CommandText = dbCommand.Text; - cmd.Parameters.Clear(); - foreach (var parameterInfo in dbCommand.Parameters) - AddParameter(cmd, parameterInfo); - cmd.ExecuteNonQuery(); - } - } - else - { - _dbFactory.Configure(conn.ConnectionString, Constants.DatabaseProviders.SqlServer); - - using var database = (UmbracoDatabase)_dbFactory.CreateDatabase(); - // track each db command ran as part of creating the database so we can replay these - database.LogCommands = true; - - using var trans = database.GetTransaction(); - - var creator = new DatabaseSchemaCreator(database, _loggerFactory.CreateLogger(), _loggerFactory, _umbracoVersion); - creator.InitializeDatabaseSchema(); - - trans.Complete(); // commit it - - _dbCommands = database.Commands.ToArray(); + _localDb.CopyDatabaseFiles(tempName, _filesPath, targetDatabaseName: meta.Name, overwrite: true, delete: false); + meta.ConnectionString = _localDbInstance.GetAttachedConnectionString(meta.Name, _filesPath); + _prepareQueue.Add(meta); } - } - - private static void AddParameter(IDbCommand cmd, UmbracoDatabase.ParameterInfo parameterInfo) - { - var p = cmd.CreateParameter(); - p.ParameterName = parameterInfo.Name; - p.Value = parameterInfo.Value; - p.DbType = parameterInfo.DbType; - p.Size = parameterInfo.Size; - cmd.Parameters.Add(p); - } - - public void Clear() - { - var filename = Path.Combine(_filesPath, DatabaseName).ToUpper(); - - foreach (var database in _instance.GetDatabases()) + for (var i = 0; i < _threadCount; i++) { - if (database.StartsWith(filename)) - _instance.DropDatabase(database); - } - - foreach (var file in Directory.EnumerateFiles(_filesPath)) - { - if (file.EndsWith(".mdf") == false && file.EndsWith(".ldf") == false) continue; - File.Delete(file); + var thread = new Thread(PrepareDatabase); + thread.Start(); } } - private static void ResetLocalDb(IDbCommand cmd) + public void Finish() { - // https://stackoverflow.com/questions/536350 + if (_prepareQueue == null) + return; - cmd.CommandType = CommandType.Text; - cmd.CommandText = @" - declare @n char(1); - set @n = char(10); - declare @stmt nvarchar(max); - -- check constraints - select @stmt = isnull( @stmt + @n, '' ) + - 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']' - from sys.check_constraints; - -- foreign keys - select @stmt = isnull( @stmt + @n, '' ) + - 'alter table [' + schema_name(schema_id) + '].[' + object_name( parent_object_id ) + '] drop constraint [' + name + ']' - from sys.foreign_keys; - -- tables - select @stmt = isnull( @stmt + @n, '' ) + - 'drop table [' + schema_name(schema_id) + '].[' + name + ']' - from sys.tables; - exec sp_executesql @stmt; - "; + _prepareQueue.CompleteAdding(); + while (_prepareQueue.TryTake(out _)) + { } - // rudimentary retry policy since a db can still be in use when we try to drop - Retry(10, () => - { - cmd.ExecuteNonQuery(); - }); - } + _readyEmptyQueue.CompleteAdding(); + while (_readyEmptyQueue.TryTake(out _)) + { } - public static void KillLocalDb() - { - _emptyPool?.Stop(); - _schemaPool?.Stop(); + _readySchemaQueue.CompleteAdding(); + while (_readySchemaQueue.TryTake(out _)) + { } if (_filesPath == null) return; var filename = Path.Combine(_filesPath, DatabaseName).ToUpper(); - foreach (var database in _instance.GetDatabases()) + foreach (var database in _localDbInstance.GetDatabases()) { if (database.StartsWith(filename)) - _instance.DropDatabase(database); + _localDbInstance.DropDatabase(database); } foreach (var file in Directory.EnumerateFiles(_filesPath)) @@ -226,145 +123,5 @@ namespace Umbraco.Tests.Integration.Testing } } } - - private static void Retry(int maxIterations, Action action) - { - for (var i = 0; i < maxIterations; i++) - { - try - { - action(); - return; - } - catch (SqlException) - { - - //Console.Error.WriteLine($"SqlException occured, but we try again {i+1}/{maxIterations}.\n{e}"); - // This can occur when there's a transaction deadlock which means (i think) that the database is still in use and hasn't been closed properly yet - // so we need to just wait a little bit - Thread.Sleep(100 * i); - if (i == maxIterations - 1) - { - Debugger.Launch(); - throw; - } - } - catch (InvalidOperationException) - { - - } - } - } - - private class DatabasePool - { - private readonly LocalDb _localDb; - private readonly LocalDb.Instance _instance; - private readonly string _filesPath; - private readonly string _name; - private readonly int _size; - private readonly string[] _cstrs; - private readonly BlockingCollection _prepareQueue, _readyQueue; - private readonly Action _prepare; - private int _current; - - public DatabasePool(LocalDb localDb, LocalDb.Instance instance, string name, string tempName, string filesPath, int size, int parallel = 1, Action prepare = null, bool delete = false) - { - _localDb = localDb; - _instance = instance; - _filesPath = filesPath; - _name = name; - _size = size; - _prepare = prepare; - _prepareQueue = new BlockingCollection(); - _readyQueue = new BlockingCollection(); - _cstrs = new string[_size]; - - for (var i = 0; i < size; i++) - localDb.CopyDatabaseFiles(tempName, filesPath, targetDatabaseName: name + "-" + i, overwrite: true, delete: delete && i == size - 1); - - if (prepare == null) - { - for (var i = 0; i < size; i++) - _readyQueue.Add(i); - } - else - { - for (var i = 0; i < size; i++) - _prepareQueue.Add(i); - } - - for (var i = 0; i < parallel; i++) - { - var thread = new Thread(PrepareThread); - thread.Start(); - } - } - - public string AttachDatabase(out int id) - { - _current = _readyQueue.Take(); - id = _current; - - return ConnectionString(_current); - } - - public void DetachDatabase(int id) - { - if (id != _current) - throw new InvalidOperationException("Cannot detatch the non-current db"); - - _prepareQueue.Add(_current); - } - - private string ConnectionString(int i) - { - return _cstrs[i] ?? (_cstrs[i] = _instance.GetAttachedConnectionString(_name + "-" + i, _filesPath)); - } - - private void PrepareThread() - { - Retry(10, () => - { - while (_prepareQueue.IsCompleted == false) - { - int i; - try - { - i = _prepareQueue.Take(); - } - catch (InvalidOperationException) - { - continue; - } - - using (var conn = new SqlConnection(ConnectionString(i))) - using (var cmd = conn.CreateCommand()) - { - conn.Open(); - ResetLocalDb(cmd); - - _prepare?.Invoke(conn, cmd); - - } - - if (!_readyQueue.IsAddingCompleted) - { - _readyQueue.Add(i); - } - } - }); - } - - public void Stop() - { - int i; - _prepareQueue.CompleteAdding(); - while (_prepareQueue.TryTake(out i)) { } - _readyQueue.CompleteAdding(); - while (_readyQueue.TryTake(out i)) { } - } - } - } } diff --git a/src/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs b/src/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs new file mode 100644 index 0000000000..4a7f602ac6 --- /dev/null +++ b/src/Umbraco.Tests.Integration/Testing/SqlDeveloperTestDatabase.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Concurrent; +using System.Data.SqlClient; +using System.Threading; +using Microsoft.Extensions.Logging; +using Umbraco.Core.Persistence; + +// ReSharper disable ConvertToUsingDeclaration + +namespace Umbraco.Tests.Integration.Testing +{ + /// + /// It's not meant to be pretty, rushed port of LocalDb.cs + LocalDbTestDatabase.cs + /// + public class SqlDeveloperTestDatabase : BaseTestDatabase, ITestDatabase + { + private readonly string _masterConnectionString; + public const string DatabaseName = "UmbracoTests"; + + private const int _threadCount = 2; + + public static SqlDeveloperTestDatabase Instance { get; private set; } + + public SqlDeveloperTestDatabase(ILoggerFactory loggerFactory, IUmbracoDatabaseFactory databaseFactory, string masterConnectionString) + { + _loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); + _databaseFactory = databaseFactory ?? throw new ArgumentNullException(nameof(databaseFactory)); + + _masterConnectionString = masterConnectionString; + + _testDatabases = new[] + { + // With Schema + TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-1", false, masterConnectionString), + TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-2", false, masterConnectionString), + + // Empty (for migration testing etc) + TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-3", true, masterConnectionString), + TestDbMeta.CreateWithMasterConnectionString($"{DatabaseName}-4", true, masterConnectionString), + }; + + Instance = this; // For GlobalSetupTeardown.cs + } + + protected override void Initialize() + { + _prepareQueue = new BlockingCollection(); + _readySchemaQueue = new BlockingCollection(); + _readyEmptyQueue = new BlockingCollection(); + + foreach (var meta in _testDatabases) + { + CreateDatabase(meta); + _prepareQueue.Add(meta); + } + + for (var i = 0; i < _threadCount; i++) + { + var thread = new Thread(PrepareDatabase); + thread.Start(); + } + } + + private void CreateDatabase(TestDbMeta meta) + { + using (var connection = new SqlConnection(_masterConnectionString)) + { + connection.Open(); + using (var command = connection.CreateCommand()) + { + SetCommand(command, $@"CREATE DATABASE {LocalDb.QuotedName(meta.Name)}"); + command.ExecuteNonQuery(); + } + } + } + + private void Drop(TestDbMeta meta) + { + using (var connection = new SqlConnection(_masterConnectionString)) + { + connection.Open(); + using (var command = connection.CreateCommand()) + { + SetCommand(command, $@" + ALTER DATABASE{LocalDb.QuotedName(meta.Name)} + SET SINGLE_USER + WITH ROLLBACK IMMEDIATE + "); + command.ExecuteNonQuery(); + + SetCommand(command, $@"DROP DATABASE {LocalDb.QuotedName(meta.Name)}"); + command.ExecuteNonQuery(); + } + } + } + + public void Finish() + { + if (_prepareQueue == null) + return; + + _prepareQueue.CompleteAdding(); + while (_prepareQueue.TryTake(out _)) { } + + _readyEmptyQueue.CompleteAdding(); + while (_readyEmptyQueue.TryTake(out _)) { } + + _readySchemaQueue.CompleteAdding(); + while (_readySchemaQueue.TryTake(out _)) { } + + foreach (var testDatabase in _testDatabases) + { + Drop(testDatabase); + } + } + } +} diff --git a/src/Umbraco.Tests.Integration/Testing/TestDatabaseFactory.cs b/src/Umbraco.Tests.Integration/Testing/TestDatabaseFactory.cs new file mode 100644 index 0000000000..9bcbfa4d3a --- /dev/null +++ b/src/Umbraco.Tests.Integration/Testing/TestDatabaseFactory.cs @@ -0,0 +1,43 @@ +using System; +using Microsoft.Extensions.Logging; +using Umbraco.Core.Persistence; + +namespace Umbraco.Tests.Integration.Testing +{ + public class TestDatabaseFactory + { + public static ITestDatabase Create(string filesPath, ILoggerFactory loggerFactory, TestUmbracoDatabaseFactoryProvider dbFactory) + { + return string.IsNullOrEmpty(Environment.GetEnvironmentVariable("UmbracoIntegrationTestConnectionString")) + ? CreateLocalDb(filesPath, loggerFactory, dbFactory.Create()) + : CreateSqlDeveloper(loggerFactory, dbFactory.Create()); + } + + private static ITestDatabase CreateLocalDb(string filesPath, ILoggerFactory loggerFactory, IUmbracoDatabaseFactory dbFactory) + { + var localDb = new LocalDb(); + + if (!localDb.IsAvailable) + { + throw new InvalidOperationException("LocalDB is not available."); + } + + return new LocalDbTestDatabase(loggerFactory, localDb, filesPath, dbFactory); + } + + private static ITestDatabase CreateSqlDeveloper(ILoggerFactory loggerFactory, IUmbracoDatabaseFactory dbFactory) + { + // $ export SA_PASSWORD=Foobar123! + // $ export UmbracoIntegrationTestConnectionString="Server=localhost,1433;User Id=sa;Password=$SA_PASSWORD;" + // $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$SA_PASSWORD" -e 'MSSQL_PID=Developer' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu + var connectionString = Environment.GetEnvironmentVariable("UmbracoIntegrationTestConnectionString"); + + if (string.IsNullOrEmpty(connectionString)) + { + throw new InvalidOperationException("ENV: UmbracoIntegrationTestConnectionString is not set"); + } + + return new SqlDeveloperTestDatabase(loggerFactory, dbFactory, connectionString); + } + } +} diff --git a/src/Umbraco.Tests.Integration/Testing/TestDbMeta.cs b/src/Umbraco.Tests.Integration/Testing/TestDbMeta.cs new file mode 100644 index 0000000000..83702db8e5 --- /dev/null +++ b/src/Umbraco.Tests.Integration/Testing/TestDbMeta.cs @@ -0,0 +1,39 @@ +using System.Text.RegularExpressions; + +namespace Umbraco.Tests.Integration.Testing +{ + public class TestDbMeta + { + + public string Name { get; } + + public bool IsEmpty { get; } + + public string ConnectionString { get; set; } + + private TestDbMeta(string name, bool isEmpty, string connectionString) + { + IsEmpty = isEmpty; + Name = name; + ConnectionString = connectionString; + } + + private static string ConstructConnectionString(string masterConnectionString, string databaseName) + { + var prefix = Regex.Replace(masterConnectionString, "Database=.+?;", string.Empty); + var connectionString = $"{prefix};Database={databaseName};"; + return connectionString.Replace(";;", ";"); + } + + public static TestDbMeta CreateWithMasterConnectionString(string name, bool isEmpty, string masterConnectionString) + { + return new TestDbMeta(name, isEmpty, ConstructConnectionString(masterConnectionString, name)); + } + + // LocalDb mdf funtimes + public static TestDbMeta CreateWithoutConnectionString(string name, bool isEmpty) + { + return new TestDbMeta(name, isEmpty, null); + } + } +} diff --git a/src/Umbraco.Tests.Integration/Testing/TestUmbracoDatabaseFactoryProvider.cs b/src/Umbraco.Tests.Integration/Testing/TestUmbracoDatabaseFactoryProvider.cs new file mode 100644 index 0000000000..3eb3757207 --- /dev/null +++ b/src/Umbraco.Tests.Integration/Testing/TestUmbracoDatabaseFactoryProvider.cs @@ -0,0 +1,48 @@ +using System; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using Umbraco.Core.Configuration.Models; +using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Mappers; + +namespace Umbraco.Tests.Integration.Testing +{ + /// + /// I want to be able to create a database for integration testsing without setting the connection string on the + /// singleton database factory forever. + /// + public class TestUmbracoDatabaseFactoryProvider + { + private readonly ILoggerFactory _loggerFactory; + private readonly IOptions _globalSettings; + private readonly IOptions _connectionStrings; + private readonly Lazy _mappers; + private readonly IDbProviderFactoryCreator _dbProviderFactoryCreator; + + public TestUmbracoDatabaseFactoryProvider( + ILoggerFactory loggerFactory, + IOptions globalSettings, + IOptions connectionStrings, + Lazy mappers, + IDbProviderFactoryCreator dbProviderFactoryCreator) + { + _loggerFactory = loggerFactory; + _globalSettings = globalSettings; + _connectionStrings = connectionStrings; + _mappers = mappers; + _dbProviderFactoryCreator = dbProviderFactoryCreator; + } + + public IUmbracoDatabaseFactory Create() + { + // ReSharper disable once ArrangeMethodOrOperatorBody + return new UmbracoDatabaseFactory( + _loggerFactory.CreateLogger(), + _loggerFactory, + _globalSettings.Value, + _connectionStrings.Value, + _mappers, + _dbProviderFactoryCreator); + } + } +} diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index a8875de286..43b2d236c7 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -165,6 +165,7 @@ namespace Umbraco.Tests.Integration.Testing public virtual void ConfigureServices(IServiceCollection services) { services.AddSingleton(TestHelper.DbProviderFactoryCreator); + services.AddTransient(); var webHostEnvironment = TestHelper.GetWebHostEnvironment(); services.AddRequiredNetCoreServices(TestHelper, webHostEnvironment); @@ -242,17 +243,17 @@ namespace Umbraco.Tests.Integration.Testing #region LocalDb private static readonly object _dbLocker = new object(); - private static LocalDbTestDatabase _dbInstance; + private static ITestDatabase _dbInstance; + private static TestDbMeta _fixtureDbMeta; protected void UseTestLocalDb(IServiceProvider serviceProvider) { var state = serviceProvider.GetRequiredService(); + var testDatabaseFactoryProvider = serviceProvider.GetRequiredService(); var databaseFactory = serviceProvider.GetRequiredService(); // This will create a db, install the schema and ensure the app is configured to run - InstallTestLocalDb(databaseFactory, TestHelper.ConsoleLoggerFactory, state, TestHelper.WorkingDirectory); - TestDBConnectionString = databaseFactory.ConnectionString; - InMemoryConfiguration["ConnectionStrings:" + Constants.System.UmbracoConnectionName] = TestDBConnectionString; + InstallTestLocalDb(testDatabaseFactoryProvider, databaseFactory, serviceProvider.GetRequiredService(), state, TestHelper.WorkingDirectory); } /// @@ -267,17 +268,14 @@ namespace Umbraco.Tests.Integration.Testing /// /// There must only be ONE instance shared between all tests in a session /// - private static LocalDbTestDatabase GetOrCreateDatabase(string filesPath, ILoggerFactory loggerFactory, IUmbracoDatabaseFactory dbFactory) + private static ITestDatabase GetOrCreateDatabase(string filesPath, ILoggerFactory loggerFactory, TestUmbracoDatabaseFactoryProvider dbFactory) { lock (_dbLocker) { if (_dbInstance != null) return _dbInstance; - var localDb = new LocalDb(); - if (localDb.IsAvailable == false) - throw new InvalidOperationException("LocalDB is not available."); - _dbInstance = new LocalDbTestDatabase(loggerFactory, localDb, filesPath, dbFactory); + _dbInstance = TestDatabaseFactory.Create(filesPath, loggerFactory, dbFactory); return _dbInstance; } } @@ -285,16 +283,12 @@ namespace Umbraco.Tests.Integration.Testing /// /// Creates a LocalDb instance to use for the test /// - /// - /// - /// - /// - /// - /// - /// private void InstallTestLocalDb( - IUmbracoDatabaseFactory databaseFactory, ILoggerFactory loggerFactory, - IRuntimeState runtimeState, string workingDirectory) + TestUmbracoDatabaseFactoryProvider testUmbracoDatabaseFactoryProvider, + IUmbracoDatabaseFactory databaseFactory, + ILoggerFactory loggerFactory, + IRuntimeState runtimeState, + string workingDirectory) { var dbFilePath = Path.Combine(workingDirectory, "LocalDb"); @@ -310,22 +304,22 @@ namespace Umbraco.Tests.Integration.Testing if (!Directory.Exists(dbFilePath)) Directory.CreateDirectory(dbFilePath); - var db = GetOrCreateDatabase(dbFilePath, loggerFactory, databaseFactory); + var db = GetOrCreateDatabase(dbFilePath, loggerFactory, testUmbracoDatabaseFactoryProvider); switch (testOptions.Database) { case UmbracoTestOptions.Database.NewSchemaPerTest: // New DB + Schema - var newSchemaDbId = db.AttachSchema(); + var newSchemaDbMeta = db.AttachSchema(); // Add teardown callback - OnTestTearDown(() => db.Detach(newSchemaDbId)); + OnTestTearDown(() => db.Detach(newSchemaDbMeta)); // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings if (!databaseFactory.Configured) { - databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer); + databaseFactory.Configure(newSchemaDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer); } // re-run the runtime level check @@ -335,15 +329,15 @@ namespace Umbraco.Tests.Integration.Testing break; case UmbracoTestOptions.Database.NewEmptyPerTest: - var newEmptyDbId = db.AttachEmpty(); + var newEmptyDbMeta = db.AttachEmpty(); // Add teardown callback - OnTestTearDown(() => db.Detach(newEmptyDbId)); + OnTestTearDown(() => db.Detach(newEmptyDbMeta)); // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings if (!databaseFactory.Configured) { - databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer); + databaseFactory.Configure(newEmptyDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer); } // re-run the runtime level check @@ -359,16 +353,17 @@ namespace Umbraco.Tests.Integration.Testing if (FirstTestInFixture) { // New DB + Schema - var newSchemaFixtureDbId = db.AttachSchema(); + var newSchemaFixtureDbMeta = db.AttachSchema(); + _fixtureDbMeta = newSchemaFixtureDbMeta; // Add teardown callback - OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbId)); + OnFixtureTearDown(() => db.Detach(newSchemaFixtureDbMeta)); } // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings if (!databaseFactory.Configured) { - databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer); + databaseFactory.Configure(_fixtureDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer); } // re-run the runtime level check @@ -382,16 +377,17 @@ namespace Umbraco.Tests.Integration.Testing if (FirstTestInFixture) { // New DB + Schema - var newEmptyFixtureDbId = db.AttachEmpty(); + var newEmptyFixtureDbMeta = db.AttachEmpty(); + _fixtureDbMeta = newEmptyFixtureDbMeta; // Add teardown callback - OnFixtureTearDown(() => db.Detach(newEmptyFixtureDbId)); + OnFixtureTearDown(() => db.Detach(newEmptyFixtureDbMeta)); } // We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings if (!databaseFactory.Configured) { - databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer); + databaseFactory.Configure(_fixtureDbMeta.ConnectionString, Constants.DatabaseProviders.SqlServer); } break; @@ -412,8 +408,6 @@ namespace Umbraco.Tests.Integration.Testing public TestHelper TestHelper = new TestHelper(); - protected virtual string TestDBConnectionString { get; private set; } - protected virtual Action CustomTestSetup => services => { }; /// diff --git a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs similarity index 97% rename from src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs index 474528a8ec..ac502ddf80 100644 --- a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Migrations/AdvancedMigrationTests.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Microsoft.Extensions.Logging; +using Umbraco.Core.Configuration; using Umbraco.Core.Migrations; using Umbraco.Core.Migrations.Install; using Umbraco.Core.Migrations.Upgrade; @@ -12,6 +13,7 @@ using Umbraco.Core.Persistence.DatabaseModelDefinitions; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Services; using Umbraco.Tests.Common.Builders; +using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; @@ -19,10 +21,12 @@ namespace Umbraco.Tests.Migrations { [TestFixture] [UmbracoTest(Database = UmbracoTestOptions.Database.NewEmptyPerTest)] - public class AdvancedMigrationTests : TestWithDatabaseBase + public class AdvancedMigrationTests : UmbracoIntegrationTest { private ILoggerFactory _loggerFactory = NullLoggerFactory.Instance; + private IUmbracoVersion UmbracoVersion => GetRequiredService(); + [Test] public void CreateTableOfTDto() { diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs index ebfcd3e7de..c94b708ff9 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/DataTypeDefinitionRepositoryTest.cs @@ -3,11 +3,11 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Persistence.Repositories; -using Umbraco.Tests.Testing; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Tests.Integration.Testing; +using Umbraco.Tests.Testing; using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories @@ -23,15 +23,16 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor private IDataTypeContainerRepository DataTypeContainerRepository => GetRequiredService(); private IDataTypeRepository DataTypeRepository => GetRequiredService(); private IConfigurationEditorJsonSerializer ConfigurationEditorJsonSerializer => GetRequiredService(); + private IJsonSerializer JsonSerializer => GetRequiredService(); [Test] public void Can_Find_Usages() { using (ScopeProvider.CreateScope()) { - IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "dt1" }; + IDataType dataType1 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "dt1" }; DataTypeRepository.Save(dataType1); - IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "dt2" }; + IDataType dataType2 = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "dt2" }; DataTypeRepository.Save(dataType2); IContentType ct = new ContentType(ShortStringHelper, -1) @@ -94,14 +95,14 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor var container2 = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah2", ParentId = container1.Id }; DataTypeContainerRepository.Save(container2); - var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, container2.Id) + var dataType = (IDataType) new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, container2.Id) { Name = "dt1" }; DataTypeRepository.Save(dataType); //create a - var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, dataType.Id) + var dataType2 = (IDataType)new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, dataType.Id) { Name = "dt2" }; @@ -160,7 +161,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" }; DataTypeContainerRepository.Save(container); - var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; + var dataTypeDefinition = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; DataTypeRepository.Save(dataTypeDefinition); Assert.AreEqual(container.Id, dataTypeDefinition.ParentId); @@ -175,7 +176,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor var container = new EntityContainer(Constants.ObjectTypes.DataType) { Name = "blah" }; DataTypeContainerRepository.Save(container); - IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; + IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer, container.Id) { Name = "test" }; DataTypeRepository.Save(dataType); // Act @@ -195,7 +196,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper), ConfigurationEditorJsonSerializer) {Name = "test"}; + IDataType dataType = new DataType(new RadioButtonsPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) {Name = "test"}; DataTypeRepository.Save(dataType); @@ -295,7 +296,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) + var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { DatabaseType = ValueStorageType.Integer, Name = "AgeDataType", @@ -330,7 +331,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - var dataTypeDefinition = new DataType(new IntegerPropertyEditor(LoggerFactory, DataTypeService, LocalizationService, ShortStringHelper, LocalizedTextService), ConfigurationEditorJsonSerializer) + var dataTypeDefinition = new DataType(new IntegerPropertyEditor(LoggerFactory, DataTypeService, LocalizationService, ShortStringHelper, LocalizedTextService, JsonSerializer), ConfigurationEditorJsonSerializer) { DatabaseType = ValueStorageType.Integer, Name = "AgeDataType", @@ -341,7 +342,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor // Act var definition = DataTypeRepository.Get(dataTypeDefinition.Id); definition.Name = "AgeDataType Updated"; - definition.Editor = new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper); //change + definition.Editor = new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer); //change DataTypeRepository.Save(definition); var definitionUpdated = DataTypeRepository.Get(dataTypeDefinition.Id); @@ -358,7 +359,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor { using (ScopeProvider.CreateScope()) { - var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService,LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) + var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService,LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { DatabaseType = ValueStorageType.Integer, Name = "AgeDataType", diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs index 1ae46faa76..ffda46ed0d 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/PartialViewRepositoryTests.cs @@ -7,6 +7,7 @@ using Umbraco.Core.Models; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Tests.Testing; using System; +using System.IO; using Umbraco.Core.Hosting; using Umbraco.Tests.Integration.Testing; @@ -55,28 +56,28 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor partialView = new PartialView(PartialViewType.PartialView, "path-2/test-path-2.cshtml") { Content = "// partialView" }; repository.Save(partialView); Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.cshtml")); - Assert.AreEqual("path-2\\test-path-2.cshtml", partialView.Path); // fixed in 7.3 - 7.2.8 does not update the path + Assert.AreEqual("path-2\\test-path-2.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path); // fixed in 7.3 - 7.2.8 does not update the path Assert.AreEqual("/Views/Partials/path-2/test-path-2.cshtml", partialView.VirtualPath); partialView = (PartialView) repository.Get("path-2/test-path-2.cshtml"); Assert.IsNotNull(partialView); - Assert.AreEqual("path-2\\test-path-2.cshtml", partialView.Path); + Assert.AreEqual("path-2\\test-path-2.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path); Assert.AreEqual("/Views/Partials/path-2/test-path-2.cshtml", partialView.VirtualPath); partialView = new PartialView(PartialViewType.PartialView, "path-2\\test-path-3.cshtml") { Content = "// partialView" }; repository.Save(partialView); Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.cshtml")); - Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path); + Assert.AreEqual("path-2\\test-path-3.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path); Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath); partialView = (PartialView) repository.Get("path-2/test-path-3.cshtml"); Assert.IsNotNull(partialView); - Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path); + Assert.AreEqual("path-2\\test-path-3.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path); Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath); partialView = (PartialView) repository.Get("path-2\\test-path-3.cshtml"); Assert.IsNotNull(partialView); - Assert.AreEqual("path-2\\test-path-3.cshtml", partialView.Path); + Assert.AreEqual("path-2\\test-path-3.cshtml".Replace("\\", $"{Path.DirectorySeparatorChar}"), partialView.Path); Assert.AreEqual("/Views/Partials/path-2/test-path-3.cshtml", partialView.VirtualPath); partialView = new PartialView(PartialViewType.PartialView, "\\test-path-4.cshtml") { Content = "// partialView" }; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs index 9e4ae80ec6..f9084332b7 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/ScriptRepositoryTest.cs @@ -280,36 +280,36 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor repository.Save(script); Assert.IsTrue(_fileSystem.FileExists("scripts/path-2/test-path-2.js")); - Assert.AreEqual("scripts\\path-2\\test-path-2.js", script.Path); + Assert.AreEqual("scripts\\path-2\\test-path-2.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path); Assert.AreEqual("/scripts/scripts/path-2/test-path-2.js", script.VirtualPath); script = new Script("path-2/test-path-2.js") { Content = "// script" }; repository.Save(script); Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.js")); - Assert.AreEqual("path-2\\test-path-2.js", script.Path); // fixed in 7.3 - 7.2.8 does not update the path + Assert.AreEqual("path-2\\test-path-2.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path);// fixed in 7.3 - 7.2.8 does not update the path Assert.AreEqual("/scripts/path-2/test-path-2.js", script.VirtualPath); script = repository.Get("path-2/test-path-2.js"); Assert.IsNotNull(script); - Assert.AreEqual("path-2\\test-path-2.js", script.Path); + Assert.AreEqual("path-2\\test-path-2.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path); Assert.AreEqual("/scripts/path-2/test-path-2.js", script.VirtualPath); script = new Script("path-2\\test-path-3.js") { Content = "// script" }; repository.Save(script); Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.js")); - Assert.AreEqual("path-2\\test-path-3.js", script.Path); + Assert.AreEqual("path-2\\test-path-3.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path); Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath); script = repository.Get("path-2/test-path-3.js"); Assert.IsNotNull(script); - Assert.AreEqual("path-2\\test-path-3.js", script.Path); + Assert.AreEqual("path-2\\test-path-3.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path); Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath); script = repository.Get("path-2\\test-path-3.js"); Assert.IsNotNull(script); - Assert.AreEqual("path-2\\test-path-3.js", script.Path); + Assert.AreEqual("path-2\\test-path-3.js".Replace("\\", $"{Path.DirectorySeparatorChar}"), script.Path); Assert.AreEqual("/scripts/path-2/test-path-3.js", script.VirtualPath); script = new Script("\\test-path-4.js") { Content = "// script" }; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs index a576666e6e..b4b8316f83 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/Repositories/StylesheetRepositoryTest.cs @@ -135,7 +135,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor stylesheet = repository.Get(stylesheet.Name); //Assert - Assert.That(stylesheet.Content, Is.EqualTo("body { color:#000; } .bold {font-weight:bold;}\r\n\r\n/**umb_name:Test*/\r\np {\r\n\tfont-size:2em;\r\n}")); + Assert.That(stylesheet.Content, Is.EqualTo("body { color:#000; } .bold {font-weight:bold;}\r\n\r\n/**umb_name:Test*/\r\np {\r\n\tfont-size:2em;\r\n}".Replace("\r\n", Environment.NewLine))); Assert.AreEqual(1, stylesheet.Properties.Count()); } } @@ -281,29 +281,29 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor repository.Save(stylesheet); Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-2.css")); - Assert.AreEqual("path-2\\test-path-2.css", stylesheet.Path); // fixed in 7.3 - 7.2.8 does not update the path + Assert.AreEqual("path-2\\test-path-2.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path);// fixed in 7.3 - 7.2.8 does not update the path Assert.AreEqual("/css/path-2/test-path-2.css", stylesheet.VirtualPath); stylesheet = repository.Get("path-2/test-path-2.css"); Assert.IsNotNull(stylesheet); - Assert.AreEqual("path-2\\test-path-2.css", stylesheet.Path); + Assert.AreEqual("path-2\\test-path-2.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path); Assert.AreEqual("/css/path-2/test-path-2.css", stylesheet.VirtualPath); stylesheet = new Stylesheet("path-2\\test-path-3.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; repository.Save(stylesheet); Assert.IsTrue(_fileSystem.FileExists("path-2/test-path-3.css")); - Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path); + Assert.AreEqual("path-2\\test-path-3.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path); Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath); stylesheet = repository.Get("path-2/test-path-3.css"); Assert.IsNotNull(stylesheet); - Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path); + Assert.AreEqual("path-2\\test-path-3.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path); Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath); stylesheet = repository.Get("path-2\\test-path-3.css"); Assert.IsNotNull(stylesheet); - Assert.AreEqual("path-2\\test-path-3.css", stylesheet.Path); + Assert.AreEqual("path-2\\test-path-3.css".Replace("\\", $"{Path.DirectorySeparatorChar}"), stylesheet.Path); Assert.AreEqual("/css/path-2/test-path-3.css", stylesheet.VirtualPath); stylesheet = new Stylesheet("\\test-path-4.css") { Content = "body { color:#000; } .bold {font-weight:bold;}" }; diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs index 4dbc7b3efc..3c03be2a95 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/CachedDataTypeServiceTests.cs @@ -21,6 +21,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services private ILocalizedTextService LocalizedTextService => GetRequiredService(); private ILocalizationService LocalizationService => GetRequiredService(); private IConfigurationEditorJsonSerializer ConfigurationEditorJsonSerializer => GetRequiredService(); + private IJsonSerializer JsonSerializer => GetRequiredService(); /// /// This tests validates that with the new scope changes that the underlying cache policies work - in this case it tests that the cache policy @@ -29,7 +30,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services [Test] public void DataTypeService_Can_Get_All() { - IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; + IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; DataTypeService.Save(dataType); //Get all the first time (no cache) diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs index 0af3ae6fb5..2de7fb6b2a 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/DataTypeServiceTests.cs @@ -26,12 +26,13 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services private ILocalizedTextService LocalizedTextService => GetRequiredService(); private ILocalizationService LocalizationService => GetRequiredService(); private IConfigurationEditorJsonSerializer ConfigurationEditorJsonSerializer => GetRequiredService(); + private IJsonSerializer JsonSerializer => GetRequiredService(); [Test] public void DataTypeService_Can_Persist_New_DataTypeDefinition() { // Act - IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; + IDataType dataType = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService, LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = "Testing Textfield", DatabaseType = ValueStorageType.Ntext }; DataTypeService.Save(dataType); // Assert @@ -74,7 +75,7 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services public void Cannot_Save_DataType_With_Empty_Name() { // Act - var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService,LocalizationService, ShortStringHelper), ConfigurationEditorJsonSerializer) { Name = string.Empty, DatabaseType = ValueStorageType.Ntext }; + var dataTypeDefinition = new DataType(new LabelPropertyEditor(LoggerFactory, IOHelper, DataTypeService, LocalizedTextService,LocalizationService, ShortStringHelper, JsonSerializer), ConfigurationEditorJsonSerializer) { Name = string.Empty, DatabaseType = ValueStorageType.Ntext }; // Act & Assert Assert.Throws(() => DataTypeService.Save(dataTypeDefinition)); diff --git a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx index 5823fa1245..fdf7880297 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/Importing/ImportResources.resx @@ -119,6 +119,6 @@ - dictionary-package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + Dictionary-Package.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - \ No newline at end of file + diff --git a/src/Umbraco.Tests/Services/RedirectUrlServiceTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RedirectUrlServiceTests.cs similarity index 55% rename from src/Umbraco.Tests/Services/RedirectUrlServiceTests.cs rename to src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RedirectUrlServiceTests.cs index 8f38bd67eb..89cde051e3 100644 --- a/src/Umbraco.Tests/Services/RedirectUrlServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/RedirectUrlServiceTests.cs @@ -1,81 +1,72 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading; using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; using Umbraco.Core.Models; - -using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.Repositories.Implement; using Umbraco.Core.Scoping; +using Umbraco.Core.Services; +using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Services +namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services { [TestFixture] [Apartment(ApartmentState.STA)] [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] - public class RedirectUrlServiceTests : TestWithSomeContentBase + public class RedirectUrlServiceTests : UmbracoIntegrationTestWithContent { private IContent _testPage; private IContent _altTestPage; - private string _url = "blah"; - private string _cultureA = "en"; - private string _cultureB = "de"; + private const string Url = "blah"; + private const string CultureA = "en"; + private const string CultureB = "de"; + + private IRedirectUrlService RedirectUrlService => GetRequiredService(); + public override void CreateTestData() { base.CreateTestData(); - using (var scope = ScopeProvider.CreateScope()) + using (IScope scope = ScopeProvider.CreateScope()) { var repository = new RedirectUrlRepository((IScopeAccessor)ScopeProvider, AppCaches.Disabled, Mock.Of>()); - var rootContent = ServiceContext.ContentService.GetRootContent().FirstOrDefault(); - var subPages = ServiceContext.ContentService.GetPagedChildren(rootContent.Id, 0, 2, out _).ToList(); + IContent rootContent = ContentService.GetRootContent().First(); + var subPages = ContentService.GetPagedChildren(rootContent.Id, 0, 2, out _).ToList(); _testPage = subPages[0]; _altTestPage = subPages[1]; repository.Save(new RedirectUrl { ContentKey = _testPage.Key, - Url = _url, - Culture = _cultureA + Url = Url, + Culture = CultureA }); repository.Save(new RedirectUrl { ContentKey = _altTestPage.Key, - Url = _url, - Culture = _cultureB + Url = Url, + Culture = CultureB }); scope.Complete(); } } - [TearDown] - public override void TearDown() - { - base.TearDown(); - } [Test] public void Can_Get_Most_Recent_RedirectUrl() { - var redirectUrlService = ServiceContext.RedirectUrlService; - var redirect = redirectUrlService.GetMostRecentRedirectUrl(_url); + IRedirectUrl redirect = RedirectUrlService.GetMostRecentRedirectUrl(Url); Assert.AreEqual(redirect.ContentId, _altTestPage.Id); - } [Test] public void Can_Get_Most_Recent_RedirectUrl_With_Culture() { - var redirectUrlService = ServiceContext.RedirectUrlService; - var redirect = redirectUrlService.GetMostRecentRedirectUrl(_url, _cultureA); + IRedirectUrl redirect = RedirectUrlService.GetMostRecentRedirectUrl(Url, CultureA); Assert.AreEqual(redirect.ContentId, _testPage.Id); - } - } } diff --git a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj index c5b42f9848..b996205712 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj +++ b/src/Umbraco.Tests.Integration/Umbraco.Tests.Integration.csproj @@ -7,6 +7,10 @@ 8 + + IS_WINDOWS + + diff --git a/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs index 2960455a70..dc88455d68 100644 --- a/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs +++ b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Filters/ContentModelValidatorTests.cs @@ -13,7 +13,6 @@ using Umbraco.Core.IO; using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; @@ -273,8 +272,8 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Filters public class ComplexTestEditor : NestedContentPropertyEditor { public ComplexTestEditor(ILoggerFactory loggerFactory, Lazy propertyEditors, IDataTypeService dataTypeService, IContentTypeService contentTypeService, ILocalizationService localizationService, - IIOHelper ioHelper, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper) - : base(loggerFactory, propertyEditors, dataTypeService, localizationService, contentTypeService, ioHelper, shortStringHelper, localizedTextService) + IIOHelper ioHelper, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer) + : base(loggerFactory, propertyEditors, dataTypeService, localizationService, contentTypeService, ioHelper, shortStringHelper, localizedTextService, jsonSerializer) { } @@ -290,17 +289,19 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Filters [DataEditor("test", "test", "test")] // This alias aligns with the prop editor alias for all properties created from MockedContentTypes.CreateTextPageContentType public class TestEditor : DataEditor { - public TestEditor(ILoggerFactory loggerFactory, - IDataTypeService dataTypeService, - ILocalizationService localizationService, - ILocalizedTextService localizedTextService, - IShortStringHelper shortStringHelper) - : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper) + public TestEditor( + ILoggerFactory loggerFactory, + IDataTypeService dataTypeService, + ILocalizationService localizationService, + ILocalizedTextService localizedTextService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(loggerFactory, dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer) { } - protected override IDataValueEditor CreateValueEditor() => new TestValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, Attribute); + protected override IDataValueEditor CreateValueEditor() => new TestValueEditor(DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, JsonSerializer, Attribute); private class TestValueEditor : DataValueEditor { @@ -309,8 +310,9 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Filters ILocalizationService localizationService, ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer, DataEditorAttribute attribute) - : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, attribute) + : base(dataTypeService, localizationService, localizedTextService, shortStringHelper, jsonSerializer, attribute) { Validators.Add(new NeverValidateValidator()); } diff --git a/src/Umbraco.Tests/Cache/DefaultCachePolicyTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/DefaultCachePolicyTests.cs similarity index 91% rename from src/Umbraco.Tests/Cache/DefaultCachePolicyTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/DefaultCachePolicyTests.cs index 74aba2b824..a8592356e9 100644 --- a/src/Umbraco.Tests/Cache/DefaultCachePolicyTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/DefaultCachePolicyTests.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -using System.Web.Caching; using Moq; using NUnit.Framework; using Umbraco.Core.Cache; using Umbraco.Core.Models; using Umbraco.Core.Scoping; -namespace Umbraco.Tests.Cache +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache { [TestFixture] public class DefaultCachePolicyTests @@ -37,7 +36,7 @@ namespace Umbraco.Tests.Cache var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions()); - var unused = defaultPolicy.Get(1, id => new AuditItem(1, AuditType.Copy, 123, "test", "blah"), o => null); + AuditItem unused = defaultPolicy.Get(1, id => new AuditItem(1, AuditType.Copy, 123, "test", "blah"), o => null); Assert.IsTrue(isCached); } @@ -49,7 +48,7 @@ namespace Umbraco.Tests.Cache var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions()); - var found = defaultPolicy.Get(1, id => null, ids => null); + AuditItem found = defaultPolicy.Get(1, id => null, ids => null); Assert.IsNotNull(found); } @@ -67,7 +66,7 @@ namespace Umbraco.Tests.Cache var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions()); - var unused = defaultPolicy.GetAll(new object[] {}, ids => new[] + AuditItem[] unused = defaultPolicy.GetAll(new object[] {}, ids => new[] { new AuditItem(1, AuditType.Copy, 123, "test", "blah"), new AuditItem(2, AuditType.Copy, 123, "test", "blah2") @@ -88,7 +87,7 @@ namespace Umbraco.Tests.Cache var defaultPolicy = new DefaultRepositoryCachePolicy(cache.Object, DefaultAccessor, new RepositoryCachePolicyOptions()); - var found = defaultPolicy.GetAll(new object[] {}, ids => new[] { (AuditItem)null }); + AuditItem[] found = defaultPolicy.GetAll(new object[] {}, ids => new[] { (AuditItem)null }); Assert.AreEqual(2, found.Length); } diff --git a/src/Umbraco.Tests/Cache/FullDataSetCachePolicyTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/FullDataSetCachePolicyTests.cs similarity index 99% rename from src/Umbraco.Tests/Cache/FullDataSetCachePolicyTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/FullDataSetCachePolicyTests.cs index 027f6d2d69..e904f9104e 100644 --- a/src/Umbraco.Tests/Cache/FullDataSetCachePolicyTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/FullDataSetCachePolicyTests.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Web.Caching; using Moq; using NUnit.Framework; using Umbraco.Core.Cache; @@ -10,7 +9,7 @@ using Umbraco.Core.Collections; using Umbraco.Core.Models; using Umbraco.Core.Scoping; -namespace Umbraco.Tests.Cache +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache { [TestFixture] public class FullDataSetCachePolicyTests diff --git a/src/Umbraco.Tests/Cache/RefresherTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/RefresherTests.cs similarity index 98% rename from src/Umbraco.Tests/Cache/RefresherTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/RefresherTests.cs index eb8580c9e2..59d2f010d2 100644 --- a/src/Umbraco.Tests/Cache/RefresherTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/RefresherTests.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using Umbraco.Core.Services.Changes; using Umbraco.Web.Cache; -namespace Umbraco.Tests.Cache +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache { [TestFixture] public class RefreshersTests diff --git a/src/Umbraco.Tests/Cache/SingleItemsOnlyCachePolicyTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/SingleItemsOnlyCachePolicyTests.cs similarity index 97% rename from src/Umbraco.Tests/Cache/SingleItemsOnlyCachePolicyTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/SingleItemsOnlyCachePolicyTests.cs index 335335e391..323b83699c 100644 --- a/src/Umbraco.Tests/Cache/SingleItemsOnlyCachePolicyTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Cache/SingleItemsOnlyCachePolicyTests.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -using System.Web.Caching; using Moq; using NUnit.Framework; using Umbraco.Core.Cache; using Umbraco.Core.Models; using Umbraco.Core.Scoping; -namespace Umbraco.Tests.Cache +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Cache { [TestFixture] public class SingleItemsOnlyCachePolicyTests diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs index 3bc29c9a9d..7b876af85d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs @@ -67,7 +67,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components private static TypeLoader MockTypeLoader() { var ioHelper = IOHelper; - return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), Mock.Of()); + return new TypeLoader(Mock.Of(), Mock.Of(), new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), Mock.Of()); } @@ -389,7 +389,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components public void AllComposers() { var typeFinder = TestHelper.GetTypeFinder(); - var typeLoader = new TypeLoader(typeFinder, AppCaches.Disabled.RuntimeCache, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), Mock.Of()); + var typeLoader = new TypeLoader(typeFinder, AppCaches.Disabled.RuntimeCache, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), Mock.Of()); var register = MockRegister(); var builder = new UmbracoBuilder(register, Mock.Of(), TestHelper.GetMockedTypeLoader()); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs index 43760d1c6c..1c8bf139ac 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/ComposingTestBase.cs @@ -1,9 +1,10 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Reflection; using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; +using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Logging; @@ -23,7 +24,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing ProfilingLogger = new ProfilingLogger(Mock.Of>(), Mock.Of()); var typeFinder = TestHelper.GetTypeFinder(); - TypeLoader = new TypeLoader(typeFinder, NoAppCache.Instance, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), Mock.Of>(), ProfilingLogger, false, AssembliesToScan); + TypeLoader = new TypeLoader(typeFinder, NoAppCache.Instance, new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), ProfilingLogger, false, AssembliesToScan); } protected virtual IEnumerable AssembliesToScan diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs index 20e9f8feef..36843ad1cc 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/TypeLoaderTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -28,7 +28,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing // this ensures it's reset var typeFinder = TestHelper.GetTypeFinder(); _typeLoader = new TypeLoader(typeFinder, NoAppCache.Instance, - new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot("~/App_Data/TEMP")), + new DirectoryInfo(TestHelper.GetHostingEnvironment().MapPathContentRoot(Constants.SystemDirectories.TempData)), Mock.Of>(), new ProfilingLogger(Mock.Of>(), Mock.Of()), false, // for testing, we'll specify which assemblies are scanned for the PluginTypeResolver diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs index 5bc14b3792..d3e2ca3014 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Configuration/Models/Extensions/HealthCheckSettingsExtensionsTests.cs @@ -4,8 +4,8 @@ using System; using NUnit.Framework; using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Extensions; using Umbraco.Core.Configuration.Models; -using Umbraco.Infrastructure.Configuration.Extensions; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Configuration.Models.Extensions { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs index 81c868656e..cab26fd7d2 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Models/VariationTests.cs @@ -585,6 +585,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Models var localizedTextService = Mock.Of(); var localizationService = Mock.Of(); var shortStringHelper = Mock.Of(); + var jsonSerializer = Mock.Of(); var textBoxEditor = new TextboxPropertyEditor( NullLoggerFactory.Instance, @@ -592,7 +593,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Models localizationService, ioHelper, shortStringHelper, - localizedTextService + localizedTextService, + jsonSerializer ); var serializer = new ConfigurationEditorJsonSerializer(); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs index 14aa628f88..98820ccac9 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorListValidatorTest.cs @@ -2,13 +2,12 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using NUnit.Framework; using Newtonsoft.Json.Linq; +using NUnit.Framework; using Umbraco.Core.IO; -using NUnit.Framework.Internal; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors @@ -22,7 +21,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray() { var validator = new ColorPickerConfigurationEditor.ColorListValidator(); - var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -30,7 +29,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray_Of_Item_JObject() { var validator = new ColorPickerConfigurationEditor.ColorListValidator(); - var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -43,7 +42,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors JObject.FromObject(new { value = "zxcvzxcvxzcv" }), JObject.FromObject(new { value = "ABC" }), JObject.FromObject(new { value = "1234567" })), - null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(2, result.Count()); } } diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ConvertersTests.cs similarity index 62% rename from src/Umbraco.Tests/Published/ConvertersTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ConvertersTests.cs index 840ec58f13..f41a950c27 100644 --- a/src/Umbraco.Tests/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ConvertersTests.cs @@ -14,9 +14,9 @@ using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.PublishedContent; +using Umbraco.Tests.Common.PublishedContent; using Umbraco.Tests.TestHelpers; -using Umbraco.Web; +using Umbraco.Tests.UnitTests.TestHelpers; using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.Published @@ -24,13 +24,10 @@ namespace Umbraco.Tests.Published [TestFixture] public class ConvertersTests { - #region SimpleConverter3 - [Test] public void SimpleConverter3Test() { - // Current.Reset(); - var register = TestHelper.GetRegister(); + var register = new ServiceCollection(); var composition = new UmbracoBuilder(register, Mock.Of(), TestHelper.GetMockedTypeLoader()); @@ -38,37 +35,41 @@ namespace Umbraco.Tests.Published .Append() .Append(); - IPublishedModelFactory factory = new PublishedModelFactory(new[] - { - typeof (PublishedSnapshotTestObjects.TestElementModel1), typeof (PublishedSnapshotTestObjects.TestElementModel2), - typeof (PublishedSnapshotTestObjects.TestContentModel1), typeof (PublishedSnapshotTestObjects.TestContentModel2), - }, Mock.Of()); + IPublishedModelFactory factory = new PublishedModelFactory( + new[] + { + typeof(PublishedSnapshotTestObjects.TestElementModel1), + typeof(PublishedSnapshotTestObjects.TestElementModel2), + typeof(PublishedSnapshotTestObjects.TestContentModel1), + typeof(PublishedSnapshotTestObjects.TestContentModel2) + }, Mock.Of()); register.AddTransient(f => factory); - var cacheMock = new Mock(); var cacheContent = new Dictionary(); - cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null); + cacheMock.Setup(x => x.GetById(It.IsAny())).Returns(id => + cacheContent.TryGetValue(id, out IPublishedContent content) ? content : null); var publishedSnapshotMock = new Mock(); publishedSnapshotMock.Setup(x => x.Content).Returns(cacheMock.Object); var publishedSnapshotAccessorMock = new Mock(); publishedSnapshotAccessorMock.Setup(x => x.PublishedSnapshot).Returns(publishedSnapshotMock.Object); register.AddTransient(f => publishedSnapshotAccessorMock.Object); - var registerFactory = composition.CreateServiceProvider(); - var converters = registerFactory.GetRequiredService(); + IServiceProvider registerFactory = composition.CreateServiceProvider(); + PropertyValueConverterCollection converters = + registerFactory.GetRequiredService(); var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType1 = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) - { Id = 1 }; + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), + serializer) { Id = 1 }; var dataType2 = new DataType(new VoidEditor("2", NullLoggerFactory.Instance, Mock.Of(), - Mock.Of(), Mock.Of(), Mock.Of()), serializer) - { Id = 2 }; + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), + serializer) { Id = 2 }; - dataTypeServiceMock.Setup(x => x.GetAll()).Returns(new []{dataType1, dataType2 }); + dataTypeServiceMock.Setup(x => x.GetAll()).Returns(new[] { dataType1, dataType2 }); var contentTypeFactory = new PublishedContentTypeFactory(factory, converters, dataTypeServiceMock.Object); @@ -77,52 +78,69 @@ namespace Umbraco.Tests.Published yield return contentTypeFactory.CreatePropertyType(contentType, "prop" + i, i); } - var elementType1 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1000, "element1", t => CreatePropertyTypes(t, 1)); - var elementType2 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1001, "element2", t => CreatePropertyTypes(t, 2)); - var contentType1 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1002, "content1", t => CreatePropertyTypes(t, 1)); - var contentType2 = contentTypeFactory.CreateContentType(Guid.NewGuid(), 1003, "content2", t => CreatePropertyTypes(t, 2)); + IPublishedContentType elementType1 = + contentTypeFactory.CreateContentType(Guid.NewGuid(), 1000, "element1", t => CreatePropertyTypes(t, 1)); + IPublishedContentType elementType2 = + contentTypeFactory.CreateContentType(Guid.NewGuid(), 1001, "element2", t => CreatePropertyTypes(t, 2)); + IPublishedContentType contentType1 = + contentTypeFactory.CreateContentType(Guid.NewGuid(), 1002, "content1", t => CreatePropertyTypes(t, 1)); + IPublishedContentType contentType2 = + contentTypeFactory.CreateContentType(Guid.NewGuid(), 1003, "content2", t => CreatePropertyTypes(t, 2)); - var element1 = new PublishedElement(elementType1, Guid.NewGuid(), new Dictionary { { "prop1", "val1" } }, false); - var element2 = new PublishedElement(elementType2, Guid.NewGuid(), new Dictionary { { "prop2", "1003" } }, false); + var element1 = new PublishedElement(elementType1, Guid.NewGuid(), + new Dictionary { { "prop1", "val1" } }, false); + var element2 = new PublishedElement(elementType2, Guid.NewGuid(), + new Dictionary { { "prop2", "1003" } }, false); var cnt1 = new SolidPublishedContent(contentType1) { Id = 1003, - Properties = new[] { new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = "val1" } } + Properties = new[] + { + new SolidPublishedProperty { Alias = "prop1", SolidHasValue = true, SolidValue = "val1" } + } }; var cnt2 = new SolidPublishedContent(contentType1) { Id = 1004, - Properties = new[] { new SolidPublishedProperty { Alias = "prop2", SolidHasValue = true, SolidValue = "1003" } } + Properties = new[] + { + new SolidPublishedProperty { Alias = "prop2", SolidHasValue = true, SolidValue = "1003" } + } }; - var publishedModelFactory = registerFactory.GetRequiredService(); + IPublishedModelFactory publishedModelFactory = registerFactory.GetRequiredService(); cacheContent[cnt1.Id] = cnt1.CreateModel(publishedModelFactory); cacheContent[cnt2.Id] = cnt2.CreateModel(publishedModelFactory); // can get the actual property Clr type // ie ModelType gets properly mapped by IPublishedContentModelFactory // must test ModelClrType with special equals 'cos they are not ref-equals - Assert.IsTrue(ModelType.Equals(typeof(IEnumerable<>).MakeGenericType(ModelType.For("content1")), contentType2.GetPropertyType("prop2").ModelClrType)); - Assert.AreEqual(typeof(IEnumerable), contentType2.GetPropertyType("prop2").ClrType); + Assert.IsTrue(ModelType.Equals(typeof(IEnumerable<>).MakeGenericType(ModelType.For("content1")), + contentType2.GetPropertyType("prop2").ModelClrType)); + Assert.AreEqual(typeof(IEnumerable), + contentType2.GetPropertyType("prop2").ClrType); // can create a model for an element - var model1 = factory.CreateModel(element1); + IPublishedElement model1 = factory.CreateModel(element1); Assert.IsInstanceOf(model1); Assert.AreEqual("val1", ((PublishedSnapshotTestObjects.TestElementModel1)model1).Prop1); // can create a model for a published content - var model2 = factory.CreateModel(element2); + IPublishedElement model2 = factory.CreateModel(element2); Assert.IsInstanceOf(model2); var mmodel2 = (PublishedSnapshotTestObjects.TestElementModel2)model2; // and get direct property - Assert.IsInstanceOf(model2.Value(Mock.Of(), "prop2")); - Assert.AreEqual(1, ((PublishedSnapshotTestObjects.TestContentModel1[])model2.Value(Mock.Of(), "prop2")).Length); + Assert.IsInstanceOf( + model2.Value(Mock.Of(), "prop2")); + Assert.AreEqual(1, + ((PublishedSnapshotTestObjects.TestContentModel1[])model2.Value(Mock.Of(), + "prop2")).Length); // and get model property Assert.IsInstanceOf>(mmodel2.Prop2); Assert.IsInstanceOf(mmodel2.Prop2); - var mmodel1 = mmodel2.Prop2.First(); + PublishedSnapshotTestObjects.TestContentModel1 mmodel1 = mmodel2.Prop2.First(); // and we get what we want Assert.AreSame(cacheContent[mmodel1.Id], mmodel1); @@ -144,10 +162,8 @@ namespace Umbraco.Tests.Published { private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; - public SimpleConverter3B(IPublishedSnapshotAccessor publishedSnapshotAccessor) - { + public SimpleConverter3B(IPublishedSnapshotAccessor publishedSnapshotAccessor) => _publishedSnapshotAccessor = publishedSnapshotAccessor; - } public override bool IsConverter(IPublishedPropertyType propertyType) => propertyType.EditorAlias == "Umbraco.Void.2"; @@ -158,18 +174,18 @@ namespace Umbraco.Tests.Published public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType) => PropertyCacheLevel.Elements; - public override object ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object source, bool preview) + public override object ConvertSourceToIntermediate(IPublishedElement owner, + IPublishedPropertyType propertyType, object source, bool preview) { var s = source as string; return s?.Split(',').Select(int.Parse).ToArray() ?? Array.Empty(); } - public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview) - { - return ((int[])inter).Select(x => (PublishedSnapshotTestObjects.TestContentModel1)_publishedSnapshotAccessor.PublishedSnapshot.Content.GetById(x)).ToArray(); - } + public override object ConvertIntermediateToObject(IPublishedElement owner, + IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, + bool preview) => ((int[])inter).Select(x => + (PublishedSnapshotTestObjects.TestContentModel1)_publishedSnapshotAccessor.PublishedSnapshot.Content + .GetById(x)).ToArray(); } - - #endregion } } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs index 0fa864ae06..3229c3652c 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/DataValueReferenceFactoryCollectionTests.cs @@ -1,21 +1,19 @@ -using Moq; -using NUnit.Framework; -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.Editors; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.PropertyEditors; using static Umbraco.Core.Models.Property; -using Umbraco.Core.Serialization; namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors { @@ -27,6 +25,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors ILocalizedTextService LocalizedTextService { get; } = Mock.Of(); ILocalizationService LocalizationService { get; } = Mock.Of(); IShortStringHelper ShortStringHelper { get; } = Mock.Of(); + IJsonSerializer JsonSerializer { get; } = new JsonNetSerializer(); [Test] public void GetAllReferences_All_Variants_With_IDataValueReferenceFactory() @@ -41,7 +40,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors DataTypeService, LocalizedTextService, LocalizationService, - ShortStringHelper + ShortStringHelper, + JsonSerializer ); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(labelEditor.Yield())); var trackedUdi1 = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString(); @@ -110,7 +110,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors LocalizationService, IOHelper, ShortStringHelper, - LocalizedTextService + LocalizedTextService, + JsonSerializer ); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(mediaPicker.Yield())); var trackedUdi1 = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString(); @@ -179,7 +180,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors LocalizationService, IOHelper, ShortStringHelper, - LocalizedTextService + LocalizedTextService, + JsonSerializer ); var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(mediaPicker.Yield())); var trackedUdi1 = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString(); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs index 44c53382d9..2b81620b27 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/EnsureUniqueValuesValidatorTest.cs @@ -2,13 +2,12 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; -using NUnit.Framework; using Newtonsoft.Json.Linq; +using NUnit.Framework; using Umbraco.Core.IO; -using Umbraco.Core.Logging; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; using Umbraco.Web.PropertyEditors; namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors @@ -21,7 +20,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray() { var validator = new ValueListUniqueValueValidator(); - var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate("hello", null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -29,7 +28,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Only_Tests_On_JArray_Of_Item_JObject() { var validator = new ValueListUniqueValueValidator(); - var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate(new JArray("hello", "world"), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -37,7 +36,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void Allows_Unique_Values() { var validator = new ValueListUniqueValueValidator(); - var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" })), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" })), null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(0, result.Count()); } @@ -46,7 +45,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors { var validator = new ValueListUniqueValueValidator(); var result = validator.Validate(new JArray(JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "hello" })), - null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(1, result.Count()); } @@ -59,7 +58,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors JObject.FromObject(new { value = "hello" }), JObject.FromObject(new { value = "world" }), JObject.FromObject(new { value = "world" })), - null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of())); + null, new ColorPickerPropertyEditor(_loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer())); Assert.AreEqual(2, result.Count()); } } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs index 5b3e3f1ff6..2952ac032d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/MultiValuePropertyEditorTests.cs @@ -5,7 +5,6 @@ using Moq; using Newtonsoft.Json; using NUnit.Framework; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; @@ -30,7 +29,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void DropDownMultipleValueEditor_Format_Data_For_Cache() { var serializer = new ConfigurationEditorJsonSerializer(); - var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Configuration = new ValueListConfiguration { @@ -63,7 +62,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.PropertyEditors public void DropDownValueEditor_Format_Data_For_Cache() { var serializer = new ConfigurationEditorJsonSerializer(); - var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType = new DataType(new CheckBoxListPropertyEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Configuration = new ValueListConfiguration { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs index a46662c3a1..13c4ae071c 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/ConvertersTests.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -33,7 +32,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(Mock.Of(), dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); @@ -117,7 +116,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(Mock.Of(), dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs index 67c294f5a9..7493d59d72 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/NestedContentTests.cs @@ -34,7 +34,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published var localizationService = Mock.Of(); PropertyEditorCollection editors = null; - var editor = new NestedContentPropertyEditor(loggerFactory, new Lazy(() => editors), Mock.Of(),localizationService, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()); + var editor = new NestedContentPropertyEditor(loggerFactory, new Lazy(() => editors), Mock.Of(),localizationService, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()); editors = new PropertyEditorCollection(new DataEditorCollection(new DataEditor[] { editor })); var serializer = new ConfigurationEditorJsonSerializer(); @@ -67,7 +67,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published } }; - var dataType3 = new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType3 = new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 3 }; diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs index b412ab1153..163020b6f6 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Published/PropertyCacheLevelTests.cs @@ -5,7 +5,6 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -32,10 +31,11 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published converter, }); - var serializer = new ConfigurationEditorJsonSerializer(); + var configurationEditorJsonSerializer = new ConfigurationEditorJsonSerializer(); + var jsonSerializer = new JsonNetSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), jsonSerializer), configurationEditorJsonSerializer) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); @@ -118,10 +118,9 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published converter, }); - var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), new ConfigurationEditorJsonSerializer()) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); @@ -199,10 +198,16 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Published converter, }); - var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); - var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + var dataType = new DataType( + new VoidEditor( + NullLoggerFactory.Instance, + dataTypeServiceMock.Object, + Mock.Of(), + Mock.Of(), + Mock.Of(), + new JsonNetSerializer()), + new ConfigurationEditorJsonSerializer()) { Id = 1 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests/Migrations/AlterMigrationTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/AlterMigrationTests.cs similarity index 61% rename from src/Umbraco.Tests/Migrations/AlterMigrationTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/AlterMigrationTests.cs index 2d8dd7d18e..23ee3e143a 100644 --- a/src/Umbraco.Tests/Migrations/AlterMigrationTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/AlterMigrationTests.cs @@ -1,39 +1,20 @@ using System; using System.Diagnostics; -using System.Data.Common; using System.Linq; using Microsoft.Extensions.Logging; using Moq; -using NPoco; using NUnit.Framework; -using Umbraco.Core; using Umbraco.Core.Migrations; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.SqlSyntax; -using Umbraco.Persistance.SqlCe; using Umbraco.Tests.Migrations.Stubs; -using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Migrations +namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Migrations { [TestFixture] public class AlterMigrationTests { - private ILogger _logger; - private ISqlSyntaxProvider _sqlSyntax; - private IUmbracoDatabase _database; + private readonly ILogger _logger = Mock.Of>(); - [SetUp] - public void Setup() - { - _logger = Mock.Of>(); - _sqlSyntax = new SqlCeSyntaxProvider(); - - var dbProviderFactory = DbProviderFactories.GetFactory(Constants.DbProviderNames.SqlServer); - var sqlContext = new SqlContext(_sqlSyntax, DatabaseType.SqlServer2008, Mock.Of()); - _database = new UmbracoDatabase("cstr", sqlContext, dbProviderFactory, Mock.Of>(), TestHelper.BulkSqlInsertProvider); - } [Test] public void Drop_Foreign_Key() @@ -46,13 +27,15 @@ namespace Umbraco.Tests.Migrations // Act stub.Migrate(); - foreach (var op in database.Operations) + foreach (TestDatabase.Operation op in database.Operations) + { Console.WriteLine("{0}\r\n\t{1}", op.Text, op.Sql); + } // Assert Assert.That(database.Operations.Count, Is.EqualTo(1)); - Assert.That(database.Operations[0].Sql, Is.EqualTo("ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoUser_id]")); - + Assert.That(database.Operations[0].Sql, + Is.EqualTo("ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoUser_id]")); } [Test] @@ -64,23 +47,24 @@ namespace Umbraco.Tests.Migrations migration.Migrate(); - foreach (var op in database.Operations) + foreach (TestDatabase.Operation op in database.Operations) + { Console.WriteLine("{0}\r\n\t{1}", op.Text, op.Sql); + } Assert.That(database.Operations.Count, Is.EqualTo(1)); - Assert.That(database.Operations[0].Sql, Is.EqualTo("ALTER TABLE [bar] ADD [foo] UniqueIdentifier NOT NULL")); + Assert.That(database.Operations[0].Sql, + Is.EqualTo("ALTER TABLE [bar] ADD [foo] UniqueIdentifier NOT NULL")); } public class CreateColumnMigration : MigrationBase { public CreateColumnMigration(IMigrationContext context) : base(context) - { } - - public override void Migrate() { - Alter.Table("bar").AddColumn("foo").AsGuid().Do(); } + + public override void Migrate() => Alter.Table("bar").AddColumn("foo").AsGuid().Do(); } [Test] @@ -92,28 +76,30 @@ namespace Umbraco.Tests.Migrations migration.Migrate(); - foreach (var op in database.Operations) + foreach (TestDatabase.Operation op in database.Operations) + { Console.WriteLine("{0}\r\n\t{1}", op.Text, op.Sql); + } Assert.That(database.Operations.Count, Is.EqualTo(1)); - Assert.That(database.Operations[0].Sql, Is.EqualTo("ALTER TABLE [bar] ALTER COLUMN [foo] UniqueIdentifier NOT NULL")); + Assert.That(database.Operations[0].Sql, + Is.EqualTo("ALTER TABLE [bar] ALTER COLUMN [foo] UniqueIdentifier NOT NULL")); } public class AlterColumnMigration : MigrationBase { public AlterColumnMigration(IMigrationContext context) : base(context) - { } - - public override void Migrate() { + } + + public override void Migrate() => // bad/good syntax... //Alter.Column("foo").OnTable("bar").AsGuid().NotNullable(); Alter.Table("bar").AlterColumn("foo").AsGuid().NotNullable().Do(); - } } - [NUnit.Framework.Ignore("this doesn't actually test anything")] + [Ignore("this doesn't actually test anything")] [Test] public void Can_Get_Up_Migration_From_MigrationStub() { @@ -131,7 +117,7 @@ namespace Umbraco.Tests.Migrations //Console output Debug.Print("Number of expressions in context: {0}", database.Operations.Count); Debug.Print(""); - foreach (var expression in database.Operations) + foreach (TestDatabase.Operation expression in database.Operations) { Debug.Print(expression.ToString()); } diff --git a/src/Umbraco.Tests/Migrations/MigrationPlanTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationPlanTests.cs similarity index 83% rename from src/Umbraco.Tests/Migrations/MigrationPlanTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationPlanTests.cs index 0a8c6cfb3f..0511ee6290 100644 --- a/src/Umbraco.Tests/Migrations/MigrationPlanTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationPlanTests.cs @@ -10,14 +10,13 @@ using Umbraco.Core; using Umbraco.Core.Migrations; using Umbraco.Core.Migrations.Upgrade; using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Scoping; using Umbraco.Core.Services; -using Umbraco.Persistance.SqlCe; -using Umbraco.Tests.Common.Builders; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Migrations +namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Migrations { [TestFixture] public class MigrationPlanTests @@ -25,18 +24,19 @@ namespace Umbraco.Tests.Migrations [Test] public void CanExecute() { - var loggerFactory = NullLoggerFactory.Instance; + NullLoggerFactory loggerFactory = NullLoggerFactory.Instance; var database = new TestDatabase(); - var scope = Mock.Of(); + IScope scope = Mock.Of(); Mock.Get(scope) .Setup(x => x.Database) .Returns(database); - var sqlContext = new SqlContext(new SqlCeSyntaxProvider(), DatabaseType.SQLCe, Mock.Of()); + var sqlContext = new SqlContext(new SqlServerSyntaxProvider(), DatabaseType.SQLCe, + Mock.Of()); var scopeProvider = new MigrationTests.TestScopeProvider(scope) { SqlContext = sqlContext }; - var migrationBuilder = Mock.Of(); + IMigrationBuilder migrationBuilder = Mock.Of(); Mock.Get(migrationBuilder) .Setup(x => x.Build(It.IsAny(), It.IsAny())) .Returns((t, c) => @@ -52,22 +52,24 @@ namespace Umbraco.Tests.Migrations } }); - var plan = new MigrationPlan("default") + MigrationPlan plan = new MigrationPlan("default") .From(string.Empty) .To("{4A9A1A8F-0DA1-4BCF-AD06-C19D79152E35}") .To("VERSION.33"); - var kvs = Mock.Of(); - Mock.Get(kvs).Setup(x => x.GetValue(It.IsAny())).Returns(k => k == "Umbraco.Tests.MigrationPlan" ? string.Empty : null); + IKeyValueService kvs = Mock.Of(); + Mock.Get(kvs).Setup(x => x.GetValue(It.IsAny())) + .Returns(k => k == "Umbraco.Tests.MigrationPlan" ? string.Empty : null); string state; - using (var s = scopeProvider.CreateScope()) + using (IScope s = scopeProvider.CreateScope()) { // read current state var sourceState = kvs.GetValue("Umbraco.Tests.MigrationPlan") ?? string.Empty; // execute plan - state = plan.Execute(s, sourceState, migrationBuilder, loggerFactory.CreateLogger(), loggerFactory); + state = plan.Execute(s, sourceState, migrationBuilder, loggerFactory.CreateLogger(), + loggerFactory); // save new state kvs.SetValue("Umbraco.Tests.MigrationPlan", sourceState, state); @@ -178,11 +180,11 @@ namespace Umbraco.Tests.Migrations .From(string.Empty) .To("aaa") .Merge() - .To("bbb") - .To("ccc") + .To("bbb") + .To("ccc") .With() - .To("ddd") - .To("eee") + .To("ddd") + .To("eee") .As("fff") .To("ggg"); @@ -198,8 +200,12 @@ namespace Umbraco.Tests.Migrations { Assert.AreEqual(expected.Length, states.Count, string.Join(", ", states)); for (var i = 0; i < expected.Length; i++) + { if (expected[i] != "*") + { Assert.AreEqual(expected[i], states[i], "at:" + i); + } + } } private void WritePlanToConsole(MigrationPlan plan) @@ -207,21 +213,23 @@ namespace Umbraco.Tests.Migrations var final = plan.Transitions.First(x => x.Value == null).Key; Console.WriteLine("plan \"{0}\" to final state \"{1}\":", plan.Name, final); - foreach (var (_, transition) in plan.Transitions) + foreach ((var _, MigrationPlan.Transition transition) in plan.Transitions) + { if (transition != null) + { Console.WriteLine(transition); + } + } } public class DeleteRedirectUrlTable : MigrationBase { public DeleteRedirectUrlTable(IMigrationContext context) : base(context) - { } - - public override void Migrate() { - Delete.Table("umbracoRedirectUrl").Do(); } + + public override void Migrate() => Delete.Table("umbracoRedirectUrl").Do(); } } } diff --git a/src/Umbraco.Tests/Migrations/MigrationTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationTests.cs similarity index 55% rename from src/Umbraco.Tests/Migrations/MigrationTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationTests.cs index 46d9b04b1b..34093d0bce 100644 --- a/src/Umbraco.Tests/Migrations/MigrationTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/MigrationTests.cs @@ -1,18 +1,14 @@ using System; -using System.Collections.Generic; using System.Data; using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; -using Semver; using Umbraco.Core.Events; using Umbraco.Core.Migrations; -using Umbraco.Core.Migrations.Upgrade; using Umbraco.Core.Persistence; using Umbraco.Core.Scoping; -using Umbraco.Core.Services; -namespace Umbraco.Tests.Migrations +namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Migrations { [TestFixture] public class MigrationTests @@ -21,35 +17,30 @@ namespace Umbraco.Tests.Migrations { private readonly IScope _scope; - public TestScopeProvider(IScope scope) - { - _scope = scope; - } + public TestScopeProvider(IScope scope) => _scope = scope; - public IScope CreateScope(IsolationLevel isolationLevel = IsolationLevel.Unspecified, RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified, IEventDispatcher eventDispatcher = null, bool? scopeFileSystems = null, bool callContext = false, bool autoComplete = false) - { - return _scope; - } + public IScope CreateScope( + IsolationLevel isolationLevel = IsolationLevel.Unspecified, + RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified, + IEventDispatcher eventDispatcher = null, + bool? scopeFileSystems = null, + bool callContext = false, + bool autoComplete = false) => _scope; - public IScope CreateDetachedScope(IsolationLevel isolationLevel = IsolationLevel.Unspecified, RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified, IEventDispatcher eventDispatcher = null, bool? scopeFileSystems = null) - { - throw new NotImplementedException(); - } + public IScope CreateDetachedScope( + IsolationLevel isolationLevel = IsolationLevel.Unspecified, + RepositoryCacheMode repositoryCacheMode = RepositoryCacheMode.Unspecified, + IEventDispatcher eventDispatcher = null, + bool? scopeFileSystems = null) => throw new NotImplementedException(); - public void AttachScope(IScope scope, bool callContext = false) - { - throw new NotImplementedException(); - } - - public IScope DetachScope() - { - throw new NotImplementedException(); - } + public void AttachScope(IScope scope, bool callContext = false) => throw new NotImplementedException(); + public IScope DetachScope() => throw new NotImplementedException(); public IScopeContext Context { get; set; } - public ISqlContext SqlContext { get; set; } + + public ISqlContext SqlContext { get; set; } #if DEBUG_SCOPES public ScopeInfo GetScopeInfo(IScope scope) @@ -63,7 +54,8 @@ namespace Umbraco.Tests.Migrations [Test] public void RunGoodMigration() { - var migrationContext = new MigrationContext(Mock.Of(), Mock.Of>()); + var migrationContext = + new MigrationContext(Mock.Of(), Mock.Of>()); IMigration migration = new GoodMigration(migrationContext); migration.Migrate(); } @@ -71,7 +63,8 @@ namespace Umbraco.Tests.Migrations [Test] public void DetectBadMigration1() { - var migrationContext = new MigrationContext(Mock.Of(), Mock.Of>()); + var migrationContext = + new MigrationContext(Mock.Of(), Mock.Of>()); IMigration migration = new BadMigration1(migrationContext); Assert.Throws(() => migration.Migrate()); } @@ -79,7 +72,8 @@ namespace Umbraco.Tests.Migrations [Test] public void DetectBadMigration2() { - var migrationContext = new MigrationContext(Mock.Of(), Mock.Of>()); + var migrationContext = + new MigrationContext(Mock.Of(), Mock.Of>()); IMigration migration = new BadMigration2(migrationContext); Assert.Throws(() => migration.Migrate()); } @@ -88,31 +82,28 @@ namespace Umbraco.Tests.Migrations { public GoodMigration(IMigrationContext context) : base(context) - { } - - public override void Migrate() { - Execute.Sql("").Do(); } + + public override void Migrate() => Execute.Sql("").Do(); } public class BadMigration1 : MigrationBase { public BadMigration1(IMigrationContext context) : base(context) - { } - - public override void Migrate() { - Alter.Table("foo"); // stop here, don't Do it } + + public override void Migrate() => Alter.Table("foo"); // stop here, don't Do it } public class BadMigration2 : MigrationBase { public BadMigration2(IMigrationContext context) : base(context) - { } + { + } public override void Migrate() { diff --git a/src/Umbraco.Tests/Migrations/PostMigrationTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/PostMigrationTests.cs similarity index 71% rename from src/Umbraco.Tests/Migrations/PostMigrationTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/PostMigrationTests.cs index ba265b3fd2..2b3e626d03 100644 --- a/src/Umbraco.Tests/Migrations/PostMigrationTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/PostMigrationTests.cs @@ -1,6 +1,6 @@ using System; -using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; using Moq; using NPoco; using NUnit.Framework; @@ -10,19 +10,19 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Core.Scoping; using Umbraco.Core.Services; -using Umbraco.Persistance.SqlCe; using Umbraco.Tests.Testing; -namespace Umbraco.Tests.Migrations +namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Migrations { [TestFixture] public class PostMigrationTests { - private static ILoggerFactory _loggerFactory = NullLoggerFactory.Instance; + private static readonly ILoggerFactory s_loggerFactory = NullLoggerFactory.Instance; + [Test] public void ExecutesPlanPostMigration() { - var builder = Mock.Of(); + IMigrationBuilder builder = Mock.Of(); Mock.Get(builder) .Setup(x => x.Build(It.IsAny(), It.IsAny())) .Returns((t, c) => @@ -39,22 +39,30 @@ namespace Umbraco.Tests.Migrations }); var database = new TestDatabase(); - var scope = Mock.Of(); + IScope scope = Mock.Of(); Mock.Get(scope) .Setup(x => x.Database) .Returns(database); - var sqlContext = new SqlContext(new SqlCeSyntaxProvider(), DatabaseType.SQLCe, Mock.Of()); + var sqlContext = new SqlContext( + new SqlServerSyntaxProvider(), + DatabaseType.SQLCe, + Mock.Of()); var scopeProvider = new MigrationTests.TestScopeProvider(scope) { SqlContext = sqlContext }; - var plan = new MigrationPlan("Test") + MigrationPlan plan = new MigrationPlan("Test") .From(string.Empty).To("done"); plan.AddPostMigration(); TestPostMigration.MigrateCount = 0; var upgrader = new Upgrader(plan); - upgrader.Execute(scopeProvider, builder, Mock.Of(), _loggerFactory.CreateLogger(), _loggerFactory); + upgrader.Execute( + scopeProvider, + builder, + Mock.Of(), + s_loggerFactory.CreateLogger(), + s_loggerFactory); Assert.AreEqual(1, TestPostMigration.MigrateCount); } @@ -62,7 +70,7 @@ namespace Umbraco.Tests.Migrations [Test] public void MigrationCanAddPostMigration() { - var builder = Mock.Of(); + IMigrationBuilder builder = Mock.Of(); Mock.Get(builder) .Setup(x => x.Build(It.IsAny(), It.IsAny())) .Returns((t, c) => @@ -81,24 +89,32 @@ namespace Umbraco.Tests.Migrations }); var database = new TestDatabase(); - var scope = Mock.Of(); + IScope scope = Mock.Of(); Mock.Get(scope) .Setup(x => x.Database) .Returns(database); - var sqlContext = new SqlContext(new SqlCeSyntaxProvider(), DatabaseType.SQLCe, Mock.Of()); + var sqlContext = new SqlContext( + new SqlServerSyntaxProvider(), + DatabaseType.SQLCe, + Mock.Of()); var scopeProvider = new MigrationTests.TestScopeProvider(scope) { SqlContext = sqlContext }; - var plan = new MigrationPlan("Test") + MigrationPlan plan = new MigrationPlan("Test") .From(string.Empty).To("done"); TestMigration.MigrateCount = 0; TestPostMigration.MigrateCount = 0; - new MigrationContext(database, _loggerFactory.CreateLogger()); + new MigrationContext(database, s_loggerFactory.CreateLogger()); var upgrader = new Upgrader(plan); - upgrader.Execute(scopeProvider, builder, Mock.Of(), _loggerFactory.CreateLogger(), _loggerFactory); + upgrader.Execute( + scopeProvider, + builder, + Mock.Of(), + s_loggerFactory.CreateLogger(), + s_loggerFactory); Assert.AreEqual(1, TestMigration.MigrateCount); Assert.AreEqual(1, TestPostMigration.MigrateCount); @@ -108,7 +124,8 @@ namespace Umbraco.Tests.Migrations { public TestMigration(IMigrationContext context) : base(context) - { } + { + } public static int MigrateCount { get; set; } @@ -124,10 +141,7 @@ namespace Umbraco.Tests.Migrations { public static int MigrateCount { get; set; } - public void Migrate() - { - MigrateCount++; - } + public void Migrate() => MigrateCount++; } } } diff --git a/src/Umbraco.Tests/Migrations/Stubs/AlterUserTableMigrationStub.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/AlterUserTableMigrationStub.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/AlterUserTableMigrationStub.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/AlterUserTableMigrationStub.cs diff --git a/src/Umbraco.Tests/Migrations/Stubs/DropForeignKeyMigrationStub.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/DropForeignKeyMigrationStub.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/DropForeignKeyMigrationStub.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/DropForeignKeyMigrationStub.cs diff --git a/src/Umbraco.Tests/Migrations/Stubs/Dummy.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/Dummy.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/Dummy.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/Dummy.cs diff --git a/src/Umbraco.Tests/Migrations/Stubs/FiveZeroMigration.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/FiveZeroMigration.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/FiveZeroMigration.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/FiveZeroMigration.cs diff --git a/src/Umbraco.Tests/Migrations/Stubs/FourElevenMigration.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/FourElevenMigration.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/FourElevenMigration.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/FourElevenMigration.cs diff --git a/src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration1.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/SixZeroMigration1.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration1.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/SixZeroMigration1.cs diff --git a/src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration2.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/SixZeroMigration2.cs similarity index 100% rename from src/Umbraco.Tests/Migrations/Stubs/SixZeroMigration2.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Migrations/Stubs/SixZeroMigration2.cs diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs index 436c202398..5d90d85f81 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Persistence/Querying/ExpressionTests.cs @@ -1,21 +1,21 @@ using System; using System.Diagnostics; +using System.Linq; using System.Linq.Expressions; +using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; using Umbraco.Core.Persistence; +using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.Persistence.Querying; using Umbraco.Core.Persistence.SqlSyntax; -using Umbraco.Tests.TestHelpers; -using System.Linq; -using Microsoft.Extensions.Logging.Abstractions; -using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; +using Umbraco.Tests.TestHelpers; namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.Querying { @@ -25,8 +25,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Persistence.Querying [Test] public void Equals_Claus_With_Two_Entity_Values() { - var serializer = new ConfigurationEditorJsonSerializer(); - var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of()), serializer) + + var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of(), new JsonNetSerializer()), new ConfigurationEditorJsonSerializer()) { Id = 12345 }; diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs index 3acfce1781..abc1bb0c9d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/Services/PropertyValidationServiceTests.cs @@ -5,6 +5,7 @@ using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.Validators; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Web.PropertyEditors; @@ -34,7 +35,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Services x => x.Type == EditorType.PropertyValue && x.Alias == Constants.PropertyEditors.Aliases.TextBox); Mock.Get(dataEditor).Setup(x => x.GetValueEditor(It.IsAny())) - .Returns(new CustomTextOnlyValueEditor(Mock.Of(), Mock.Of(), new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"), textService.Object, Mock.Of())); + .Returns(new CustomTextOnlyValueEditor(Mock.Of(), Mock.Of(), new DataEditorAttribute(Constants.PropertyEditors.Aliases.TextBox, "Test Textbox", "textbox"), textService.Object, Mock.Of(), new JsonNetSerializer())); var propEditors = new PropertyEditorCollection(new DataEditorCollection(new[] { dataEditor })); @@ -166,7 +167,14 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Infrastructure.Services { private readonly ILocalizedTextService _textService; - public CustomTextOnlyValueEditor(IDataTypeService dataTypeService, ILocalizationService localizationService, DataEditorAttribute attribute, ILocalizedTextService textService, IShortStringHelper shortStringHelper) : base(dataTypeService, localizationService, attribute, textService, shortStringHelper) + public CustomTextOnlyValueEditor( + IDataTypeService dataTypeService, + ILocalizationService localizationService, + DataEditorAttribute attribute, + ILocalizedTextService textService, + IShortStringHelper shortStringHelper, + IJsonSerializer jsonSerializer) + : base(dataTypeService, localizationService, attribute, textService, shortStringHelper, jsonSerializer) { _textService = textService; } diff --git a/src/Umbraco.Tests/Cache/SnapDictionaryTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.PublishedCache.NuCache/SnapDictionaryTests.cs similarity index 99% rename from src/Umbraco.Tests/Cache/SnapDictionaryTests.cs rename to src/Umbraco.Tests.UnitTests/Umbraco.PublishedCache.NuCache/SnapDictionaryTests.cs index 739268b451..91317848c6 100644 --- a/src/Umbraco.Tests/Cache/SnapDictionaryTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.PublishedCache.NuCache/SnapDictionaryTests.cs @@ -1,4 +1,5 @@ -using System; + +using System; using System.Linq; using System.Threading.Tasks; using Moq; @@ -6,7 +7,7 @@ using NUnit.Framework; using Umbraco.Core.Scoping; using Umbraco.Web.PublishedCache.NuCache; -namespace Umbraco.Tests.Cache +namespace Umbraco.Tests.UnitTests.Umbraco.Umbraco.PublishedCache { [TestFixture] public class SnapDictionaryTests diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj b/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj index 76764d0483..1e774f4b00 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Tests.UnitTests.csproj @@ -8,6 +8,7 @@ + diff --git a/src/Umbraco.Tests/Migrations/SqlScripts/SqlCe-SchemaAndData-4110.sql b/src/Umbraco.Tests/Migrations/SqlScripts/SqlCe-SchemaAndData-4110.sql deleted file mode 100644 index 4aeb066f54..0000000000 Binary files a/src/Umbraco.Tests/Migrations/SqlScripts/SqlCe-SchemaAndData-4110.sql and /dev/null differ diff --git a/src/Umbraco.Tests/Migrations/SqlScripts/SqlCeTotal-480.sql b/src/Umbraco.Tests/Migrations/SqlScripts/SqlCeTotal-480.sql deleted file mode 100644 index f814b7fc2d..0000000000 --- a/src/Umbraco.Tests/Migrations/SqlScripts/SqlCeTotal-480.sql +++ /dev/null @@ -1,638 +0,0 @@ -CREATE TABLE [umbracoRelation] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[parentId] [int] NOT NULL, -[childId] [int] NOT NULL, -[relType] [int] NOT NULL, -[datetime] [datetime] NOT NULL CONSTRAINT [DF_umbracoRelation_datetime] DEFAULT (getdate()), -[comment] [nvarchar] (1000) NOT NULL -) - -; -ALTER TABLE [umbracoRelation] ADD CONSTRAINT [PK_umbracoRelation] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsDocument] -( -[nodeId] [int] NOT NULL, -[published] [bit] NOT NULL, -[documentUser] [int] NOT NULL, -[versionId] [uniqueidentifier] NOT NULL, -[text] [nvarchar] (255) NOT NULL, -[releaseDate] [datetime] NULL, -[expireDate] [datetime] NULL, -[updateDate] [datetime] NOT NULL CONSTRAINT [DF_cmsDocument_updateDate] DEFAULT (getdate()), -[templateId] [int] NULL, -[alias] [nvarchar] (255) NULL , -[newest] [bit] NOT NULL CONSTRAINT [DF_cmsDocument_newest] DEFAULT (0) -) - -; -ALTER TABLE [cmsDocument] ADD CONSTRAINT [PK_cmsDocument] PRIMARY KEY ([versionId]) -; -CREATE TABLE [umbracoLog] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[userId] [int] NOT NULL, -[NodeId] [int] NOT NULL, -[Datestamp] [datetime] NOT NULL CONSTRAINT [DF_umbracoLog_Datestamp] DEFAULT (getdate()), -[logHeader] [nvarchar] (50) NOT NULL, -[logComment] [nvarchar] (1000) NULL -) - -; -ALTER TABLE [umbracoLog] ADD CONSTRAINT [PK_umbracoLog] PRIMARY KEY ([id]) -; - -CREATE TABLE [umbracoApp] -( -[sortOrder] [tinyint] NOT NULL CONSTRAINT [DF_app_sortOrder] DEFAULT (0), -[appAlias] [nvarchar] (50) NOT NULL, -[appIcon] [nvarchar] (255) NOT NULL, -[appName] [nvarchar] (255) NOT NULL, -[appInitWithTreeAlias] [nvarchar] (255) NULL -) - -; -ALTER TABLE [umbracoApp] ADD CONSTRAINT [PK_umbracoApp] PRIMARY KEY ([appAlias]) -; -CREATE TABLE [cmsPropertyData] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[contentNodeId] [int] NOT NULL, -[versionId] [uniqueidentifier] NULL, -[propertytypeid] [int] NOT NULL, -[dataInt] [int] NULL, -[dataDate] [datetime] NULL, -[dataNvarchar] [nvarchar] (500) NULL, -[dataNtext] [ntext] NULL -) - -; -ALTER TABLE [cmsPropertyData] ADD CONSTRAINT [PK_cmsPropertyData] PRIMARY KEY ([id]) -; -CREATE INDEX [IX_cmsPropertyData] ON [cmsPropertyData] ([id]) -; -CREATE TABLE [cmsContent] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[contentType] [int] NOT NULL -) - -; -ALTER TABLE [cmsContent] ADD CONSTRAINT [PK_cmsContent] PRIMARY KEY ([pk]) -; -CREATE TABLE [cmsContentType] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[alias] [nvarchar] (255) NULL, -[icon] [nvarchar] (255) NULL -) - -; -ALTER TABLE [cmsContentType] ADD CONSTRAINT [PK_cmsContentType] PRIMARY KEY ([pk]) -; -CREATE TABLE [cmsMacroPropertyType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[macroPropertyTypeAlias] [nvarchar] (50) NULL, -[macroPropertyTypeRenderAssembly] [nvarchar] (255) NULL, -[macroPropertyTypeRenderType] [nvarchar] (255) NULL, -[macroPropertyTypeBaseType] [nvarchar] (255) NULL -) - -; -ALTER TABLE [cmsMacroPropertyType] ADD CONSTRAINT [PK_macroPropertyType] PRIMARY KEY ([id]) -; - - -CREATE TABLE [cmsTab] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[contenttypeNodeId] [int] NOT NULL, -[text] [nvarchar] (255) NOT NULL, -[sortorder] [int] NOT NULL -) - -; -ALTER TABLE [cmsTab] ADD CONSTRAINT [PK_cmsTab] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsTemplate] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[master] [int] NULL, -[alias] [nvarchar] (100) NULL, -[design] [ntext] NOT NULL -) - -; -ALTER TABLE [cmsTemplate] ADD CONSTRAINT [PK_templates] PRIMARY KEY ([pk]) -; -CREATE TABLE [umbracoUser2app] -( -[user] [int] NOT NULL, -[app] [nvarchar] (50) NOT NULL -) - -; -ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [PK_user2app] PRIMARY KEY ([user], [app]) -; -CREATE TABLE [umbracoUserType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[userTypeAlias] [nvarchar] (50) NULL, -[userTypeName] [nvarchar] (255) NOT NULL, -[userTypeDefaultPermissions] [nvarchar] (50) NULL -) - -; -ALTER TABLE [umbracoUserType] ADD CONSTRAINT [PK_userType] PRIMARY KEY ([id]) -; -CREATE TABLE [umbracoUser] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[userDisabled] [bit] NOT NULL CONSTRAINT [DF_umbracoUser_userDisabled] DEFAULT (0), -[userNoConsole] [bit] NOT NULL CONSTRAINT [DF_umbracoUser_userNoConsole] DEFAULT (0), -[userType] [int] NOT NULL, -[startStructureID] [int] NOT NULL, -[startMediaID] [int] NULL, -[userName] [nvarchar] (255) NOT NULL, -[userLogin] [nvarchar] (125) NOT NULL, -[userPassword] [nvarchar] (125) NOT NULL, -[userEmail] [nvarchar] (255) NOT NULL, -[userDefaultPermissions] [nvarchar] (50) NULL, -[userLanguage] [nvarchar] (10) NULL -) - -; -ALTER TABLE [umbracoUser] ADD CONSTRAINT [PK_user] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsDocumentType] -( -[contentTypeNodeId] [int] NOT NULL, -[templateNodeId] [int] NOT NULL, -[IsDefault] [bit] NOT NULL CONSTRAINT [DF_cmsDocumentType_IsDefault] DEFAULT (0) -) - -; -ALTER TABLE [cmsDocumentType] ADD CONSTRAINT [PK_cmsDocumentType] PRIMARY KEY ([contentTypeNodeId], [templateNodeId]) -; -CREATE TABLE [cmsMemberType] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[NodeId] [int] NOT NULL, -[propertytypeId] [int] NOT NULL, -[memberCanEdit] [bit] NOT NULL CONSTRAINT [DF_cmsMemberType_memberCanEdit] DEFAULT (0), -[viewOnProfile] [bit] NOT NULL CONSTRAINT [DF_cmsMemberType_viewOnProfile] DEFAULT (0) -) - -; -ALTER TABLE [cmsMemberType] ADD CONSTRAINT [PK_cmsMemberType] PRIMARY KEY ([pk]) -; -CREATE TABLE [cmsMember] -( -[nodeId] [int] NOT NULL, -[Email] [nvarchar] (1000) NOT NULL CONSTRAINT [DF_cmsMember_Email] DEFAULT (''), -[LoginName] [nvarchar] (1000) NOT NULL CONSTRAINT [DF_cmsMember_LoginName] DEFAULT (''), -[Password] [nvarchar] (1000) NOT NULL CONSTRAINT [DF_cmsMember_Password] DEFAULT ('') -) - -; -CREATE TABLE [umbracoNode] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[trashed] [bit] NOT NULL CONSTRAINT [DF_umbracoNode_trashed] DEFAULT (0), -[parentID] [int] NOT NULL, -[nodeUser] [int] NULL, -[level] [int] NOT NULL, -[path] [nvarchar] (150) NOT NULL, -[sortOrder] [int] NOT NULL, -[uniqueID] [uniqueidentifier] NULL, -[text] [nvarchar] (255) NULL, -[nodeObjectType] [uniqueidentifier] NULL, -[createDate] [datetime] NOT NULL CONSTRAINT [DF_umbracoNode_createDate] DEFAULT (getdate()) -) - -; -ALTER TABLE [umbracoNode] ADD CONSTRAINT [PK_structure] PRIMARY KEY ([id]) -; -; -CREATE TABLE [cmsPropertyType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[dataTypeId] [int] NOT NULL, -[contentTypeId] [int] NOT NULL, -[tabId] [int] NULL, -[Alias] [nvarchar] (255) NOT NULL, -[Name] [nvarchar] (255) NULL, -[helpText] [nvarchar] (1000) NULL, -[sortOrder] [int] NOT NULL CONSTRAINT [DF__cmsProper__sortO__1EA48E88] DEFAULT (0), -[mandatory] [bit] NOT NULL CONSTRAINT [DF__cmsProper__manda__2180FB33] DEFAULT (0), -[validationRegExp] [nvarchar] (255) NULL, -[Description] [nvarchar] (2000) NULL -) - -; -ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [PK_cmsPropertyType] PRIMARY KEY ([id]) -; - -CREATE TABLE [cmsMacroProperty] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[macroPropertyHidden] [bit] NOT NULL CONSTRAINT [DF_macroProperty_macroPropertyHidden] DEFAULT (0), -[macroPropertyType] [int] NOT NULL, -[macro] [int] NOT NULL, -[macroPropertySortOrder] [tinyint] NOT NULL CONSTRAINT [DF_macroProperty_macroPropertySortOrder] DEFAULT (0), -[macroPropertyAlias] [nvarchar] (50) NOT NULL, -[macroPropertyName] [nvarchar] (255) NOT NULL -) - -; -ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [PK_macroProperty] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsMacro] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[macroUseInEditor] [bit] NOT NULL CONSTRAINT [DF_macro_macroUseInEditor] DEFAULT (0), -[macroRefreshRate] [int] NOT NULL CONSTRAINT [DF_macro_macroRefreshRate] DEFAULT (0), -[macroAlias] [nvarchar] (255) NOT NULL, -[macroName] [nvarchar] (255) NULL, -[macroScriptType] [nvarchar] (255) NULL, -[macroScriptAssembly] [nvarchar] (255) NULL, -[macroXSLT] [nvarchar] (255) NULL, -[macroCacheByPage] [bit] NOT NULL CONSTRAINT [DF_cmsMacro_macroCacheByPage] DEFAULT (1), -[macroCachePersonalized] [bit] NOT NULL CONSTRAINT [DF_cmsMacro_macroCachePersonalized] DEFAULT (0), -[macroDontRender] [bit] NOT NULL CONSTRAINT [DF_cmsMacro_macroDontRender] DEFAULT (0) -) - -; -ALTER TABLE [cmsMacro] ADD CONSTRAINT [PK_macro] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsContentVersion] -( -[id] [int] NOT NULL IDENTITY(1, 1) PRIMARY KEY, -[ContentId] [int] NOT NULL, -[VersionId] [uniqueidentifier] NOT NULL, -[VersionDate] [datetime] NOT NULL CONSTRAINT [DF_cmsContentVersion_VersionDate] DEFAULT (getdate()) -) - -; -CREATE TABLE [umbracoAppTree] -( -[treeSilent] [bit] NOT NULL CONSTRAINT [DF_umbracoAppTree_treeSilent] DEFAULT (0), -[treeInitialize] [bit] NOT NULL CONSTRAINT [DF_umbracoAppTree_treeInitialize] DEFAULT (1), -[treeSortOrder] [tinyint] NOT NULL, -[appAlias] [nvarchar] (50) NOT NULL, -[treeAlias] [nvarchar] (150) NOT NULL, -[treeTitle] [nvarchar] (255) NOT NULL, -[treeIconClosed] [nvarchar] (255) NOT NULL, -[treeIconOpen] [nvarchar] (255) NOT NULL, -[treeHandlerAssembly] [nvarchar] (255) NOT NULL, -[treeHandlerType] [nvarchar] (255) NOT NULL, -[action] [nvarchar] (255) NULL -) - -; -ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [PK_umbracoAppTree] PRIMARY KEY ([appAlias], [treeAlias]) -; - -CREATE TABLE [cmsContentTypeAllowedContentType] -( -[Id] [int] NOT NULL, -[AllowedId] [int] NOT NULL -) - -; -ALTER TABLE [cmsContentTypeAllowedContentType] ADD CONSTRAINT [PK_cmsContentTypeAllowedContentType] PRIMARY KEY ([Id], [AllowedId]) -; -CREATE TABLE [cmsContentXml] -( -[nodeId] [int] NOT NULL, -[xml] [ntext] NOT NULL -) - -; -ALTER TABLE [cmsContentXml] ADD CONSTRAINT [PK_cmsContentXml] PRIMARY KEY ([nodeId]) -; -CREATE TABLE [cmsDataType] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[controlId] [uniqueidentifier] NOT NULL, -[dbType] [nvarchar] (50) NOT NULL -) - -; -ALTER TABLE [cmsDataType] ADD CONSTRAINT [PK_cmsDataType] PRIMARY KEY ([pk]) -; -CREATE TABLE [cmsDataTypePreValues] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[datatypeNodeId] [int] NOT NULL, -[value] [nvarchar] (255) NULL, -[sortorder] [int] NOT NULL, -[alias] [nvarchar] (50) NULL -) - -; -ALTER TABLE [cmsDataTypePreValues] ADD CONSTRAINT [PK_cmsDataTypePreValues] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsDictionary] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[id] [uniqueidentifier] NOT NULL, -[parent] [uniqueidentifier] NOT NULL, -[key] [nvarchar] (1000) NOT NULL -) - -; -ALTER TABLE [cmsDictionary] ADD CONSTRAINT [PK_cmsDictionary] PRIMARY KEY ([pk]) -; -CREATE TABLE [cmsLanguageText] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[languageId] [int] NOT NULL, -[UniqueId] [uniqueidentifier] NOT NULL, -[value] [nvarchar] (1000) NOT NULL -) - -; -ALTER TABLE [cmsLanguageText] ADD CONSTRAINT [PK_cmsLanguageText] PRIMARY KEY ([pk]) -; -CREATE TABLE [cmsMember2MemberGroup] -( -[Member] [int] NOT NULL, -[MemberGroup] [int] NOT NULL -) - -; -ALTER TABLE [cmsMember2MemberGroup] ADD CONSTRAINT [PK_cmsMember2MemberGroup] PRIMARY KEY ([Member], [MemberGroup]) -; -CREATE TABLE [cmsStylesheet] -( -[nodeId] [int] NOT NULL, -[filename] [nvarchar] (100) NOT NULL, -[content] [ntext] NULL -) - -; -CREATE TABLE [cmsStylesheetProperty] -( -[nodeId] [int] NOT NULL, -[stylesheetPropertyEditor] [bit] NULL, -[stylesheetPropertyAlias] [nvarchar] (50) NULL, -[stylesheetPropertyValue] [nvarchar] (400) NULL -) - -; -CREATE TABLE [umbracoDomains] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[domainDefaultLanguage] [int] NULL, -[domainRootStructureID] [int] NULL, -[domainName] [nvarchar] (255) NOT NULL -) - -; -ALTER TABLE [umbracoDomains] ADD CONSTRAINT [PK_domains] PRIMARY KEY ([id]) -; -CREATE TABLE [umbracoLanguage] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[languageISOCode] [nvarchar] (10) NULL, -[languageCultureName] [nvarchar] (100) NULL -) - -; -ALTER TABLE [umbracoLanguage] ADD CONSTRAINT [PK_language] PRIMARY KEY ([id]) -; -CREATE TABLE [umbracoRelationType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[dual] [bit] NOT NULL, -[parentObjectType] [uniqueidentifier] NOT NULL, -[childObjectType] [uniqueidentifier] NOT NULL, -[name] [nvarchar] (255) NOT NULL, -[alias] [nvarchar] (100) NULL -) - -; -ALTER TABLE [umbracoRelationType] ADD CONSTRAINT [PK_umbracoRelationType] PRIMARY KEY ([id]) -; - - -CREATE TABLE [umbracoUser2NodeNotify] -( -[userId] [int] NOT NULL, -[nodeId] [int] NOT NULL, -[action] [nchar] (1) NOT NULL -) - -; -ALTER TABLE [umbracoUser2NodeNotify] ADD CONSTRAINT [PK_umbracoUser2NodeNotify] PRIMARY KEY ([userId], [nodeId], [action]) -; -CREATE TABLE [umbracoUser2NodePermission] -( -[userId] [int] NOT NULL, -[nodeId] [int] NOT NULL, -[permission] [nchar] (1) NOT NULL -) - -; -ALTER TABLE [umbracoUser2NodePermission] ADD CONSTRAINT [PK_umbracoUser2NodePermission] PRIMARY KEY ([userId], [nodeId], [permission]) -; - -ALTER TABLE [umbracoAppTree] ADD -CONSTRAINT [FK_umbracoAppTree_umbracoApp] FOREIGN KEY ([appAlias]) REFERENCES [umbracoApp] ([appAlias]) -; -ALTER TABLE [cmsPropertyData] ADD -CONSTRAINT [FK_cmsPropertyData_umbracoNode] FOREIGN KEY ([contentNodeId]) REFERENCES [umbracoNode] ([id]) -; - - -ALTER TABLE [cmsDocument] ADD -CONSTRAINT [FK_cmsDocument_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsMacroProperty] ADD -CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id]) -; -ALTER TABLE [umbracoUser] ADD -CONSTRAINT [FK_user_userType] FOREIGN KEY ([userType]) REFERENCES [umbracoUserType] ([id]) -; -ALTER TABLE [umbracoNode] ADD -CONSTRAINT [FK_umbracoNode_umbracoNode] FOREIGN KEY ([parentID]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsTemplate] ADD -CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsContentType] ADD -CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsPropertyType] ADD -CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) -; -ALTER TABLE [cmsContent] ADD -CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [umbracoUser2app] ADD -CONSTRAINT [FK_umbracoUser2app_umbracoApp] FOREIGN KEY ([app]) REFERENCES [umbracoApp] ([appAlias]), -CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]) -; - -ALTER TABLE [cmsTemplate] DROP CONSTRAINT [FK_cmsTemplate_umbracoNode] -; -ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab] -; -ALTER TABLE [cmsContent] DROP CONSTRAINT [FK_cmsContent_umbracoNode] -; -ALTER TABLE [cmsMacroProperty] DROP CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] -; -ALTER TABLE [umbracoAppTree] DROP CONSTRAINT [FK_umbracoAppTree_umbracoApp] -; -ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoApp] -; -ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoUser] -; -ALTER TABLE [cmsPropertyData] DROP CONSTRAINT [FK_cmsPropertyData_umbracoNode] -; - -ALTER TABLE [umbracoUser] DROP CONSTRAINT [FK_user_userType] -; -ALTER TABLE [cmsContentType] DROP CONSTRAINT [FK_cmsContentType_umbracoNode] -; -ALTER TABLE [cmsDocument] DROP CONSTRAINT [FK_cmsDocument_umbracoNode] -; -ALTER TABLE [umbracoNode] DROP CONSTRAINT [FK_umbracoNode_umbracoNode] -; - -ALTER TABLE [cmsTemplate] ADD CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) -; -ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id]) -; -ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [FK_umbracoAppTree_umbracoApp] FOREIGN KEY ([appAlias]) REFERENCES [umbracoApp] ([appAlias]) -; -ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [FK_umbracoUser2app_umbracoApp] FOREIGN KEY ([app]) REFERENCES [umbracoApp] ([appAlias]) -; -ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]) -; -ALTER TABLE [cmsPropertyData] ADD CONSTRAINT [FK_cmsPropertyData_umbracoNode] FOREIGN KEY ([contentNodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [umbracoUser] ADD CONSTRAINT [FK_user_userType] FOREIGN KEY ([userType]) REFERENCES [umbracoUserType] ([id]) -; -ALTER TABLE [cmsContentType] ADD CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsDocument] ADD CONSTRAINT [FK_cmsDocument_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [umbracoNode] ADD CONSTRAINT [FK_umbracoNode_umbracoNode] FOREIGN KEY ([parentID]) REFERENCES [umbracoNode] ([id]) -; - -ALTER TABLE cmsDataTypePreValues ALTER COLUMN value NVARCHAR(2500) NULL -; -CREATE TABLE [cmsTask] -( -[closed] [bit] NOT NULL CONSTRAINT [DF__cmsTask__closed__04E4BC85] DEFAULT ((0)), -[id] [int] NOT NULL IDENTITY(1, 1), -[taskTypeId] [int] NOT NULL, -[nodeId] [int] NOT NULL, -[parentUserId] [int] NOT NULL, -[userId] [int] NOT NULL, -[DateTime] [datetime] NOT NULL CONSTRAINT [DF__cmsTask__DateTim__05D8E0BE] DEFAULT (getdate()), -[Comment] [nvarchar] (500) NULL -) -; -ALTER TABLE [cmsTask] ADD CONSTRAINT [PK_cmsTask] PRIMARY KEY ([id]) -; -CREATE TABLE [cmsTaskType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[alias] [nvarchar] (255) NOT NULL -) -; -ALTER TABLE [cmsTaskType] ADD CONSTRAINT [PK_cmsTaskType] PRIMARY KEY ([id]) -; -ALTER TABLE [cmsTask] ADD -CONSTRAINT [FK_cmsTask_cmsTaskType] FOREIGN KEY ([taskTypeId]) REFERENCES [cmsTaskType] ([id]) -; -insert into cmsTaskType (alias) values ('toTranslate') -; - -update umbracoUserType set userTypeDefaultPermissions = userTypeDefaultPermissions + '5' where userTypeAlias in ('editor','admin') -; - -; -insert into umbracoRelationType (dual, parentObjectType, childObjectType, name, alias) values (1, 'c66ba18e-eaf3-4cff-8a22-41b16d66a972', 'c66ba18e-eaf3-4cff-8a22-41b16d66a972', 'Relate Document On Copy','relateDocumentOnCopy') -; -ALTER TABLE cmsMacro ADD macroPython nvarchar(255) -; - - -UPDATE umbracoUserType SET userTypeDefaultPermissions = userTypeDefaultPermissions + 'F' WHERE CHARINDEX('A',userTypeDefaultPermissions,0) >= 1 -AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1 -; - -UPDATE umbracoUserType SET userTypeDefaultPermissions = userTypeDefaultPermissions + 'H' WHERE userTypeAlias = 'writer' -AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1 -; - -INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission) -SELECT userID, nodeId, 'F' FROM umbracoUser2NodePermission WHERE permission='A' -; - -INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission) -SELECT DISTINCT userID, nodeId, 'H' FROM umbracoUser2NodePermission WHERE userId IN -(SELECT umbracoUser.id FROM umbracoUserType INNER JOIN umbracoUser ON umbracoUserType.id = umbracoUser.userType WHERE (umbracoUserType.userTypeAlias = 'writer')) -; - -alter TABLE [cmsContentType] -add [masterContentType] int NULL CONSTRAINT -[DF_cmsContentType_masterContentType] DEFAULT (0) -; -CREATE TABLE [cmsTagRelationship]( - [nodeId] [int] NOT NULL, - [tagId] [int] NOT NULL) -; - -CREATE TABLE [cmsTags]( - [id] [int] IDENTITY(1,1) NOT NULL, - [tag] [nvarchar](200) NULL, - [parentId] [int] NULL, - [group] [nvarchar](100) NULL) -; -alter TABLE [umbracoUser] -add [defaultToLiveEditing] bit NOT NULL CONSTRAINT -[DF_umbracoUser_defaultToLiveEditing] DEFAULT (0) -; - -CREATE TABLE [cmsPreviewXml]( - [nodeId] [int] NOT NULL, - [versionId] [uniqueidentifier] NOT NULL, - [timestamp] [datetime] NOT NULL, - [xml] [ntext] NOT NULL) -; - - -ALTER TABLE [umbracoNode] ALTER COLUMN id IDENTITY(1042,1) -; -ALTER TABLE [cmsContentType] ALTER COLUMN pk IDENTITY(535,1) -; -ALTER TABLE [umbracoUser] ALTER COLUMN id IDENTITY(1,1) -; -ALTER TABLE [umbracoUserType] ALTER COLUMN id IDENTITY(5,1) -; -ALTER TABLE [cmsMacroPropertyType] ALTER COLUMN id IDENTITY(26,1) -; -ALTER TABLE [cmsTab] ALTER COLUMN id IDENTITY(6,1) -; -ALTER TABLE [cmsPropertyType] ALTER COLUMN id IDENTITY(28,1) -; -ALTER TABLE [umbracoLanguage] ALTER COLUMN id IDENTITY(2,1) -; -ALTER TABLE [cmsDataType] ALTER COLUMN pk IDENTITY(39,1) -; -ALTER TABLE [cmsDataTypePreValues] ALTER COLUMN id IDENTITY(5,1) \ No newline at end of file diff --git a/src/Umbraco.Tests/Migrations/SqlScripts/SqlResources.Designer.cs b/src/Umbraco.Tests/Migrations/SqlScripts/SqlResources.Designer.cs deleted file mode 100644 index 7a7cee0ce3..0000000000 --- a/src/Umbraco.Tests/Migrations/SqlScripts/SqlResources.Designer.cs +++ /dev/null @@ -1,143 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Umbraco.Tests.Migrations.SqlScripts { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class SqlResources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal SqlResources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Tests.Migrations.SqlScripts.SqlResources", typeof(SqlResources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to CREATE TABLE [umbracoUserType] ( - /// [id] int NOT NULL IDENTITY (5,1) - ///, [userTypeAlias] nvarchar(50) NULL - ///, [userTypeName] nvarchar(255) NOT NULL - ///, [userTypeDefaultPermissions] nvarchar(50) NULL - ///); - ///GO - ///CREATE TABLE [umbracoUser2NodePermission] ( - /// [userId] int NOT NULL - ///, [nodeId] int NOT NULL - ///, [permission] nchar(1) NOT NULL - ///); - ///GO - ///CREATE TABLE [umbracoUser2NodeNotify] ( - /// [userId] int NOT NULL - ///, [nodeId] int NOT NULL - ///, [action] nchar(1) NOT NULL - ///); - ///GO - ///CREATE TABLE [umbracoUser] ( - /// [id] in [rest of string was truncated]";. - /// - internal static string SqlCe_SchemaAndData_4110 { - get { - return ResourceManager.GetString("SqlCe_SchemaAndData_4110", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to CREATE TABLE [umbracoRelation] - ///( - ///[id] [int] NOT NULL IDENTITY(1, 1), - ///[parentId] [int] NOT NULL, - ///[childId] [int] NOT NULL, - ///[relType] [int] NOT NULL, - ///[datetime] [datetime] NOT NULL CONSTRAINT [DF_umbracoRelation_datetime] DEFAULT (getdate()), - ///[comment] [nvarchar] (1000) NOT NULL - ///) - /// - ///; - ///ALTER TABLE [umbracoRelation] ADD CONSTRAINT [PK_umbracoRelation] PRIMARY KEY ([id]) - ///; - ///CREATE TABLE [cmsDocument] - ///( - ///[nodeId] [int] NOT NULL, - ///[published] [bit] NOT NULL, - ///[documentUser] [int] NOT [rest of string was truncated]";. - /// - internal static string SqlCeTotal_480 { - get { - return ResourceManager.GetString("SqlCeTotal_480", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to /******************************************************************************************* - /// - /// - /// - /// - /// - /// - /// - /// Umbraco database installation script for SQL Server - /// - ///IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - /// - /// Database version: 4.8.0.0 - /// - /// Please increment this version number if ANY change is made to this script, - /// so compatibility with scripts for other database systems can be verified easily. - /// The first 3 digits depict the Umbraco versi [rest of string was truncated]";. - /// - internal static string SqlServerTotal_480 { - get { - return ResourceManager.GetString("SqlServerTotal_480", resourceCulture); - } - } - } -} diff --git a/src/Umbraco.Tests/Migrations/SqlScripts/SqlResources.resx b/src/Umbraco.Tests/Migrations/SqlScripts/SqlResources.resx deleted file mode 100644 index 20ba6d0e8e..0000000000 --- a/src/Umbraco.Tests/Migrations/SqlScripts/SqlResources.resx +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - sqlcetotal-480.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - - sqlce-schemaanddata-4110.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16 - - - sqlservertotal-480.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - diff --git a/src/Umbraco.Tests/Migrations/SqlScripts/SqlServerTotal-480.sql b/src/Umbraco.Tests/Migrations/SqlScripts/SqlServerTotal-480.sql deleted file mode 100644 index e69d87f759..0000000000 --- a/src/Umbraco.Tests/Migrations/SqlScripts/SqlServerTotal-480.sql +++ /dev/null @@ -1,1671 +0,0 @@ -/******************************************************************************************* - - - - - - - - Umbraco database installation script for SQL Server - -IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - - Database version: 4.8.0.0 - - Please increment this version number if ANY change is made to this script, - so compatibility with scripts for other database systems can be verified easily. - The first 3 digits depict the Umbraco version, the last digit is the database version. - (e.g. version 4.0.0.3 means "Umbraco version 4.0.0, database version 3") - - Check-in policy: only commit this script if - * you ran the Umbraco installer completely; - * you ran it on the targetted database system; - * you ran the Runway and Module installations; - * you were able to browse the Boost site; - * you were able to open the Umbraco administration panel; - * you have documented the code change in this script; - * you have incremented the version number in this script. - -IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT - - - - - - - -********************************************************************************************/ - -CREATE TABLE [umbracoRelation] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[parentId] [int] NOT NULL, -[childId] [int] NOT NULL, -[relType] [int] NOT NULL, -[datetime] [datetime] NOT NULL CONSTRAINT [DF_umbracoRelation_datetime] DEFAULT (getdate()), -[comment] [nvarchar] (1000) COLLATE Danish_Norwegian_CI_AS NOT NULL -) - -; -ALTER TABLE [umbracoRelation] ADD CONSTRAINT [PK_umbracoRelation] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsDocument] -( -[nodeId] [int] NOT NULL, -[published] [bit] NOT NULL, -[documentUser] [int] NOT NULL, -[versionId] [uniqueidentifier] NOT NULL, -[text] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[releaseDate] [datetime] NULL, -[expireDate] [datetime] NULL, -[updateDate] [datetime] NOT NULL CONSTRAINT [DF_cmsDocument_updateDate] DEFAULT (getdate()), -[templateId] [int] NULL, -[alias] [nvarchar] (255) COLLATE Danish_Norwegian_CI_AS NULL , -[newest] [bit] NOT NULL CONSTRAINT [DF_cmsDocument_newest] DEFAULT (0) -) - -; -ALTER TABLE [cmsDocument] ADD CONSTRAINT [PK_cmsDocument] PRIMARY KEY CLUSTERED ([versionId]) -; -CREATE TABLE [umbracoLog] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[userId] [int] NOT NULL, -[NodeId] [int] NOT NULL, -[Datestamp] [datetime] NOT NULL CONSTRAINT [DF_umbracoLog_Datestamp] DEFAULT (getdate()), -[logHeader] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[logComment] [nvarchar] (1000) COLLATE Danish_Norwegian_CI_AS NULL -) - -; -ALTER TABLE [umbracoLog] ADD CONSTRAINT [PK_umbracoLog] PRIMARY KEY CLUSTERED ([id]) -; - -/* TABLES ARE NEVER USED, REMOVED FOR 4.1 - -CREATE TABLE [umbracoUserGroup] -( -[id] [smallint] NOT NULL IDENTITY(1, 1), -[userGroupName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL -) -; -ALTER TABLE [umbracoUserGroup] ADD CONSTRAINT [PK_userGroup] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [umbracoUser2userGroup] -( -[user] [int] NOT NULL, -[userGroup] [smallint] NOT NULL -) -; -ALTER TABLE [umbracoUser2userGroup] ADD CONSTRAINT [PK_user2userGroup] PRIMARY KEY CLUSTERED ([user], [userGroup]) -; - -*/ - -CREATE TABLE [umbracoApp] -( -[sortOrder] [tinyint] NOT NULL CONSTRAINT [DF_app_sortOrder] DEFAULT (0), -[appAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[appIcon] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[appName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[appInitWithTreeAlias] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [umbracoApp] ADD CONSTRAINT [PK_umbracoApp] PRIMARY KEY CLUSTERED ([appAlias]) -; -CREATE TABLE [cmsPropertyData] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[contentNodeId] [int] NOT NULL, -[versionId] [uniqueidentifier] NULL, -[propertytypeid] [int] NOT NULL, -[dataInt] [int] NULL, -[dataDate] [datetime] NULL, -[dataNvarchar] [nvarchar] (500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[dataNtext] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [cmsPropertyData] ADD CONSTRAINT [PK_cmsPropertyData] PRIMARY KEY CLUSTERED ([id]) -; -CREATE NONCLUSTERED INDEX [IX_cmsPropertyData] ON [cmsPropertyData] ([id]) -; -CREATE NONCLUSTERED INDEX [IX_cmsPropertyData_1] ON [cmsPropertyData] ([contentNodeId]) -; -CREATE NONCLUSTERED INDEX [IX_cmsPropertyData_2] ON [cmsPropertyData] ([versionId]) -; -CREATE NONCLUSTERED INDEX [IX_cmsPropertyData_3] ON [cmsPropertyData] ([propertytypeid]) -; -CREATE TABLE [cmsContent] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[contentType] [int] NOT NULL -) - -; -ALTER TABLE [cmsContent] ADD CONSTRAINT [PK_cmsContent] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [cmsContentType] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[alias] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[icon] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [cmsContentType] ADD CONSTRAINT [PK_cmsContentType] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [cmsMacroPropertyType] -( -[id] [smallint] NOT NULL IDENTITY(1, 1), -[macroPropertyTypeAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroPropertyTypeRenderAssembly] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroPropertyTypeRenderType] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroPropertyTypeBaseType] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [cmsMacroPropertyType] ADD CONSTRAINT [PK_macroPropertyType] PRIMARY KEY CLUSTERED ([id]) -; - -/* TABLE IS NEVER USED, REMOVED FOR 4.1 - -CREATE TABLE [umbracoStylesheetProperty] -( -[id] [smallint] NOT NULL IDENTITY(1, 1), -[stylesheetPropertyEditor] [bit] NOT NULL CONSTRAINT [DF_stylesheetProperty_stylesheetPropertyEditor] DEFAULT (0), -[stylesheet] [tinyint] NOT NULL, -[stylesheetPropertyAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[stylesheetPropertyName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[stylesheetPropertyValue] [nvarchar] (400) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) -; - -ALTER TABLE [umbracoStylesheetProperty] ADD CONSTRAINT [PK_stylesheetProperty] PRIMARY KEY CLUSTERED ([id]) -; - -*/ - -CREATE TABLE [cmsTab] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[contenttypeNodeId] [int] NOT NULL, -[text] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[sortorder] [int] NOT NULL -) - -; -ALTER TABLE [cmsTab] ADD CONSTRAINT [PK_cmsTab] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsTemplate] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[master] [int] NULL, -[alias] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[design] [ntext] COLLATE Danish_Norwegian_CI_AS NOT NULL -) - -; -ALTER TABLE [cmsTemplate] ADD CONSTRAINT [PK_templates] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [umbracoUser2app] -( -[user] [int] NOT NULL, -[app] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL -) - -; -ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [PK_user2app] PRIMARY KEY CLUSTERED ([user], [app]) -; -CREATE TABLE [umbracoUserType] -( -[id] [smallint] NOT NULL IDENTITY(1, 1), -[userTypeAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[userTypeName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[userTypeDefaultPermissions] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [umbracoUserType] ADD CONSTRAINT [PK_userType] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [umbracoUser] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[userDisabled] [bit] NOT NULL CONSTRAINT [DF_umbracoUser_userDisabled] DEFAULT (0), -[userNoConsole] [bit] NOT NULL CONSTRAINT [DF_umbracoUser_userNoConsole] DEFAULT (0), -[userType] [smallint] NOT NULL, -[startStructureID] [int] NOT NULL, -[startMediaID] [int] NULL, -[userName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[userLogin] [nvarchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[userPassword] [nvarchar] (125) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[userEmail] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[userDefaultPermissions] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[userLanguage] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [umbracoUser] ADD CONSTRAINT [PK_user] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsDocumentType] -( -[contentTypeNodeId] [int] NOT NULL, -[templateNodeId] [int] NOT NULL, -[IsDefault] [bit] NOT NULL CONSTRAINT [DF_cmsDocumentType_IsDefault] DEFAULT (0) -) - -; -ALTER TABLE [cmsDocumentType] ADD CONSTRAINT [PK_cmsDocumentType] PRIMARY KEY CLUSTERED ([contentTypeNodeId], [templateNodeId]) -; -CREATE TABLE [cmsMemberType] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[NodeId] [int] NOT NULL, -[propertytypeId] [int] NOT NULL, -[memberCanEdit] [bit] NOT NULL CONSTRAINT [DF_cmsMemberType_memberCanEdit] DEFAULT (0), -[viewOnProfile] [bit] NOT NULL CONSTRAINT [DF_cmsMemberType_viewOnProfile] DEFAULT (0) -) - -; -ALTER TABLE [cmsMemberType] ADD CONSTRAINT [PK_cmsMemberType] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [cmsMember] -( -[nodeId] [int] NOT NULL, -[Email] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_cmsMember_Email] DEFAULT (''), -[LoginName] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_cmsMember_LoginName] DEFAULT (''), -[Password] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_cmsMember_Password] DEFAULT ('') -) - -; -CREATE TABLE [umbracoNode] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[trashed] [bit] NOT NULL CONSTRAINT [DF_umbracoNode_trashed] DEFAULT (0), -[parentID] [int] NOT NULL, -[nodeUser] [int] NULL, -[level] [smallint] NOT NULL, -[path] [nvarchar] (150) COLLATE Danish_Norwegian_CI_AS NOT NULL, -[sortOrder] [int] NOT NULL, -[uniqueID] [uniqueidentifier] NULL, -[text] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[nodeObjectType] [uniqueidentifier] NULL, -[createDate] [datetime] NOT NULL CONSTRAINT [DF_umbracoNode_createDate] DEFAULT (getdate()) -) - -; -ALTER TABLE [umbracoNode] ADD CONSTRAINT [PK_structure] PRIMARY KEY CLUSTERED ([id]) -; -CREATE NONCLUSTERED INDEX [IX_umbracoNodeParentId] ON [umbracoNode] ([parentID]) -; -CREATE NONCLUSTERED INDEX [IX_umbracoNodeObjectType] ON [umbracoNode] ([nodeObjectType]) -; -CREATE TABLE [cmsPropertyType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[dataTypeId] [int] NOT NULL, -[contentTypeId] [int] NOT NULL, -[tabId] [int] NULL, -[Alias] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[Name] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[helpText] [nvarchar] (1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[sortOrder] [int] NOT NULL CONSTRAINT [DF__cmsProper__sortO__1EA48E88] DEFAULT (0), -[mandatory] [bit] NOT NULL CONSTRAINT [DF__cmsProper__manda__2180FB33] DEFAULT (0), -[validationRegExp] [nvarchar] (255) COLLATE Danish_Norwegian_CI_AS NULL, -[Description] [nvarchar] (2000) COLLATE Danish_Norwegian_CI_AS NULL -) - -; -ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [PK_cmsPropertyType] PRIMARY KEY CLUSTERED ([id]) -; - -CREATE TABLE [cmsMacroProperty] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[macroPropertyHidden] [bit] NOT NULL CONSTRAINT [DF_macroProperty_macroPropertyHidden] DEFAULT (0), -[macroPropertyType] [smallint] NOT NULL, -[macro] [int] NOT NULL, -[macroPropertySortOrder] [tinyint] NOT NULL CONSTRAINT [DF_macroProperty_macroPropertySortOrder] DEFAULT (0), -[macroPropertyAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[macroPropertyName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL -) - -; -ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [PK_macroProperty] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsMacro] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[macroUseInEditor] [bit] NOT NULL CONSTRAINT [DF_macro_macroUseInEditor] DEFAULT (0), -[macroRefreshRate] [int] NOT NULL CONSTRAINT [DF_macro_macroRefreshRate] DEFAULT (0), -[macroAlias] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[macroName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroScriptType] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroScriptAssembly] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroXSLT] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[macroCacheByPage] [bit] NOT NULL CONSTRAINT [DF_cmsMacro_macroCacheByPage] DEFAULT (1), -[macroCachePersonalized] [bit] NOT NULL CONSTRAINT [DF_cmsMacro_macroCachePersonalized] DEFAULT (0), -[macroDontRender] [bit] NOT NULL CONSTRAINT [DF_cmsMacro_macroDontRender] DEFAULT (0) -) - -; -ALTER TABLE [cmsMacro] ADD CONSTRAINT [PK_macro] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsContentVersion] -( -[id] [int] NOT NULL IDENTITY(1, 1) PRIMARY KEY, -[ContentId] [int] NOT NULL, -[VersionId] [uniqueidentifier] NOT NULL, -[VersionDate] [datetime] NOT NULL CONSTRAINT [DF_cmsContentVersion_VersionDate] DEFAULT (getdate()) -) - -; -CREATE TABLE [umbracoAppTree] -( -[treeSilent] [bit] NOT NULL CONSTRAINT [DF_umbracoAppTree_treeSilent] DEFAULT (0), -[treeInitialize] [bit] NOT NULL CONSTRAINT [DF_umbracoAppTree_treeInitialize] DEFAULT (1), -[treeSortOrder] [tinyint] NOT NULL, -[appAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[treeAlias] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[treeTitle] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[treeIconClosed] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[treeIconOpen] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[treeHandlerAssembly] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[treeHandlerType] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[action] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [PK_umbracoAppTree] PRIMARY KEY CLUSTERED ([appAlias], [treeAlias]) -; - -CREATE TABLE [cmsContentTypeAllowedContentType] -( -[Id] [int] NOT NULL, -[AllowedId] [int] NOT NULL -) - -; -ALTER TABLE [cmsContentTypeAllowedContentType] ADD CONSTRAINT [PK_cmsContentTypeAllowedContentType] PRIMARY KEY CLUSTERED ([Id], [AllowedId]) -; -CREATE TABLE [cmsContentXml] -( -[nodeId] [int] NOT NULL, -[xml] [ntext] COLLATE Danish_Norwegian_CI_AS NOT NULL -) - -; -ALTER TABLE [cmsContentXml] ADD CONSTRAINT [PK_cmsContentXml] PRIMARY KEY CLUSTERED ([nodeId]) -; -CREATE TABLE [cmsDataType] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[nodeId] [int] NOT NULL, -[controlId] [uniqueidentifier] NOT NULL, -[dbType] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL -) - -; -ALTER TABLE [cmsDataType] ADD CONSTRAINT [PK_cmsDataType] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [cmsDataTypePreValues] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[datatypeNodeId] [int] NOT NULL, -[value] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[sortorder] [int] NOT NULL, -[alias] [nvarchar] (50) COLLATE Danish_Norwegian_CI_AS NULL -) - -; -ALTER TABLE [cmsDataTypePreValues] ADD CONSTRAINT [PK_cmsDataTypePreValues] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsDictionary] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[id] [uniqueidentifier] NOT NULL, -[parent] [uniqueidentifier] NOT NULL, -[key] [nvarchar] (1000) COLLATE Danish_Norwegian_CI_AS NOT NULL -) - -; -ALTER TABLE [cmsDictionary] ADD CONSTRAINT [PK_cmsDictionary] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [cmsLanguageText] -( -[pk] [int] NOT NULL IDENTITY(1, 1), -[languageId] [int] NOT NULL, -[UniqueId] [uniqueidentifier] NOT NULL, -[value] [nvarchar] (1000) COLLATE Danish_Norwegian_CI_AS NOT NULL -) - -; -ALTER TABLE [cmsLanguageText] ADD CONSTRAINT [PK_cmsLanguageText] PRIMARY KEY CLUSTERED ([pk]) -; -CREATE TABLE [cmsMember2MemberGroup] -( -[Member] [int] NOT NULL, -[MemberGroup] [int] NOT NULL -) - -; -ALTER TABLE [cmsMember2MemberGroup] ADD CONSTRAINT [PK_cmsMember2MemberGroup] PRIMARY KEY CLUSTERED ([Member], [MemberGroup]) -; -CREATE TABLE [cmsStylesheet] -( -[nodeId] [int] NOT NULL, -[filename] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[content] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -CREATE TABLE [cmsStylesheetProperty] -( -[nodeId] [int] NOT NULL, -[stylesheetPropertyEditor] [bit] NULL, -[stylesheetPropertyAlias] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[stylesheetPropertyValue] [nvarchar] (400) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -CREATE TABLE [umbracoDomains] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[domainDefaultLanguage] [int] NULL, -[domainRootStructureID] [int] NULL, -[domainName] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL -) - -; -ALTER TABLE [umbracoDomains] ADD CONSTRAINT [PK_domains] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [umbracoLanguage] -( -[id] [smallint] NOT NULL IDENTITY(1, 1), -[languageISOCode] [nvarchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, -[languageCultureName] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) - -; -ALTER TABLE [umbracoLanguage] ADD CONSTRAINT [PK_language] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [umbracoRelationType] -( -[id] [int] NOT NULL IDENTITY(1, 1), -[dual] [bit] NOT NULL, -[parentObjectType] [uniqueidentifier] NOT NULL, -[childObjectType] [uniqueidentifier] NOT NULL, -[name] [nvarchar] (255) COLLATE Danish_Norwegian_CI_AS NOT NULL, -[alias] [nvarchar] (100) COLLATE Danish_Norwegian_CI_AS NULL -) - -; -ALTER TABLE [umbracoRelationType] ADD CONSTRAINT [PK_umbracoRelationType] PRIMARY KEY CLUSTERED ([id]) -; - -/* TABLE IS NEVER USED, REMOVED FOR 4.1 - -CREATE TABLE [umbracoStylesheet] -( -[nodeId] [int] NOT NULL, -[filename] [nvarchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, -[content] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL -) -; - -ALTER TABLE [umbracoStylesheet] ADD CONSTRAINT [PK_umbracoStylesheet] PRIMARY KEY CLUSTERED ([nodeId]) -; - -*/ - -CREATE TABLE [umbracoUser2NodeNotify] -( -[userId] [int] NOT NULL, -[nodeId] [int] NOT NULL, -[action] [char] (1) COLLATE Danish_Norwegian_CI_AS NOT NULL -) - -; -ALTER TABLE [umbracoUser2NodeNotify] ADD CONSTRAINT [PK_umbracoUser2NodeNotify] PRIMARY KEY CLUSTERED ([userId], [nodeId], [action]) -; -CREATE TABLE [umbracoUser2NodePermission] -( -[userId] [int] NOT NULL, -[nodeId] [int] NOT NULL, -[permission] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL -) - -; -ALTER TABLE [umbracoUser2NodePermission] ADD CONSTRAINT [PK_umbracoUser2NodePermission] PRIMARY KEY CLUSTERED ([userId], [nodeId], [permission]) -; -ALTER TABLE [umbracoAppTree] ADD -CONSTRAINT [FK_umbracoAppTree_umbracoApp] FOREIGN KEY ([appAlias]) REFERENCES [umbracoApp] ([appAlias]) -; -ALTER TABLE [cmsPropertyData] ADD -CONSTRAINT [FK_cmsPropertyData_umbracoNode] FOREIGN KEY ([contentNodeId]) REFERENCES [umbracoNode] ([id]) -; - -/* TABLES ARE NEVER USED, REMOVED FOR 4.1 - -ALTER TABLE [umbracoUser2userGroup] ADD -CONSTRAINT [FK_user2userGroup_user] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]), -CONSTRAINT [FK_user2userGroup_userGroup] FOREIGN KEY ([userGroup]) REFERENCES [umbracoUserGroup] ([id]) -; - -*/ - -ALTER TABLE [cmsDocument] ADD -CONSTRAINT [FK_cmsDocument_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsMacroProperty] ADD -CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id]) -; -ALTER TABLE [umbracoUser] ADD -CONSTRAINT [FK_user_userType] FOREIGN KEY ([userType]) REFERENCES [umbracoUserType] ([id]) -; -ALTER TABLE [umbracoNode] ADD -CONSTRAINT [FK_umbracoNode_umbracoNode] FOREIGN KEY ([parentID]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsTemplate] ADD -CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsContentType] ADD -CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [cmsPropertyType] ADD -CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) -; -ALTER TABLE [cmsContent] ADD -CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -; -ALTER TABLE [umbracoUser2app] ADD -CONSTRAINT [FK_umbracoUser2app_umbracoApp] FOREIGN KEY ([app]) REFERENCES [umbracoApp] ([appAlias]), -CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]) -; - -ALTER TABLE [cmsTemplate] DROP CONSTRAINT [FK_cmsTemplate_umbracoNode] -; -ALTER TABLE [cmsPropertyType] DROP CONSTRAINT [FK_cmsPropertyType_cmsTab] -; -ALTER TABLE [cmsContent] DROP CONSTRAINT [FK_cmsContent_umbracoNode] -; -ALTER TABLE [cmsMacroProperty] DROP CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] -; -ALTER TABLE [umbracoAppTree] DROP CONSTRAINT [FK_umbracoAppTree_umbracoApp] -; -ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoApp] -; -ALTER TABLE [umbracoUser2app] DROP CONSTRAINT [FK_umbracoUser2app_umbracoUser] -; -ALTER TABLE [cmsPropertyData] DROP CONSTRAINT [FK_cmsPropertyData_umbracoNode] -; - -/* TABLE IS NEVER USED, REMOVED FOR 4.1 - -ALTER TABLE [umbracoUser2userGroup] DROP CONSTRAINT [FK_user2userGroup_user] -; -ALTER TABLE [umbracoUser2userGroup] DROP CONSTRAINT [FK_user2userGroup_userGroup] -; - -*/ - -ALTER TABLE [umbracoUser] DROP CONSTRAINT [FK_user_userType] -; -ALTER TABLE [cmsContentType] DROP CONSTRAINT [FK_cmsContentType_umbracoNode] -; -ALTER TABLE [cmsDocument] DROP CONSTRAINT [FK_cmsDocument_umbracoNode] -; -ALTER TABLE [umbracoNode] DROP CONSTRAINT [FK_umbracoNode_umbracoNode] -; -SET IDENTITY_INSERT [umbracoNode] ON -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-92, 0, -1, 0, 11, N'-1,-92', 37, 'f0bc4bfb-b499-40d6-ba86-058885a5178c', N'Label', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-90, 0, -1, 0, 11, N'-1,-90', 35, '84c6b441-31df-4ffe-b67e-67d5bc3ae65a', N'Upload', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-89, 0, -1, 0, 11, N'-1,-89', 34, 'c6bac0dd-4ab9-45b1-8e30-e4b619ee5da3', N'Textarea', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-88, 0, -1, 0, 11, N'-1,-88', 33, '0cc0eba1-9960-42c9-bf9b-60e150b429ae', N'Textstring', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-87, 0, -1, 0, 11, N'-1,-87', 32, 'ca90c950-0aff-4e72-b976-a30b1ac57dad', N'Richtext editor', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-51, 0, -1, 0, 11, N'-1,-51', 4, '2e6d3631-066e-44b8-aec4-96f09099b2b5', N'Numeric', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-49, 0, -1, 0, 11, N'-1,-49', 2, '92897bc6-a5f3-4ffe-ae27-f2e7e33dda49', N'True/false', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-43, 0, -1, 0, 1, N'-1,-43', 2, 'fbaf13a8-4036-41f2-93a3-974f678c312a', N'Checkbox list', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:11:04.367') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-42, 0, -1, 0, 1, N'-1,-42', 2, '0b6a45e7-44ba-430d-9da5-4e46060b9e03', N'Dropdown', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:59.000') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-41, 0, -1, 0, 1, N'-1,-41', 2, '5046194e-4237-453c-a547-15db3a07c4e1', N'Date Picker', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:54.303') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-40, 0, -1, 0, 1, N'-1,-40', 2, 'bb5f57c9-ce2b-4bb9-b697-4caca783a805', N'Radiobox', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:49.253') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-39, 0, -1, 0, 1, N'-1,-39', 2, 'f38f0ac7-1d27-439c-9f3f-089cd8825a53', N'Dropdown multiple', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:44.480') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-38, 0, -1, 0, 1, N'-1,-38', 2, 'fd9f1447-6c61-4a7c-9595-5aa39147d318', N'Folder Browser', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:37.020') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-37, 0, -1, 0, 1, N'-1,-37', 2, '0225af17-b302-49cb-9176-b9f35cab9c17', N'Approved Color', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:30.580') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-36, 0, -1, 0, 1, N'-1,-36', 2, 'e4d66c0f-b935-4200-81f0-025f7256b89a', N'Date Picker with time', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20041015 14:10:23.007') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (-1, 0, -1, 0, 0, N'-1', 0, '916724a5-173d-4619-b97e-b9de133dd6f5', N'SYSTEM DATA: umbraco master root', 'ea7d8624-4cfe-4578-a871-24aa946bf34d', '20040930 14:01:49.920') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1031, 0, -1, 1, 1, N'-1,1031', 2, 'f38bd2d7-65d0-48e6-95dc-87ce06ec2d3d', N'Folder', '4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e', '20041201 00:13:40.743') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1032, 0, -1, 1, 1, N'-1,1032', 2, 'cc07b313-0843-4aa8-bbda-871c8da728c8', N'Image', '4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e', '20041201 00:13:43.737') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1033, 0, -1, 1, 1, N'-1,1033', 2, '4c52d8ab-54e6-40cd-999c-7a5f24903e4d', N'File', '4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e', '20041201 00:13:46.210') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1034, 0, -1, 0, 1, N'-1,1034', 2, 'a6857c73-d6e9-480c-b6e6-f15f6ad11125', N'Content Picker', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:29.203') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1035, 0, -1, 0, 1, N'-1,1035', 2, '93929b9a-93a2-4e2a-b239-d99334440a59', N'Media Picker', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:36.143') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1036, 0, -1, 0, 1, N'-1,1036', 2, '2b24165f-9782-4aa3-b459-1de4a4d21f60', N'Member Picker', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:40.260') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1038, 0, -1, 0, 1, N'-1,1038', 2, '1251c96c-185c-4e9b-93f4-b48205573cbd', N'Simple Editor', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:55.250') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1039, 0, -1, 0, 1, N'-1,1039', 2, '06f349a9-c949-4b6a-8660-59c10451af42', N'Ultimate Picker', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:55.250') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1040, 0, -1, 0, 1, N'-1,1040', 2, '21e798da-e06e-4eda-a511-ed257f78d4fa', N'Related Links', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:55.250') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1041, 0, -1, 0, 1, N'-1,1041', 2, 'b6b73142-b9c1-4bf8-a16d-e1c23320b549', N'Tags', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:55.250') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1042, 0, -1, 0, 1, N'-1,1042', 2, '0a452bd5-83f9-4bc3-8403-1286e13fb77e', N'Macro Container', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:55.250') -INSERT INTO [umbracoNode] ([id], [trashed], [parentID], [nodeUser], [level], [path], [sortOrder], [uniqueID], [text], [nodeObjectType], [createDate]) VALUES (1043, 0, -1, 0, 1, N'-1,1043', 2, '1df9f033-e6d4-451f-b8d2-e0cbc50a836f', N'Image Cropper', '30a2a501-1978-4ddb-a57b-f7efed43ba3c', '20060103 13:07:55.250') - -SET IDENTITY_INSERT [umbracoNode] OFF -; -SET IDENTITY_INSERT [cmsContentType] ON -INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (532, 1031, N'Folder', N'folder.gif') -INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (533, 1032, N'Image', N'mediaPhoto.gif') -INSERT INTO [cmsContentType] ([pk], [nodeId], [alias], [icon]) VALUES (534, 1033, N'File', N'mediaMulti.gif') -SET IDENTITY_INSERT [cmsContentType] OFF -; -SET IDENTITY_INSERT [umbracoUser] ON -INSERT INTO [umbracoUser] ([id], [userDisabled], [userNoConsole], [userType], [startStructureID], [startMediaID], [userName], [userLogin], [userPassword], [userEmail], [userDefaultPermissions], [userLanguage]) VALUES (0, 0, 0, 1, -1, -1, N'Administrator', N'admin', N'default', N'', NULL, N'en') -SET IDENTITY_INSERT [umbracoUser] OFF -; -SET IDENTITY_INSERT [umbracoUserType] ON -INSERT INTO [umbracoUserType] ([id], [userTypeAlias], [userTypeName], [userTypeDefaultPermissions]) VALUES (1, N'admin', N'Administrators', N'CADMOSKTPIURZ:') -INSERT INTO [umbracoUserType] ([id], [userTypeAlias], [userTypeName], [userTypeDefaultPermissions]) VALUES (2, N'writer', N'Writer', N'CAH:') -INSERT INTO [umbracoUserType] ([id], [userTypeAlias], [userTypeName], [userTypeDefaultPermissions]) VALUES (3, N'editor', N'Editors', N'CADMOSKTPUZ:') -SET IDENTITY_INSERT [umbracoUserType] OFF -; -INSERT INTO [umbracoUser2app] ([user], [app]) VALUES (0, N'content') -INSERT INTO [umbracoUser2app] ([user], [app]) VALUES (0, N'developer') -INSERT INTO [umbracoUser2app] ([user], [app]) VALUES (0, N'media') -INSERT INTO [umbracoUser2app] ([user], [app]) VALUES (0, N'member') -INSERT INTO [umbracoUser2app] ([user], [app]) VALUES (0, N'settings') -INSERT INTO [umbracoUser2app] ([user], [app]) VALUES (0, N'users') - -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'content', 0, N'.traycontent', N'Indhold', N'content') -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'developer', 7, N'.traydeveloper', N'Developer', NULL) -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'media', 1, N'.traymedia', N'Mediearkiv', NULL) -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'member', 8, N'.traymember', N'Medlemmer', NULL) -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'settings', 6, N'.traysettings', N'Indstillinger', NULL) -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'users', 5, N'.trayusers', N'Brugere', NULL) - - -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'content', N'content', 1, 1, 0, N'Indhold', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadContent') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'developer', N'cacheBrowser', 0, 1, 0, N'CacheBrowser', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadCache') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'developer', N'CacheItem', 0, 0, 0, N'Cachebrowser', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadCacheItem') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'developer', N'datatype', 0, 1, 1, N'Datatyper', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadDataTypes') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'developer', N'macros', 0, 1, 2, N'Macros', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadMacros') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'developer', N'xslt', 0, 1, 5, N'XSLT Files', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadXslt') - -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'media', N'media', 0, 1, 0, N'Medier', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadMedia') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'member', N'member', 0, 1, 0, N'Medlemmer', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadMembers') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'member', N'memberGroups', 0, 1, 1, N'MemberGroups', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadMemberGroups') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'member', N'memberTypes', 0, 1, 2, N'Medlemstyper', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadMemberTypes') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType], [action]) VALUES (N'settings', N'dictionary', 0, 1, 3, N'Dictionary', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadDictionary', N'openDictionary()') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'settings', N'languages', 0, 1, 4, N'Languages', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadLanguages') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'settings', N'mediaTypes', 0, 1, 5, N'Medietyper', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadMediaTypes') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'settings', N'documentTypes', 0, 1, 6, N'Dokumenttyper', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadNodeTypes') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'settings', N'stylesheetProperty', 0, 0, 0, N'Stylesheet Property', N'', N'', N'umbraco', N'loadStylesheetProperty') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'settings', N'stylesheets', 0, 1, 0, N'Stylesheets', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadStylesheets') -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'settings', N'templates', 0, 1, 1, N'Templates', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadTemplates') - -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'users', N'users', 0, 1, 0, N'Brugere', N'.sprTreeFolder', N'.sprTreeFolder_o', N'umbraco', N'loadUsers') - -SET IDENTITY_INSERT [cmsMacroPropertyType] ON -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (3, N'mediaCurrent', N'umbraco.macroRenderings', N'media', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (4, N'contentSubs', N'umbraco.macroRenderings', N'content', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (5, N'contentRandom', N'umbraco.macroRenderings', N'content', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (6, N'contentPicker', N'umbraco.macroRenderings', N'content', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (13, N'number', N'umbraco.macroRenderings', N'numeric', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (14, N'bool', N'umbraco.macroRenderings', N'yesNo', N'Boolean') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (16, N'text', N'umbraco.macroRenderings', N'text', N'String') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (17, N'contentTree', N'umbraco.macroRenderings', N'content', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (18, N'contentType', N'umbraco.macroRenderings', N'contentTypeSingle', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (19, N'contentTypeMultiple', N'umbraco.macroRenderings', N'contentTypeMultiple', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (20, N'contentAll', N'umbraco.macroRenderings', N'content', N'Int32') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (21, N'tabPicker', N'umbraco.macroRenderings', N'tabPicker', N'String') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (22, N'tabPickerMultiple', N'umbraco.macroRenderings', N'tabPickerMultiple', N'String') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (23, N'propertyTypePicker', N'umbraco.macroRenderings', N'propertyTypePicker', N'String') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (24, N'propertyTypePickerMultiple', N'umbraco.macroRenderings', N'propertyTypePickerMultiple', N'String') -INSERT INTO [cmsMacroPropertyType] ([id], [macroPropertyTypeAlias], [macroPropertyTypeRenderAssembly], [macroPropertyTypeRenderType], [macroPropertyTypeBaseType]) VALUES (25, N'textMultiLine', N'umbraco.macroRenderings', N'textMultiple', N'String') -SET IDENTITY_INSERT [cmsMacroPropertyType] OFF -; -SET IDENTITY_INSERT [cmsTab] ON -INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (3, 1032, N'Image', 1) -INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (4, 1033, N'File', 1) -INSERT INTO [cmsTab] ([id], [contenttypeNodeId], [text], [sortorder]) VALUES (5, 1031, N'Contents', 1) -SET IDENTITY_INSERT [cmsTab] OFF -; -SET IDENTITY_INSERT [cmsPropertyType] ON -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (6, -90, 1032, 3, N'umbracoFile', N'Upload image', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (7, -92, 1032, 3, N'umbracoWidth', N'Width', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (8, -92, 1032, 3, N'umbracoHeight', N'Height', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (9, -92, 1032, 3, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (10, -92, 1032, 3, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (24, -90, 1033, 4, N'umbracoFile', N'Upload file', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (25, -92, 1033, 4, N'umbracoExtension', N'Type', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (26, -92, 1033, 4, N'umbracoBytes', N'Size', NULL, 0, 0, NULL, NULL) -INSERT INTO [cmsPropertyType] ([id], [dataTypeId], [contentTypeId], [tabId], [Alias], [Name], [helpText], [sortOrder], [mandatory], [validationRegExp], [Description]) VALUES (27, -38, 1031, 5, N'contents', N'Contents:', NULL, 0, 0, NULL, NULL) -SET IDENTITY_INSERT [cmsPropertyType] OFF -; -SET IDENTITY_INSERT [umbracoLanguage] ON -INSERT INTO [umbracoLanguage] ([id], [languageISOCode], [languageCultureName]) VALUES (1, N'en-US', N'en-US') -SET IDENTITY_INSERT [umbracoLanguage] OFF -; -INSERT INTO [cmsContentTypeAllowedContentType] ([Id], [AllowedId]) VALUES (1031, 1031) -INSERT INTO [cmsContentTypeAllowedContentType] ([Id], [AllowedId]) VALUES (1031, 1032) -INSERT INTO [cmsContentTypeAllowedContentType] ([Id], [AllowedId]) VALUES (1031, 1033) -SET IDENTITY_INSERT [cmsDataType] ON -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (4, -49, '38b352c1-e9f8-4fd8-9324-9a2eab06d97a', 'Integer') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (6, -51, '1413afcb-d19a-4173-8e9a-68288d2a73b8', 'Integer') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (8, -87, '5E9B75AE-FACE-41c8-B47E-5F4B0FD82F83', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (9, -88, 'ec15c1e5-9d90-422a-aa52-4f7622c63bea', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (10, -89, '67db8357-ef57-493e-91ac-936d305e0f2a', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (11, -90, '5032a6e6-69e3-491d-bb28-cd31cd11086c', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (12, -91, 'a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (13, -92, '6c738306-4c17-4d88-b9bd-6546f3771597', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (14, -36, 'b6fb1622-afa5-4bbf-a3cc-d9672a442222', 'Date') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (15, -37, 'f8d60f68-ec59-4974-b43b-c46eb5677985', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (16, -38, 'cccd4ae9-f399-4ed2-8038-2e88d19e810c', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (17, -39, '928639ed-9c73-4028-920c-1e55dbb68783', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (18, -40, 'a52c7c1c-c330-476e-8605-d63d3b84b6a6', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (19, -41, '23e93522-3200-44e2-9f29-e61a6fcbb79a', 'Date') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (20, -42, 'a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6', 'Integer') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (21, -43, 'b4471851-82b6-4c75-afa4-39fa9c6a75e9', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (22, -44, 'a3776494-0574-4d93-b7de-efdfdec6f2d1', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (23, -128, 'a52c7c1c-c330-476e-8605-d63d3b84b6a6', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (24, -129, '928639ed-9c73-4028-920c-1e55dbb68783', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (25, -130, 'a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (26, -131, 'a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (27, -132, 'a74ea9c9-8e18-4d2a-8cf6-73c6206c5da6', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (28, -133, '6c738306-4c17-4d88-b9bd-6546f3771597', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (29, -134, '928639ed-9c73-4028-920c-1e55dbb68783', 'Nvarchar') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (30, -50, 'aaf99bb2-dbbe-444d-a296-185076bf0484', 'Date') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (31, 1034, '158aa029-24ed-4948-939e-c3da209e5fba', 'Integer') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (32, 1035, 'ead69342-f06d-4253-83ac-28000225583b', 'Integer') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (33, 1036, '39f533e4-0551-4505-a64b-e0425c5ce775', 'Integer') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (35, 1038, '60b7dabf-99cd-41eb-b8e9-4d2e669bbde9', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (36, 1039, 'cdbf0b5d-5cb2-445f-bc12-fcaaec07cf2c', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (37, 1040, '71b8ad1a-8dc2-425c-b6b8-faa158075e63', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (38, 1041, '4023e540-92f5-11dd-ad8b-0800200c9a66', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (39, 1042, '474FCFF8-9D2D-11DE-ABC6-AD7A56D89593', 'Ntext') -INSERT INTO [cmsDataType] ([pk], [nodeId], [controlId], [dbType]) VALUES (40, 1043, '7A2D436C-34C2-410F-898F-4A23B3D79F54', 'Ntext') - -SET IDENTITY_INSERT [cmsDataType] OFF -; -ALTER TABLE [cmsTemplate] ADD CONSTRAINT [FK_cmsTemplate_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -ALTER TABLE [cmsPropertyType] ADD CONSTRAINT [FK_cmsPropertyType_cmsTab] FOREIGN KEY ([tabId]) REFERENCES [cmsTab] ([id]) -ALTER TABLE [cmsContent] ADD CONSTRAINT [FK_cmsContent_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -ALTER TABLE [cmsMacroProperty] ADD CONSTRAINT [FK_umbracoMacroProperty_umbracoMacroPropertyType] FOREIGN KEY ([macroPropertyType]) REFERENCES [cmsMacroPropertyType] ([id]) -ALTER TABLE [umbracoAppTree] ADD CONSTRAINT [FK_umbracoAppTree_umbracoApp] FOREIGN KEY ([appAlias]) REFERENCES [umbracoApp] ([appAlias]) -ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [FK_umbracoUser2app_umbracoApp] FOREIGN KEY ([app]) REFERENCES [umbracoApp] ([appAlias]) -ALTER TABLE [umbracoUser2app] ADD CONSTRAINT [FK_umbracoUser2app_umbracoUser] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]) -ALTER TABLE [cmsPropertyData] ADD CONSTRAINT [FK_cmsPropertyData_umbracoNode] FOREIGN KEY ([contentNodeId]) REFERENCES [umbracoNode] ([id]) - -/* TABLE IS NEVER USED, REMOVED FOR 4.1 - -ALTER TABLE [umbracoUser2userGroup] ADD CONSTRAINT [FK_user2userGroup_user] FOREIGN KEY ([user]) REFERENCES [umbracoUser] ([id]) -ALTER TABLE [umbracoUser2userGroup] ADD CONSTRAINT [FK_user2userGroup_userGroup] FOREIGN KEY ([userGroup]) REFERENCES [umbracoUserGroup] ([id]) - -*/ - -ALTER TABLE [umbracoUser] ADD CONSTRAINT [FK_user_userType] FOREIGN KEY ([userType]) REFERENCES [umbracoUserType] ([id]) -ALTER TABLE [cmsContentType] ADD CONSTRAINT [FK_cmsContentType_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -ALTER TABLE [cmsDocument] ADD CONSTRAINT [FK_cmsDocument_umbracoNode] FOREIGN KEY ([nodeId]) REFERENCES [umbracoNode] ([id]) -ALTER TABLE [umbracoNode] ADD CONSTRAINT [FK_umbracoNode_umbracoNode] FOREIGN KEY ([parentID]) REFERENCES [umbracoNode] ([id]) -; -set identity_insert umbracoNode on -insert into umbracoNode -(id, trashed, parentID, nodeUser, level, path, sortOrder, uniqueID, text, nodeObjectType) -values -(-20, 0, -1, 0, 0, '-1,-20', 0, '0F582A79-1E41-4CF0-BFA0-76340651891A', 'Recycle Bin', '01BB7FF2-24DC-4C0C-95A2-C24EF72BBAC8') -set identity_insert umbracoNode off -; -ALTER TABLE cmsDataTypePreValues ALTER COLUMN value NVARCHAR(2500) NULL -; -CREATE TABLE [cmsTask] -( -[closed] [bit] NOT NULL CONSTRAINT [DF__cmsTask__closed__04E4BC85] DEFAULT ((0)), -[id] [int] NOT NULL IDENTITY(1, 1), -[taskTypeId] [tinyint] NOT NULL, -[nodeId] [int] NOT NULL, -[parentUserId] [int] NOT NULL, -[userId] [int] NOT NULL, -[DateTime] [datetime] NOT NULL CONSTRAINT [DF__cmsTask__DateTim__05D8E0BE] DEFAULT (getdate()), -[Comment] [nvarchar] (500) NULL -) -; -ALTER TABLE [cmsTask] ADD CONSTRAINT [PK_cmsTask] PRIMARY KEY CLUSTERED ([id]) -; -CREATE TABLE [cmsTaskType] -( -[id] [tinyint] NOT NULL IDENTITY(1, 1), -[alias] [nvarchar] (255) NOT NULL -) -; -ALTER TABLE [cmsTaskType] ADD CONSTRAINT [PK_cmsTaskType] PRIMARY KEY CLUSTERED ([id]) -; -ALTER TABLE [cmsTask] ADD -CONSTRAINT [FK_cmsTask_cmsTaskType] FOREIGN KEY ([taskTypeId]) REFERENCES [cmsTaskType] ([id]) -; -insert into cmsTaskType (alias) values ('toTranslate') -; -/* Add send to translate actions to admins and editors */ -update umbracoUserType set userTypeDefaultPermissions = userTypeDefaultPermissions + '5' where userTypeAlias in ('editor','admin') -; -/* Add translator usertype */ -if not exists(select id from umbracoUserType where userTypeAlias = 'translator') -insert into umbracoUserType (userTypeAlias, userTypeName, userTypeDefaultPermissions) values ('translator', 'Translator', 'A') -; -insert into umbracoRelationType (dual, parentObjectType, childObjectType, name, alias) values (1, 'c66ba18e-eaf3-4cff-8a22-41b16d66a972', 'c66ba18e-eaf3-4cff-8a22-41b16d66a972', 'Relate Document On Copy','relateDocumentOnCopy') -; -ALTER TABLE cmsMacro ADD macroPython nvarchar(255) -; - -INSERT INTO [umbracoAppTree]([treeSilent], [treeInitialize], [treeSortOrder], [appAlias], [treeAlias], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES(0, 1, 4, 'developer', 'python', 'Python Files', 'folder.gif', 'folder_o.gif', 'umbraco', 'loadPython') -; -INSERT INTO [umbracoAppTree]([treeSilent], [treeInitialize], [treeSortOrder], [appAlias], [treeAlias], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES(0, 1, 2, 'settings', 'scripts', 'Scripts', 'folder.gif', 'folder_o.gif', 'umbraco', 'loadScripts') -; -alter TABLE [cmsContentType] -add [thumbnail] nvarchar(255) NOT NULL CONSTRAINT -[DF_cmsContentType_thumbnail] DEFAULT ('folder.png') -; -alter TABLE [cmsContentType] -add [description] nvarchar(1500) NULL -; -ALTER TABLE umbracoLog ALTER COLUMN logComment NVARCHAR(4000) NULL -; -SET IDENTITY_INSERT [cmsDataTypePreValues] ON -insert into cmsDataTypePreValues (id, dataTypeNodeId, [value], sortorder, alias) -values (3,-87,',code,undo,redo,cut,copy,mcepasteword,stylepicker,bold,italic,bullist,numlist,outdent,indent,mcelink,unlink,mceinsertanchor,mceimage,umbracomacro,mceinserttable,mcecharmap,' + char(124) + '1' + char(124) + '1,2,3,' + char(124) + '0' + char(124) + '500,400' + char(124) + '1049,' + char(124) + '', 0, '') - -insert into cmsDataTypePreValues (id, dataTypeNodeId, [value], sortorder, alias) -values (4,1041,'default', 0, 'group') - -SET IDENTITY_INSERT [cmsDataTypePreValues] OFF -; -/* 3.1 SQL changes */ - -INSERT INTO [umbracoAppTree] ([appAlias], [treeAlias], [treeSilent], [treeInitialize], [treeSortOrder], [treeTitle], [treeIconClosed], [treeIconOpen], [treeHandlerAssembly], [treeHandlerType]) VALUES (N'developer', N'packagerPackages', 0, 0, 1, N'Packager Packages', N'folder.gif', N'folder_o.gif', N'umbraco', N'loadPackages'); - - -/* Add ActionBrowse as a default permission to all user types that have ActionUpdate */ -UPDATE umbracoUserType SET userTypeDefaultPermissions = userTypeDefaultPermissions + 'F' WHERE CHARINDEX('A',userTypeDefaultPermissions,0) >= 1 -AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1 -; -/* Add ActionToPublish to all users types that have the alias 'writer' */ -UPDATE umbracoUserType SET userTypeDefaultPermissions = userTypeDefaultPermissions + 'H' WHERE userTypeAlias = 'writer' -AND CHARINDEX('F',userTypeDefaultPermissions,0) < 1 -; -/* Add ActionBrowse to all user permissions for nodes that have the ActionUpdate permission */ -IF NOT EXISTS (SELECT permission FROM umbracoUser2NodePermission WHERE permission='F') -INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission) -SELECT userID, nodeId, 'F' FROM umbracoUser2NodePermission WHERE permission='A' -; -/* Add ActionToPublish permissions to all nodes for users that are of type 'writer' */ -IF NOT EXISTS (SELECT permission FROM umbracoUser2NodePermission WHERE permission='H') -INSERT INTO umbracoUser2NodePermission (userID, nodeId, permission) -SELECT DISTINCT userID, nodeId, 'H' FROM umbracoUser2NodePermission WHERE userId IN -(SELECT umbracoUser.id FROM umbracoUserType INNER JOIN umbracoUser ON umbracoUserType.id = umbracoUser.userType WHERE (umbracoUserType.userTypeAlias = 'writer')) -; -/* Add the contentRecycleBin tree type */ -IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='contentRecycleBin') -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 0, 0, 'content', 'contentRecycleBin', 'RecycleBin', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.ContentRecycleBin') -; -/* Add the UserType tree type */ -IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='userTypes') -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 1, 1, 'users', 'userTypes', 'User Types', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.UserTypes') -; -/* Add the User Permission tree type */ -IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='userPermissions') -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 1, 2, 'users', 'userPermissions', 'User Permissions', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.UserPermissions'); - - -/* TRANSLATION RELATED SQL */ -INSERT INTO [umbracoApp] ([appAlias], [sortOrder], [appIcon], [appName], [appInitWithTreeAlias]) VALUES (N'translation', 5, N'.traytranslation', N'Translation', NULL) -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 1, 1, 'translation','openTasks', 'Tasks assigned to you', '.sprTreeFolder', '.sprTreeFolder_o', 'umbraco', 'loadOpenTasks'); -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 1, 2, 'translation','yourTasks', 'Tasks created by you', '.sprTreeFolder', '.sprTreeFolder_o', 'umbraco', 'loadYourTasks'); - - -alter TABLE [cmsContentType] -add [masterContentType] int NULL CONSTRAINT -[DF_cmsContentType_masterContentType] DEFAULT (0) -; - -CREATE TABLE [cmsTagRelationship]( - [nodeId] [int] NOT NULL, - [tagId] [int] NOT NULL, - CONSTRAINT [PK_cmsTagRelationship] PRIMARY KEY CLUSTERED -( - [nodeId] ASC, - [tagId] ASC -) -) ON [PRIMARY] -; - -CREATE TABLE [cmsTags]( - [id] [int] IDENTITY(1,1) NOT NULL, - [tag] [varchar](200) NULL, - [parentId] [int] NULL, - [group] [varchar](100) NULL, - CONSTRAINT [PK_cmsTags] PRIMARY KEY CLUSTERED -( - [id] ASC -) -) ON [PRIMARY] -; - -ALTER TABLE [cmsTagRelationship] WITH CHECK ADD CONSTRAINT [umbracoNode_cmsTagRelationship] FOREIGN KEY([nodeId]) -REFERENCES [umbracoNode] ([id]) -ON DELETE CASCADE -; - -ALTER TABLE [cmsTagRelationship] CHECK CONSTRAINT [umbracoNode_cmsTagRelationship] -; - -ALTER TABLE [cmsTagRelationship] WITH CHECK ADD CONSTRAINT [cmsTags_cmsTagRelationship] FOREIGN KEY([tagId]) -REFERENCES [cmsTags] ([id]) -ON DELETE CASCADE -; - -ALTER TABLE [cmsTagRelationship] CHECK CONSTRAINT [cmsTags_cmsTagRelationship] -; -alter TABLE [umbracoUser] -add [defaultToLiveEditing] bit NOT NULL CONSTRAINT -[DF_umbracoUser_defaultToLiveEditing] DEFAULT (0) -; - -/* INSERT NEW MEDIA RECYCLE BIN NODE */ -SET IDENTITY_INSERT [umbracoNode] ON -INSERT INTO umbracoNode (id, trashed, parentID, nodeUser, level, path, sortOrder, uniqueID, text, nodeObjectType) -VALUES (-21, 0, -1, 0, 0, '-1,-21', 0, 'BF7C7CBC-952F-4518-97A2-69E9C7B33842', 'Recycle Bin', 'CF3D8E34-1C1C-41e9-AE56-878B57B32113') -SET IDENTITY_INSERT [umbracoNode] OFF -; -/* Add the mediaRecycleBin tree type */ -IF NOT EXISTS (SELECT treeAlias FROM umbracoAppTree WHERE treeAlias='mediaRecycleBin') -INSERT INTO umbracoAppTree (treeSilent, treeInitialize, treeSortOrder, appAlias, treeAlias, treeTitle, treeIconClosed, treeIconOpen, treeHandlerAssembly, treeHandlerType) -VALUES (0, 0, 0, 'media', 'mediaRecycleBin', 'RecycleBin', 'folder.gif', 'folder_o.gif', 'umbraco', 'cms.presentation.Trees.MediaRecycleBin') -; - -/* PREVIEW */ -CREATE TABLE [cmsPreviewXml]( - [nodeId] [int] NOT NULL, - [versionId] [uniqueidentifier] NOT NULL, - [timestamp] [datetime] NOT NULL, - [xml] [ntext] NOT NULL, - CONSTRAINT [PK_cmsContentPreviewXml] PRIMARY KEY CLUSTERED -( - [nodeId] ASC, - [versionId] ASC -) WITH ( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) -) -; - - - - -/*********************************************************************************************************************** - -ADD NEW PRIMARY KEYS, FOREIGN KEYS AND INDEXES FOR VERSION 4.1 - -IMPORTANT!!!!! -YOU MUST MAKE SURE THAT THE SCRIPT BELOW THIS MATCHES THE KeysIndexesAndConstraints.sql FILE FOR THE MANUAL UPGRADE - -*/ - -/************************** CLEANUP ***********************************************/ - -/* DELETE NON-EXISTING DOCUMENTS */ -delete from cmsDocument where nodeId not in (select id from umbracoNode) -; - -/* CLEAN UNUSED CONTENT ROWS */ -delete from cmsContent where nodeId not in (select id from umbracoNode) -; - -/* CLEAN UNUSED VERSIONS */ -delete from cmsContentVersion where contentid not in (select nodeId from cmsContent) -; - -/* CLEAN UNUSED XML */ -delete from cmsContentXml where nodeid not in (select nodeId from cmsContent) -; - -/* CLEAN UNUSED DOCUMENT TYPES */ -delete from cmsDocumentType where contentTypeNodeId not in (select nodeId from cmsContentType) -; -delete from cmsDocumentType where templateNodeId not in (select nodeid from cmsTemplate) -; - -/* UPDATE EMPTY TEMPLATE REFERENCES IN DOCUMENTS */ -update cmsDocument set templateId = NULL where templateId not in (select nodeId from cmsTemplate) -; - -/* DELETE ALL NOTIFICATIONS THAT NO LONGER HAVE NODES */ -delete from umbracoUser2NodeNotify where nodeId not in (select id from umbracoNode) -; - -/* DELETE ALL NOTIFICATIONS THAT NO LONGER HAVE USERS */ -delete from umbracoUser2NodeNotify where userId not in (select id from umbracoUser) -; - -/* DELETE UMBRACO NODE DATA THAT IS FLAGGED AS A DOCUMENT OBJECT TYPE THAT DOESN'T EXIST IN THE CONTENT TABLE ANY LONGER */ -delete from umbracoNode where id not in -(select nodeId from cmsContent) and nodeObjectType = 'c66ba18e-eaf3-4cff-8a22-41b16d66a972' -; - -/* DELETE PERMISSIONS THAT RELATED TO NON-EXISTING USERS */ -delete from umbracoUser2NodePermission where userId not in (select id from umbracoUser) -; - -/* DELETE PERMISSIONS THAT RELATED TO NON-EXISTING NODES */ -delete from umbracoUser2NodePermission where nodeId not in (select id from umbracoNode) -; - -/* SET MASTER TEMPLATE TO NULL WHEN THERE ISN'T ONE SPECIFIED */ -update cmsTemplate set [master] = NULL where [master] = 0 - -/* -We need to remove any data type that doesn't exist in umbracoNode as these shouldn't actually exist -I think they must be left over from how Umbraco used to show the types of data types registered instead -of using reflection. Here are the data types in the cmsDataType table that are not in umbracoNode: - -12 -91 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -22 -44 A3776494-0574-4D93-B7DE-EFDFDEC6F2D1 Ntext -23 -128 A52C7C1C-C330-476E-8605-D63D3B84B6A6 Nvarchar -24 -129 928639ED-9C73-4028-920C-1E55DBB68783 Nvarchar -25 -130 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -26 -131 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -27 -132 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Nvarchar -28 -133 6C738306-4C17-4D88-B9BD-6546F3771597 Ntext -29 -134 928639ED-9C73-4028-920C-1E55DBB68783 Nvarchar -30 -50 AAF99BB2-DBBE-444D-A296-185076BF0484 Date -39 1042 5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83 Ntext -40 1043 5E9B75AE-FACE-41C8-B47E-5F4B0FD82F83 Ntext -41 1044 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Ntext -42 1045 A74EA9C9-8E18-4D2A-8CF6-73C6206C5DA6 Ntext -47 1194 D15E1281-E456-4B24-AA86-1DDA3E4299D5 Ntext - -*/ -DELETE FROM cmsDataType WHERE nodeId NOT IN (SELECT id FROM umbracoNode) -; - -/* Need to remove any data type prevalues that aren't related to a data type */ -DELETE FROM cmsDataTypePreValues WHERE dataTypeNodeID NOT IN (SELECT nodeId FROM cmsDataType) -; - -/* Remove any domains that should not exist as they weren't deleted before when documents were deleted */ -DELETE FROM umbracoDomains WHERE domainRootStructureId NOT IN (SELECT id FROM umbracoNode) -; - --- It would be good to add constraints from cmsLanguageText to umbracoLanguage but unfortunately, a 'zero' id --- is entered into cmsLanguageText when a new entry is made, since there's not language with id of zero this won't work. --- However, we need to remove translations that aren't related to a language (these would be left over from deleting a language) -DELETE FROM cmsLanguageText -WHERE languageId <> 0 AND languageId NOT IN (SELECT id FROM umbracoLanguage) -; - -/* need to remove any content restrictions that don't exist in cmsContent */ - -DELETE FROM cmsContentTypeAllowedContentType WHERE id NOT IN (SELECT nodeId FROM cmsContentType) -; -DELETE FROM cmsContentTypeAllowedContentType WHERE Allowedid NOT IN (SELECT nodeId FROM cmsContentType) -; - -/* Though this should not have to be run because it's a new install, you need to clean the previews if you've been testing before the RC */ -DELETE FROM cmsPreviewXml WHERE VersionID NOT IN (SELECT VersionId FROM cmsContentVersion) -; - -/* Though this should not have to run because it's a new install, you need to remove this constraint if you've been testing with the RC */ -/*IF EXISTS (SELECT name FROM sysindexes WHERE name = 'IX_cmsMemberType')*/ -/*ALTER TABLE [cmsMemberType] DROP CONSTRAINT [IX_cmsMemberType]*/ - -/************************** CLEANUP END ********************************************/ - - -/* Create missing indexes and primary keys */ -CREATE NONCLUSTERED INDEX [IX_Icon] ON CMSContenttype(nodeId, Icon) -; - -ALTER TABLE cmsContentType ADD CONSTRAINT - IX_cmsContentType UNIQUE NONCLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsContent ADD CONSTRAINT - IX_cmsContent UNIQUE NONCLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsContentVersion ADD CONSTRAINT - FK_cmsContentVersion_cmsContent FOREIGN KEY - ( - ContentId - ) REFERENCES cmsContent - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsMember ADD CONSTRAINT - PK_cmsMember PRIMARY KEY CLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsMember ADD CONSTRAINT - FK_cmsMember_cmsContent FOREIGN KEY - ( - nodeId - ) REFERENCES cmsContent - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsMember ADD CONSTRAINT - FK_cmsMember_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsStylesheet ADD CONSTRAINT - PK_cmsStylesheet PRIMARY KEY CLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsStylesheetProperty ADD CONSTRAINT - PK_cmsStylesheetProperty PRIMARY KEY CLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsStylesheetProperty ADD CONSTRAINT - FK_cmsStylesheetProperty_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsStylesheet ADD CONSTRAINT - FK_cmsStylesheet_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsContentXml ADD CONSTRAINT - FK_cmsContentXml_cmsContent FOREIGN KEY - ( - nodeId - ) REFERENCES cmsContent - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsDataType ADD CONSTRAINT - IX_cmsDataType UNIQUE NONCLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - - - -ALTER TABLE cmsDataType ADD CONSTRAINT - FK_cmsDataType_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - - - -ALTER TABLE cmsDataTypePreValues ADD CONSTRAINT - FK_cmsDataTypePreValues_cmsDataType FOREIGN KEY - ( - datatypeNodeId - ) REFERENCES cmsDataType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsDocument ADD CONSTRAINT - FK_cmsDocument_cmsContent FOREIGN KEY - ( - nodeId - ) REFERENCES cmsContent - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsDocumentType ADD CONSTRAINT - FK_cmsDocumentType_cmsContentType FOREIGN KEY - ( - contentTypeNodeId - ) REFERENCES cmsContentType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsDocumentType ADD CONSTRAINT - FK_cmsDocumentType_umbracoNode FOREIGN KEY - ( - contentTypeNodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsMacroProperty ADD CONSTRAINT - FK_cmsMacroProperty_cmsMacro FOREIGN KEY - ( - macro - ) REFERENCES cmsMacro - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsMemberType ADD CONSTRAINT - FK_cmsMemberType_cmsContentType FOREIGN KEY - ( - NodeId - ) REFERENCES cmsContentType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsMemberType ADD CONSTRAINT - FK_cmsMemberType_umbracoNode FOREIGN KEY - ( - NodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsMember2MemberGroup ADD CONSTRAINT - FK_cmsMember2MemberGroup_cmsMember FOREIGN KEY - ( - Member - ) REFERENCES cmsMember - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsDocument ADD CONSTRAINT - IX_cmsDocument UNIQUE NONCLUSTERED - ( - nodeId, - versionId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsPropertyData ADD CONSTRAINT - FK_cmsPropertyData_cmsPropertyType FOREIGN KEY - ( - propertytypeid - ) REFERENCES cmsPropertyType - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsPropertyType ADD CONSTRAINT - FK_cmsPropertyType_cmsContentType FOREIGN KEY - ( - contentTypeId - ) REFERENCES cmsContentType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsPropertyType ADD CONSTRAINT - FK_cmsPropertyType_cmsDataType FOREIGN KEY - ( - dataTypeId - ) REFERENCES cmsDataType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsTab ADD CONSTRAINT - FK_cmsTab_cmsContentType FOREIGN KEY - ( - contenttypeNodeId - ) REFERENCES cmsContentType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsTemplate ADD CONSTRAINT - IX_cmsTemplate UNIQUE NONCLUSTERED - ( - nodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsDocument ADD CONSTRAINT - FK_cmsDocument_cmsTemplate FOREIGN KEY - ( - templateId - ) REFERENCES cmsTemplate - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - - -ALTER TABLE umbracoDomains ADD CONSTRAINT - FK_umbracoDomains_umbracoNode FOREIGN KEY - ( - domainRootStructureID - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsDictionary ADD CONSTRAINT - IX_cmsDictionary UNIQUE NONCLUSTERED - ( - id - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsLanguageText ADD CONSTRAINT - FK_cmsLanguageText_cmsDictionary FOREIGN KEY - ( - UniqueId - ) REFERENCES cmsDictionary - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - - - -ALTER TABLE umbracoUser2NodeNotify ADD CONSTRAINT - FK_umbracoUser2NodeNotify_umbracoUser FOREIGN KEY - ( - userId - ) REFERENCES umbracoUser - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE umbracoUser2NodeNotify ADD CONSTRAINT - FK_umbracoUser2NodeNotify_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE umbracoUser2NodePermission ADD CONSTRAINT - FK_umbracoUser2NodePermission_umbracoUser FOREIGN KEY - ( - userId - ) REFERENCES umbracoUser - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE umbracoUser2NodePermission ADD CONSTRAINT - FK_umbracoUser2NodePermission_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsTask ADD CONSTRAINT - FK_cmsTask_umbracoUser FOREIGN KEY - ( - parentUserId - ) REFERENCES umbracoUser - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsTask ADD CONSTRAINT - FK_cmsTask_umbracoUser1 FOREIGN KEY - ( - userId - ) REFERENCES umbracoUser - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsTask ADD CONSTRAINT - FK_cmsTask_umbracoNode FOREIGN KEY - ( - nodeId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -CREATE NONCLUSTERED INDEX IX_umbracoLog ON umbracoLog - ( - NodeId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE umbracoRelation ADD CONSTRAINT - FK_umbracoRelation_umbracoRelationType FOREIGN KEY - ( - relType - ) REFERENCES umbracoRelationType - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE umbracoRelation ADD CONSTRAINT - FK_umbracoRelation_umbracoNode FOREIGN KEY - ( - parentId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE umbracoRelation ADD CONSTRAINT - FK_umbracoRelation_umbracoNode1 FOREIGN KEY - ( - childId - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - - - -ALTER TABLE cmsContentTypeAllowedContentType ADD CONSTRAINT - FK_cmsContentTypeAllowedContentType_cmsContentType FOREIGN KEY - ( - Id - ) REFERENCES cmsContentType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsContentTypeAllowedContentType ADD CONSTRAINT - FK_cmsContentTypeAllowedContentType_cmsContentType1 FOREIGN KEY - ( - AllowedId - ) REFERENCES cmsContentType - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE umbracoLanguage ADD CONSTRAINT - IX_umbracoLanguage UNIQUE NONCLUSTERED - ( - languageISOCode - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE umbracoUser ADD CONSTRAINT - IX_umbracoUser UNIQUE NONCLUSTERED - ( - userLogin - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsTaskType ADD CONSTRAINT - IX_cmsTaskType UNIQUE NONCLUSTERED - ( - alias - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsDocumentType ADD CONSTRAINT - FK_cmsDocumentType_cmsTemplate FOREIGN KEY - ( - templateNodeId - ) REFERENCES cmsTemplate - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsTemplate ADD CONSTRAINT - FK_cmsTemplate_cmsTemplate FOREIGN KEY - ( - master - ) REFERENCES cmsTemplate - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsContentVersion ADD CONSTRAINT - IX_cmsContentVersion UNIQUE NONCLUSTERED - ( - VersionId - ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) -; - -ALTER TABLE cmsPreviewXml ADD CONSTRAINT - FK_cmsPreviewXml_cmsContentVersion FOREIGN KEY - ( - versionId - ) REFERENCES cmsContentVersion - ( - VersionId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - -ALTER TABLE cmsPreviewXml ADD CONSTRAINT - FK_cmsPreviewXml_cmsContent FOREIGN KEY - ( - nodeId - ) REFERENCES cmsContent - ( - nodeId - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - - -ALTER TABLE cmsMember2MemberGroup ADD CONSTRAINT - FK_cmsMember2MemberGroup_umbracoNode FOREIGN KEY - ( - MemberGroup - ) REFERENCES umbracoNode - ( - id - ) ON UPDATE NO ACTION - ON DELETE NO ACTION -; - - -/*********************************************************************************************************************** - -END OF NEW CONSTRAINTS - -***********************************************************************************************************************/ diff --git a/src/Umbraco.Tests/Models/MediaXmlTest.cs b/src/Umbraco.Tests/Models/MediaXmlTest.cs index 92fd58d23c..20c86d127f 100644 --- a/src/Umbraco.Tests/Models/MediaXmlTest.cs +++ b/src/Umbraco.Tests/Models/MediaXmlTest.cs @@ -8,7 +8,6 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Configuration.Models; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; @@ -36,7 +35,7 @@ namespace Umbraco.Tests.Models var contentSettings = new ContentSettings(); var mediaFileSystem = new MediaFileSystem(Mock.Of(), scheme, loggerFactory.CreateLogger(), ShortStringHelper); - var ignored = new FileUploadPropertyEditor(loggerFactory, mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties); + var ignored = new FileUploadPropertyEditor(loggerFactory, mediaFileSystem, Microsoft.Extensions.Options.Options.Create(contentSettings), DataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties, JsonNetSerializer); var media = MockedMedia.CreateMediaImage(mediaType, -1); media.WriterId = -1; // else it's zero and that's not a user and it breaks the tests diff --git a/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs b/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs index b48e3230f6..0383eb6ef8 100644 --- a/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs +++ b/src/Umbraco.Tests/Packaging/PackageDataInstallationTests.cs @@ -15,6 +15,7 @@ using Umbraco.Core.Models.Packaging; using Umbraco.Core.Packaging; using Umbraco.Core.Persistence.Dtos; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.Services; @@ -34,7 +35,7 @@ namespace Umbraco.Tests.Packaging public class Editor1 : DataEditor { public Editor1(ILoggerFactory loggerFactory) - : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()) + : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()) { } } @@ -44,7 +45,7 @@ namespace Umbraco.Tests.Packaging public class Editor2 : DataEditor { public Editor2(ILoggerFactory loggerFactory) - : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(),Mock.Of()) + : base(loggerFactory, Mock.Of(), Mock.Of(), Mock.Of(),Mock.Of(), new JsonNetSerializer()) { } } diff --git a/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs b/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs index 51d077d89f..2d238c9057 100644 --- a/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs +++ b/src/Umbraco.Tests/Packaging/PackageInstallationTest.cs @@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; -using Umbraco.Core; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Hosting; using Umbraco.Core.Models.Packaging; @@ -19,7 +18,6 @@ using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; -using File = System.IO.File; namespace Umbraco.Tests.Packaging { @@ -62,7 +60,9 @@ namespace Umbraco.Tests.Packaging Factory.GetRequiredService(), Microsoft.Extensions.Options.Options.Create(new GlobalSettings()), Factory.GetRequiredService(), - Factory.GetRequiredService()); + Factory.GetRequiredService(), + Factory.GetRequiredService() + ); private IPackageInstallation PackageInstallation => new PackageInstallation( PackageDataInstallation, diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs index 8e5250499c..2297f5cf5b 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs @@ -2,14 +2,11 @@ using System; using System.Collections.Generic; using System.Data; using System.Linq; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Events; using Umbraco.Core.Hosting; @@ -19,20 +16,20 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Services.Changes; using Umbraco.Core.Strings; +using Umbraco.Net; using Umbraco.Tests.Common; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing.Objects; using Umbraco.Web; using Umbraco.Web.Cache; +using Umbraco.Web.Composing; using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache.NuCache; using Umbraco.Web.PublishedCache.NuCache.DataSource; -using Current = Umbraco.Web.Composing.Current; -using Umbraco.Core.Serialization; -using Umbraco.Net; using Umbraco.Infrastructure.PublishedCache.Persistence; namespace Umbraco.Tests.PublishedContent @@ -71,7 +68,7 @@ namespace Umbraco.Tests.PublishedContent var serializer = new ConfigurationEditorJsonSerializer(); // create data types, property types and content types - var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 3 }; + var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 3 }; var dataTypes = new[] { diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs index bc87967780..e11ccc9612 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs @@ -2,13 +2,10 @@ using System; using System.Collections.Generic; using System.Data; using System.Linq; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Events; using Umbraco.Core.Logging; @@ -27,10 +24,10 @@ using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing.Objects; using Umbraco.Web; using Umbraco.Web.Cache; +using Umbraco.Web.Composing; using Umbraco.Web.PublishedCache; using Umbraco.Web.PublishedCache.NuCache; using Umbraco.Web.PublishedCache.NuCache.DataSource; -using Current = Umbraco.Web.Composing.Current; namespace Umbraco.Tests.PublishedContent { @@ -120,7 +117,7 @@ namespace Umbraco.Tests.PublishedContent var serializer = new ConfigurationEditorJsonSerializer(); // create data types, property types and content types - var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 3 }; + var dataType = new DataType(new VoidEditor("Editor", NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 3 }; var dataTypes = new[] { diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs index 37cc8911b1..7cc5bae403 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs @@ -5,8 +5,6 @@ using System.Linq; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; -using Umbraco.Web.Composing; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -14,9 +12,7 @@ using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; -using Umbraco.Tests.Testing; using Umbraco.Web; -using PublishedContentExtensions = Umbraco.Web.PublishedContentExtensions; namespace Umbraco.Tests.PublishedContent { @@ -130,7 +126,7 @@ namespace Umbraco.Tests.PublishedContent { var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 1 }); + new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); var contentTypeAlias = createChildren ? "Parent" : "Child"; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs index 75983ba41a..e4b3721892 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentSnapshotTestBase.cs @@ -7,23 +7,22 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using Umbraco.Core; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Web; -using Umbraco.Web.PublishedCache; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Models; +using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Tests.TestHelpers; -using Current = Umbraco.Web.Composing.Current; using Umbraco.Tests.Common; -using Umbraco.Core.Security; +using Umbraco.Tests.TestHelpers; +using Umbraco.Web; +using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.PublishedContent { @@ -90,7 +89,7 @@ namespace Umbraco.Tests.PublishedContent { var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of()), serializer) { Id = 1 }); + new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); var caches = new SolidPublishedSnapshot(); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs index b55609858b..aa8fc26bd8 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTestBase.cs @@ -1,25 +1,23 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using Umbraco.Core; +using Moq; +using Umbraco.Core.IO; +using Umbraco.Core.Media; +using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; using Umbraco.Core.PropertyEditors.ValueConverters; -using Umbraco.Tests.TestHelpers; -using Moq; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Core.Models; -using Umbraco.Web.PropertyEditors; -using Umbraco.Core.Services; -using Umbraco.Web; -using Umbraco.Web.Templates; -using Umbraco.Web.Routing; -using Umbraco.Core.Media; -using System; -using Microsoft.Extensions.DependencyInjection; using Umbraco.Core.Security; using Umbraco.Core.Serialization; +using Umbraco.Core.Services; +using Umbraco.Tests.TestHelpers; +using Umbraco.Web; +using Umbraco.Web.PropertyEditors; +using Umbraco.Web.Routing; +using Umbraco.Web.Templates; namespace Umbraco.Tests.PublishedContent { @@ -67,7 +65,8 @@ namespace Umbraco.Tests.PublishedContent ShortStringHelper, IOHelper, LocalizedTextService, - Mock.Of()), + Mock.Of(), + new JsonNetSerializer()), serializer) { Id = 1 }); diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs index 2170da2f75..797b1c2be9 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentTests.cs @@ -5,31 +5,31 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors; -using Umbraco.Web; -using Umbraco.Web.PublishedCache; -using Moq; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; +using Umbraco.Core.Media; using Umbraco.Core.Models; +using Umbraco.Core.Models.PublishedContent; +using Umbraco.Core.PropertyEditors; +using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.Testing; +using Umbraco.Web; +using Umbraco.Web.Composing; using Umbraco.Web.Models.PublishedContent; using Umbraco.Web.PropertyEditors; -using Umbraco.Web.Templates; +using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; -using Current = Umbraco.Web.Composing.Current; -using Umbraco.Core.Media; -using Umbraco.Core.Security; -using Umbraco.Core.Serialization; +using Umbraco.Web.Templates; namespace Umbraco.Tests.PublishedContent { @@ -64,12 +64,12 @@ namespace Umbraco.Tests.PublishedContent var localizationService = Mock.Of(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(loggerFactory, Mock.Of(), localizationService, LocalizedTextService, ShortStringHelper), serializer) { Id = 1 }, - new DataType(new TrueFalsePropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1001 }, - new DataType(new RichTextPropertyEditor(loggerFactory,backOfficeSecurityAccessor, Mock.Of(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of()), serializer) { Id = 1002 }, - new DataType(new IntegerPropertyEditor(loggerFactory, Mock.Of(), localizationService, ShortStringHelper, LocalizedTextService), serializer) { Id = 1003 }, - new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1004 }, - new DataType(new MediaPickerPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService), serializer) { Id = 1005 }); + new DataType(new VoidEditor(loggerFactory, Mock.Of(), localizationService, LocalizedTextService, ShortStringHelper, JsonNetSerializer), serializer) { Id = 1 }, + new DataType(new TrueFalsePropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1001 }, + new DataType(new RichTextPropertyEditor(loggerFactory,backOfficeSecurityAccessor, Mock.Of(), localizationService, imageSourceParser, linkParser, pastedImages, ShortStringHelper, IOHelper, LocalizedTextService, Mock.Of(), JsonNetSerializer), serializer) { Id = 1002 }, + new DataType(new IntegerPropertyEditor(loggerFactory, Mock.Of(), localizationService, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1003 }, + new DataType(new TextboxPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1004 }, + new DataType(new MediaPickerPropertyEditor(loggerFactory, Mock.Of(), localizationService, IOHelper, ShortStringHelper, LocalizedTextService, JsonNetSerializer), serializer) { Id = 1005 }); Builder.Services.AddUnique(f => dataTypeService); } diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs index 6bdca6f0f6..58b6ea7c4d 100644 --- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs @@ -5,13 +5,13 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using Umbraco.Core; using Umbraco.Core.Cache; -using Umbraco.Web.Composing; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; +using Umbraco.Web.Composing; using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.PublishedContent @@ -415,7 +415,7 @@ namespace Umbraco.Tests.PublishedContent var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeServiceMock = new Mock(); var dataType = new DataType(new VoidEditor(NullLoggerFactory.Instance, dataTypeServiceMock.Object, - Mock.Of(), Mock.Of(), Mock.Of()), serializer) + Mock.Of(), Mock.Of(), Mock.Of(), new JsonNetSerializer()), serializer) { Id = 666 }; dataTypeServiceMock.Setup(x => x.GetAll()).Returns(dataType.Yield); diff --git a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs index 84d0ea17f6..047b7205bf 100644 --- a/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs +++ b/src/Umbraco.Tests/Routing/MediaUrlProviderTests.cs @@ -39,8 +39,8 @@ namespace Umbraco.Tests.Routing var dataTypeService = Mock.Of(); var propertyEditors = new MediaUrlGeneratorCollection(new IMediaUrlGenerator[] { - new FileUploadPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties), - new ImageCropperPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, UploadAutoFillProperties), + new FileUploadPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, LocalizedTextService, ShortStringHelper, UploadAutoFillProperties, JsonNetSerializer), + new ImageCropperPropertyEditor(loggerFactory, mediaFileSystemMock, Microsoft.Extensions.Options.Options.Create(contentSettings), dataTypeService, LocalizationService, IOHelper, ShortStringHelper, LocalizedTextService, UploadAutoFillProperties, JsonNetSerializer), }); _mediaUrlProvider = new DefaultMediaUrlProvider(propertyEditors, UriUtility); } diff --git a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs index fc3b0d6dba..23df962238 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs @@ -43,7 +43,7 @@ namespace Umbraco.Tests.TestHelpers var logger = new ProfilingLogger(Mock.Of>(), Mock.Of()); var typeFinder = TestHelper.GetTypeFinder(); var typeLoader = new TypeLoader(typeFinder, NoAppCache.Instance, - new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), + new DirectoryInfo(ioHelper.MapPath(Constants.SystemDirectories.TempData)), Mock.Of>(), logger, false); diff --git a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs index c6587f6ad8..cab74e22e4 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseWebTest.cs @@ -7,9 +7,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; -using Umbraco.Core.Configuration.UmbracoSettings; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; @@ -18,7 +16,6 @@ using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Tests.Common; -using Umbraco.Tests.Common.Builders; using Umbraco.Tests.PublishedContent; using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Web; @@ -50,7 +47,7 @@ namespace Umbraco.Tests.TestHelpers var serializer = new ConfigurationEditorJsonSerializer(); var dataTypeService = new TestObjects.TestDataTypeService( - new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of()), serializer) { Id = 1 }); + new DataType(new VoidEditor(NullLoggerFactory.Instance, Mock.Of(), Mock.Of(),Mock.Of(), Mock.Of(), JsonNetSerializer), serializer) { Id = 1 }); var factory = new PublishedContentTypeFactory(Mock.Of(), new PropertyValueConverterCollection(Array.Empty()), dataTypeService); var type = new AutoPublishedContentType(Guid.NewGuid(), 0, "anything", new PublishedPropertyType[] { }); diff --git a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs index faf387528d..8c7b9a00e2 100644 --- a/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs +++ b/src/Umbraco.Tests/TestHelpers/TestWithDatabaseBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Configuration; using System.Data.SqlServerCe; using System.Threading; @@ -91,7 +91,6 @@ namespace Umbraco.Tests.TestHelpers var lazyMappers = new Lazy(f.GetRequiredService); var factory = new UmbracoDatabaseFactory(f.GetRequiredService>(), f.GetRequiredService(), GetDbConnectionString(), GetDbProviderName(), lazyMappers, TestHelper.DbProviderFactoryCreator); - factory.ResetForTests(); return factory; }); } diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index a3d48e3592..288a309374 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -1,11 +1,3 @@ -using Examine; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Moq; -using NUnit.Framework; -using Serilog; using System; using System.Collections.Generic; using System.Globalization; @@ -15,6 +7,14 @@ using System.Reflection; using System.Web.Routing; using System.Web.Security; using System.Xml.Linq; +using Examine; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Moq; +using NUnit.Framework; +using Serilog; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; @@ -50,6 +50,7 @@ using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Web; using Umbraco.Web.Actions; using Umbraco.Web.AspNet; +using Umbraco.Web.Composing; using Umbraco.Web.ContentApps; using Umbraco.Web.Hosting; using Umbraco.Web.Install; @@ -63,7 +64,6 @@ using Umbraco.Web.Security.Providers; using Umbraco.Web.Services; using Umbraco.Web.Templates; using Umbraco.Web.Trees; -using Current = Umbraco.Web.Composing.Current; using FileSystems = Umbraco.Core.IO.FileSystems; using ILogger = Microsoft.Extensions.Logging.ILogger; @@ -312,6 +312,8 @@ namespace Umbraco.Tests.Testing Builder.Services.AddUnique(); Builder.Services.AddUnique(); Builder.Services.AddUnique(); + Builder.Services.AddUnique(); + Builder.Services.AddUnique(); Builder.SetCultureDictionaryFactory(); Builder.Services.AddSingleton(f => f.GetRequiredService().CreateDictionary()); // register back office sections in the order we want them rendered diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 2f9ab25d2a..2a7ada4c15 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -129,16 +129,11 @@ - - - - - @@ -160,12 +155,10 @@ - - @@ -186,27 +179,18 @@ - - - - - - - - - @@ -218,15 +202,6 @@ - - - True - True - SqlResources.resx - - - - @@ -335,11 +310,6 @@ - - ResXFileCodeGenerator - SqlResources.Designer.cs - Designer - ResXFileCodeGenerator ImportResources.Designer.cs @@ -352,10 +322,6 @@ - - - - Designer diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs index 8d6adee475..fe910fbd32 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -7,40 +7,38 @@ using System.Net.Mime; using System.Text; using System.Xml; using System.Xml.Linq; -using Microsoft.Extensions.Logging; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Umbraco.Core; +using Umbraco.Core.Configuration.Models; using Umbraco.Core.Dictionary; using Umbraco.Core.Hosting; +using Umbraco.Core.Mapping; using Umbraco.Core.Models; using Umbraco.Core.Packaging; using Umbraco.Core.PropertyEditors; using Umbraco.Core.Scoping; +using Umbraco.Core.Security; +using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; -using Umbraco.Web.Models; -using Umbraco.Web.Models.ContentEditing; -using Constants = Umbraco.Core.Constants; -using Umbraco.Core.Mapping; -using Umbraco.Core.Security; -using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.Common.Attributes; +using Umbraco.Web.Common.Authorization; using Umbraco.Web.Common.Exceptions; using Umbraco.Web.Editors; +using Umbraco.Web.Models; +using Umbraco.Web.Models.ContentEditing; using ContentType = Umbraco.Core.Models.ContentType; -using Umbraco.Core.Configuration.Models; -using Microsoft.Extensions.Options; -using Umbraco.Core.Serialization; -using Microsoft.AspNetCore.Authorization; -using Umbraco.Web.Common.Authorization; namespace Umbraco.Web.BackOffice.Controllers { /// /// An API controller used for dealing with content types /// - [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] + [PluginController(Constants.Web.Mvc.BackOfficeApiArea)] public class ContentTypeController : ContentTypeControllerBase { // TODO: Split this controller apart so that authz is consistent, currently we need to authz each action individually. @@ -65,7 +63,8 @@ namespace Umbraco.Web.BackOffice.Controllers private readonly IMacroService _macroService; private readonly IEntityService _entityService; private readonly IHostingEnvironment _hostingEnvironment; - private readonly IConfigurationEditorJsonSerializer _jsonSerializer; + private readonly IConfigurationEditorJsonSerializer _configurationEditorJsonSerializer; + private readonly IJsonSerializer _jsonSerializer; public ContentTypeController( ICultureDictionary cultureDictionary, @@ -91,7 +90,8 @@ namespace Umbraco.Web.BackOffice.Controllers IEntityService entityService, IHostingEnvironment hostingEnvironment, EditorValidatorCollection editorValidatorCollection, - IConfigurationEditorJsonSerializer jsonSerializer) + IConfigurationEditorJsonSerializer configurationEditorJsonSerializer, + IJsonSerializer jsonSerializer) : base(cultureDictionary, editorValidatorCollection, contentTypeService, @@ -119,6 +119,7 @@ namespace Umbraco.Web.BackOffice.Controllers _macroService = macroService; _entityService = entityService; _hostingEnvironment = hostingEnvironment; + _configurationEditorJsonSerializer = configurationEditorJsonSerializer; _jsonSerializer = jsonSerializer; } @@ -220,7 +221,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// Gets all user defined properties. /// /// - [Authorize(Policy = AuthorizationPolicies.TreeAccessAnyContentOrTypes)] + [Authorize(Policy = AuthorizationPolicies.TreeAccessAnyContentOrTypes)] public IEnumerable GetAllPropertyTypeAliases() { return _contentTypeService.GetAllPropertyTypeAliases(); @@ -626,8 +627,23 @@ namespace Umbraco.Web.BackOffice.Controllers return NotFound(); } - var dataInstaller = new PackageDataInstallation(_loggerFactory.CreateLogger(), _loggerFactory, _fileService, _macroService, _LocalizationService, - _dataTypeService, _entityService, _contentTypeService, _contentService, _propertyEditors, _scopeProvider, _shortStringHelper, Options.Create(_globalSettings), _localizedTextService, _jsonSerializer); + var dataInstaller = new PackageDataInstallation( + _loggerFactory.CreateLogger(), + _loggerFactory, + _fileService, + _macroService, + _LocalizationService, + _dataTypeService, + _entityService, + _contentTypeService, + _contentService, + _propertyEditors, + _scopeProvider, + _shortStringHelper, + Options.Create(_globalSettings), + _localizedTextService, + _configurationEditorJsonSerializer, + _jsonSerializer); var xd = new XmlDocument {XmlResolver = null}; xd.Load(filePath); @@ -643,7 +659,7 @@ namespace Umbraco.Web.BackOffice.Controllers } catch (Exception ex) { - _logger.LogError(ex, "Error cleaning up temporary udt file in App_Data: {File}", filePath); + _logger.LogError(ex, "Error cleaning up temporary udt file in {File}", filePath); } return Ok(); diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs index 49a20f1150..f03130b537 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs @@ -6,6 +6,7 @@ using System.Net; using System.Net.Mime; using System.Text; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -22,7 +23,6 @@ using Umbraco.Core.Media; using Umbraco.Core.Models; using Umbraco.Core.Models.ContentEditing; using Umbraco.Core.Models.Entities; -using Umbraco.Core.Models.Membership; using Umbraco.Core.Models.Validation; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Querying; @@ -32,17 +32,15 @@ using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Core.Strings; using Umbraco.Extensions; +using Umbraco.Web.BackOffice.ActionResults; +using Umbraco.Web.BackOffice.Authorization; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.BackOffice.ModelBinders; -using Umbraco.Web.BackOffice.ActionResults; using Umbraco.Web.Common.Attributes; +using Umbraco.Web.Common.Authorization; using Umbraco.Web.Common.Exceptions; using Umbraco.Web.ContentApps; using Umbraco.Web.Models.ContentEditing; -using Constants = Umbraco.Core.Constants; -using Microsoft.AspNetCore.Authorization; -using Umbraco.Web.Common.Authorization; -using Umbraco.Web.BackOffice.Authorization; namespace Umbraco.Web.BackOffice.Controllers { @@ -702,7 +700,7 @@ namespace Umbraco.Web.BackOffice.Controllers return NotFound("The passed id doesn't exist"); } var tempFiles = new PostedFiles(); - + //in case we pass a path with a folder in it, we will create it and upload media to it. if (!string.IsNullOrEmpty(path)) @@ -882,7 +880,7 @@ namespace Umbraco.Web.BackOffice.Controllers if (validatePermissions) { var requirement = new MediaPermissionsResourceRequirement(); - var authorizationResult = await _authorizationService.AuthorizeAsync(User, _mediaService.GetById(intParentId), requirement); + var authorizationResult = await _authorizationService.AuthorizeAsync(User, new MediaPermissionsResource(_mediaService.GetById(intParentId)), requirement); if (!authorizationResult.Succeeded) { throw new HttpResponseException( @@ -893,7 +891,7 @@ namespace Umbraco.Web.BackOffice.Controllers NotificationStyle.Warning))); } } - + return intParentId; } @@ -909,7 +907,7 @@ namespace Umbraco.Web.BackOffice.Controllers throw new HttpResponseException(HttpStatusCode.NotFound); } - + var toMove = _mediaService.GetById(model.Id); if (toMove == null) { @@ -957,7 +955,7 @@ namespace Umbraco.Web.BackOffice.Controllers return toMove; } - + public PagedResult GetPagedReferences(int id, string entityType, int pageNumber = 1, int pageSize = 100) { diff --git a/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs index fe4951bc2b..bee2854a7f 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs @@ -1,8 +1,14 @@ using System; +using System.IO; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using SixLabors.ImageSharp.Web.DependencyInjection; +using Umbraco.Core; +using Umbraco.Core.Configuration.Models; +using Umbraco.Core.Hosting; using Umbraco.Web.BackOffice.Middleware; +using Umbraco.Web.BackOffice.Plugins; using Umbraco.Web.BackOffice.Routing; using Umbraco.Web.Common.Security; @@ -13,6 +19,7 @@ namespace Umbraco.Extensions /// public static class BackOfficeApplicationBuilderExtensions { + app.UseUmbracoPlugins(); public static IApplicationBuilder UseUmbracoBackOffice(this IApplicationBuilder app) { // NOTE: This method will have been called after UseRouting, UseAuthentication, UseAuthorization @@ -43,6 +50,30 @@ namespace Umbraco.Extensions return app; } + public static IApplicationBuilder UseUmbracoPlugins(this IApplicationBuilder app) + { + var hostingEnvironment = app.ApplicationServices.GetRequiredService(); + var umbracoPluginSettings = app.ApplicationServices.GetRequiredService>(); + + var pluginFolder = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.AppPlugins); + + // Ensure the plugin folder exists + Directory.CreateDirectory(pluginFolder); + + var fileProvider = new UmbracoPluginPhysicalFileProvider( + pluginFolder, + umbracoPluginSettings); + + app.UseStaticFiles(new StaticFileOptions + { + FileProvider = fileProvider, + RequestPath = Constants.SystemDirectories.AppPlugins + }); + + return app; + } + + public static IApplicationBuilder UseUmbracoPreview(this IApplicationBuilder app) { // TODO: I'm unsure this middleware will execute before the endpoint, we'll have to see @@ -56,7 +87,6 @@ namespace Umbraco.Extensions return app; } - private static IApplicationBuilder UseBackOfficeUserManagerAuditing(this IApplicationBuilder app) { var auditer = app.ApplicationServices.GetRequiredService(); diff --git a/src/Umbraco.Web.BackOffice/Plugins/UmbracoPluginPhysicalFileProvider.cs b/src/Umbraco.Web.BackOffice/Plugins/UmbracoPluginPhysicalFileProvider.cs new file mode 100644 index 0000000000..42300e3b71 --- /dev/null +++ b/src/Umbraco.Web.BackOffice/Plugins/UmbracoPluginPhysicalFileProvider.cs @@ -0,0 +1,53 @@ +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.IO; +using Microsoft.Extensions.FileProviders; +using Microsoft.Extensions.FileProviders.Physical; +using Microsoft.Extensions.Options; +using Umbraco.Core; +using Umbraco.Core.Configuration.Models; + +namespace Umbraco.Web.BackOffice.Plugins +{ + /// + /// Looks up files using the on-disk file system and check file extensions are on a allow list + /// + /// + /// When the environment variable "DOTNET_USE_POLLING_FILE_WATCHER" is set to "1" or "true", calls to + /// will use . + /// + public class UmbracoPluginPhysicalFileProvider : PhysicalFileProvider, IFileProvider + { + private readonly IOptions _options; + + /// + /// Initializes a new instance of the class, at the given root directory. + /// + /// The root directory. This should be an absolute path. + /// The configuration options. + /// Specifies which files or directories are excluded. + public UmbracoPluginPhysicalFileProvider(string root, IOptions options, ExclusionFilters filters = ExclusionFilters.Sensitive) + : base(root, filters) => _options = options; + + /// + /// Locate a file at the given path by directly mapping path segments to physical directories. + /// + /// + /// The path needs to pass the and the to be found. + /// + /// A path under the root directory + /// The file information. Caller must check property. + public new IFileInfo GetFileInfo(string subpath) + { + var extension = Path.GetExtension(subpath); + var subPathInclAppPluginsFolder = Path.Combine(Constants.SystemDirectories.AppPlugins, subpath); + if (!_options.Value.BrowsableFileExtensions.Contains(extension)) + { + return new NotFoundFileInfo(subPathInclAppPluginsFolder); + } + + return base.GetFileInfo(subPathInclAppPluginsFolder); + } + } +} diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs index f67e062847..6b06db315c 100644 --- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs +++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs @@ -10,7 +10,7 @@ namespace Umbraco.Web.Common.AspNetCore { public class AspNetCoreHostingEnvironment : Core.Hosting.IHostingEnvironment { - private IOptionsMonitor _hostingSettings; + private IOptionsMonitor _hostingSettings; private readonly IWebHostEnvironment _webHostEnvironment; private string _localTempPath; @@ -27,59 +27,67 @@ namespace Umbraco.Web.Common.AspNetCore IISVersion = new Version(0, 0); // TODO not necessary IIS } + /// public bool IsHosted { get; } = true; + + /// public string SiteName { get; } + + /// public string ApplicationId { get; } + + /// public string ApplicationPhysicalPath { get; } + public string ApplicationServerAddress { get; } - //TODO how to find this, This is a server thing, not application thing. + // TODO how to find this, This is a server thing, not application thing. public string ApplicationVirtualPath => _hostingSettings.CurrentValue.ApplicationVirtualPath?.EnsureStartsWith('/') ?? "/"; + + /// public bool IsDebugMode => _hostingSettings.CurrentValue.Debug; public Version IISVersion { get; } + public string LocalTempPath { get { if (_localTempPath != null) + { return _localTempPath; + } switch (_hostingSettings.CurrentValue.LocalTempStorageLocation) { - case LocalTempStorage.AspNetTemp: - - // TODO: I don't think this is correct? but also we probably can remove AspNetTemp as an option entirely - // since this is legacy and we shouldn't use it - return _localTempPath = System.IO.Path.Combine(Path.GetTempPath(), ApplicationId, "UmbracoData"); - case LocalTempStorage.EnvironmentTemp: // environment temp is unique, we need a folder per site // use a hash // combine site name and application id - // site name is a Guid on Cloud - // application id is eg /LM/W3SVC/123456/ROOT + // site name is a Guid on Cloud + // application id is eg /LM/W3SVC/123456/ROOT // the combination is unique on one server // and, if a site moves from worker A to B and then back to A... - // hopefully it gets a new Guid or new application id? - - var hashString = SiteName + "::" + ApplicationId; - var hash = hashString.GenerateHash(); - var siteTemp = System.IO.Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", hash); + // hopefully it gets a new Guid or new application id? + string hashString = SiteName + "::" + ApplicationId; + string hash = hashString.GenerateHash(); + string siteTemp = Path.Combine(Environment.ExpandEnvironmentVariables("%temp%"), "UmbracoData", hash); return _localTempPath = siteTemp; - //case LocalTempStorage.Default: - //case LocalTempStorage.Unknown: default: - return _localTempPath = MapPathContentRoot("~/App_Data/TEMP"); + + return _localTempPath = MapPathContentRoot(Core.Constants.SystemDirectories.TempData); } } } + /// public string MapPathWebRoot(string path) => MapPath(_webHostEnvironment.WebRootPath, path); + + /// public string MapPathContentRoot(string path) => MapPath(_webHostEnvironment.ContentRootPath, path); private string MapPath(string root, string path) @@ -91,21 +99,29 @@ namespace Umbraco.Web.Common.AspNetCore // however if you are requesting a path be mapped, it should always assume the path is relative to the root, not // absolute in the file system. This error will help us find and fix improper uses, and should be removed once // all those uses have been found and fixed - if (newPath.StartsWith(root)) throw new ArgumentException("The path appears to already be fully qualified. Please remove the call to MapPath"); + if (newPath.StartsWith(root)) + { + throw new ArgumentException("The path appears to already be fully qualified. Please remove the call to MapPath"); + } return Path.Combine(root, newPath.TrimStart('~', '/', '\\')); } + /// public string ToAbsolute(string virtualPath) { if (!virtualPath.StartsWith("~/") && !virtualPath.StartsWith("/")) + { throw new InvalidOperationException($"The value {virtualPath} for parameter {nameof(virtualPath)} must start with ~/ or /"); + } // will occur if it starts with "/" if (Uri.IsWellFormedUriString(virtualPath, UriKind.Absolute)) + { return virtualPath; + } - var fullPath = ApplicationVirtualPath.EnsureEndsWith('/') + virtualPath.TrimStart('~', '/'); + string fullPath = ApplicationVirtualPath.EnsureEndsWith('/') + virtualPath.TrimStart('~', '/'); return fullPath; } diff --git a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs index f346e0dd79..17c91d433a 100644 --- a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs @@ -18,13 +18,11 @@ using Microsoft.Extensions.Options; using Serilog; using Smidge; using Smidge.Nuglify; -using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Configuration.Models.Validation; -using Umbraco.Core.DependencyInjection; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; @@ -53,13 +51,20 @@ namespace Umbraco.Core.DependencyInjection IConfiguration config) { if (services is null) + { throw new ArgumentNullException(nameof(services)); + } + if (config is null) + { throw new ArgumentNullException(nameof(config)); + } - var loggingConfig = new LoggingConfiguration(Path.Combine(webHostEnvironment.ContentRootPath, "umbraco", "logs")); + IHostingEnvironment tempHostingEnvironment = GetTemporaryHostingEnvironment(webHostEnvironment, config); + + var loggingDir = tempHostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.LogFiles); + var loggingConfig = new LoggingConfiguration(loggingDir); - var tempHostingEnvironment = GetTemporaryHostingEnvironment(webHostEnvironment, config); services.AddLogger(tempHostingEnvironment, loggingConfig, config); IHttpContextAccessor httpContextAccessor = new HttpContextAccessor(); @@ -69,11 +74,11 @@ namespace Umbraco.Core.DependencyInjection var appCaches = AppCaches.Create(requestCache); services.AddUnique(appCaches); - var profiler = GetWebProfiler(config); + IProfiler profiler = GetWebProfiler(config); services.AddUnique(profiler); - var loggerFactory = LoggerFactory.Create(cfg => cfg.AddSerilog(Log.Logger, false)); - var typeLoader = services.AddTypeLoader(Assembly.GetEntryAssembly(), webHostEnvironment, tempHostingEnvironment, loggerFactory, appCaches, config, profiler); + ILoggerFactory loggerFactory = LoggerFactory.Create(cfg => cfg.AddSerilog(Log.Logger, false)); + TypeLoader typeLoader = services.AddTypeLoader(Assembly.GetEntryAssembly(), webHostEnvironment, tempHostingEnvironment, loggerFactory, appCaches, config, profiler); return new UmbracoBuilder(services, config, typeLoader, loggerFactory); } @@ -188,6 +193,7 @@ namespace Umbraco.Core.DependencyInjection builder.Services.Configure(builder.Config.GetSection(Core.Constants.Configuration.ConfigTypeFinder)); builder.Services.Configure(builder.Config.GetSection(Core.Constants.Configuration.ConfigUserPassword)); builder.Services.Configure(builder.Config.GetSection(Core.Constants.Configuration.ConfigWebRouting)); + builder.Services.Configure(builder.Config.GetSection(Core.Constants.Configuration.ConfigPlugins)); return builder; } diff --git a/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js b/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js index d87ca43452..44ff1d1cdf 100644 --- a/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js +++ b/src/Umbraco.Web.UI.Client/src/preview/preview.controller.js @@ -239,9 +239,10 @@ var app = angular.module("umbraco.preview", ['umbraco.resources', 'umbraco.servi // Ask to re-enter preview mode? const localizeVarsFallback = { - "returnToPreviewHeadline": "Preview content?", - "returnToPreviewDescription":"You have ended preview mode, do you want to continue previewing this content?", - "returnToPreviewButton":"Preview" + "returnToPreviewHeadline": "Preview website?", + "returnToPreviewDescription":"You have ended preview mode, do you want to enable it again to view the latest saved version of your website?", + "returnToPreviewAcceptButton":"Preview latest version", + "returnToPreviewDeclineButton":"View published version" }; const umbLocalizedVars = Object.assign(localizeVarsFallback, $window.umbLocalizedVars); @@ -344,10 +345,20 @@ var app = angular.module("umbraco.preview", ['umbraco.resources', 'umbraco.servi
${umbLocalizedVars.returnToPreviewDescription}
`; con.appendChild(modal); + var declineButton = document.createElement("button"); + declineButton.type = "button"; + declineButton.innerHTML = umbLocalizedVars.returnToPreviewDeclineButton; + declineButton.addEventListener("click", () => { + bodyEl.removeChild(fragment); + $scope.exitPreview(); + hasPreviewDialog = false; + }); + modal.appendChild(declineButton); + var continueButton = document.createElement("button"); continueButton.type = "button"; continueButton.className = "umbraco-preview-dialog__continue"; - continueButton.innerHTML = umbLocalizedVars.returnToPreviewButton; + continueButton.innerHTML = umbLocalizedVars.returnToPreviewAcceptButton; continueButton.addEventListener("click", () => { bodyEl.removeChild(fragment); reenterPreviewMode(); diff --git a/src/Umbraco.Web.UI.NetCore/Startup.cs b/src/Umbraco.Web.UI.NetCore/Startup.cs index 6b57c8af9d..d16015101d 100644 --- a/src/Umbraco.Web.UI.NetCore/Startup.cs +++ b/src/Umbraco.Web.UI.NetCore/Startup.cs @@ -4,8 +4,8 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Umbraco.Extensions; using Umbraco.Core.DependencyInjection; +using Umbraco.Extensions; namespace Umbraco.Web.UI.NetCore { @@ -28,11 +28,14 @@ namespace Umbraco.Web.UI.NetCore _config = config ?? throw new ArgumentNullException(nameof(config)); } - // This method gets called by the runtime. Use this method to add services to the container. - // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + /// /// Configures the services /// + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 + /// public void ConfigureServices(IServiceCollection services) { #pragma warning disable IDE0022 // Use expression body for methods diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json index 43ae07d5d6..44d148acdc 100644 --- a/src/Umbraco.Web.UI.NetCore/appsettings.json +++ b/src/Umbraco.Web.UI.NetCore/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "umbracoDbDSN": "Server=(LocalDB)\\Umbraco;Database=NetCore;Integrated Security=true" + "umbracoDbDSN": "" }, "Serilog": { "MinimumLevel": { @@ -39,7 +39,7 @@ }, "RuntimeMinification": { "dataFolder": "App_Data/TEMP/Smidge", - "version": "637429346786793415" + "version": "637432008251409860" }, "Security": { "KeepUserLoggedIn": false, @@ -71,4 +71,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Web.UI.NetCore/umbraco/UmbracoBackOffice/Preview.cshtml b/src/Umbraco.Web.UI.NetCore/umbraco/UmbracoBackOffice/Preview.cshtml index bc72c1649b..382e0acce2 100644 --- a/src/Umbraco.Web.UI.NetCore/umbraco/UmbracoBackOffice/Preview.cshtml +++ b/src/Umbraco.Web.UI.NetCore/umbraco/UmbracoBackOffice/Preview.cshtml @@ -28,7 +28,8 @@ var OpenWebsiteTitle = LocalizedTextService.Localize("preview", "openWebsiteTitle"); var returnToPreviewHeadline = LocalizedTextService.Localize("preview", "returnToPreviewHeadline"); var returnToPreviewDescription = LocalizedTextService.Localize("preview", "returnToPreviewDescription"); - var returnToPreviewButton = LocalizedTextService.Localize("preview", "returnToPreviewButton"); + var returnToPreviewAcceptButton = LocalizedTextService.Localize("preview", "returnToPreviewAcceptButton"); + var returnToPreviewDeclineButton = LocalizedTextService.Localize("preview", "returnToPreviewDeclineButton"); } @@ -44,7 +45,8 @@ window.umbLocalizedVars = { 'returnToPreviewHeadline': '@returnToPreviewHeadline', 'returnToPreviewDescription':'@returnToPreviewDescription', - 'returnToPreviewButton':'@returnToPreviewButton' + 'returnToPreviewAcceptButton':'@returnToPreviewAcceptButton', + 'returnToPreviewDeclineButton':'@returnToPreviewDeclineButton' }; diff --git a/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml b/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml index 857129b1c1..b6d10589fe 100644 --- a/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml +++ b/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/da.xml @@ -1439,7 +1439,7 @@ Mange hilsner fra Umbraco robotten Dette benyttes ikke for en Element-type Du har lavet ændringer til denne egenskab. Er du sikker på at du vil kassere dem? Visning - Flyt label over editoren + Label hen over (fuld brede) Tilføj sprog @@ -1873,8 +1873,9 @@ Mange hilsner fra Umbraco robotten Vis i nyt vindue Åben forhåndsvisning i nyt vindue Forhåndsvisning af indholdet? - Du har afslutet forhåndsvisning, vil du se dette indhold i forhåndsvisning? - Fortsæt + Du har afslutet forhåndsvisning, vil du starte forhåndsvisning igen for at se seneste gemte version af indholdet? + Start forhåndsvisning + Se udgivet indhold Se udgivet indhold? Du er i forhåndsvisning, vil du afslutte for at se den udgivet version? Se udgivet version diff --git a/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en.xml b/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en.xml index 6916b00e1c..1a1bf8f840 100644 --- a/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en.xml +++ b/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en.xml @@ -1699,7 +1699,7 @@ To manage your website, simply open the Umbraco back office and start adding con This is not applicable for an Element type You have made changes to this property. Are you sure you want to discard them? Appearance - Display label on top of editor. + Label above (full-width) Add language @@ -2536,9 +2536,10 @@ To manage your website, simply open the Umbraco back office and start adding con End preview mode Preview website Open website in preview mode - Preview content? - You have ended preview mode, do you want to continue previewing this content? - Preview + Preview website? + ou have ended preview mode, do you want to enable it again to view the latest saved version of your website? + Preview latest version + View published version View published version? You are in Preview Mode, do you want exit in order to view the published version of your website? View published version diff --git a/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en_us.xml b/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en_us.xml index cacb8288b3..0bbba93c89 100644 --- a/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en_us.xml +++ b/src/Umbraco.Web.UI.NetCore/umbraco/config/lang/en_us.xml @@ -1717,7 +1717,7 @@ To manage your website, simply open the Umbraco back office and start adding con This is not applicable for an element type You have made changes to this property. Are you sure you want to discard them? Appearance - Display label on top of editor. + Label above (full-width) Add language @@ -2556,9 +2556,10 @@ To manage your website, simply open the Umbraco back office and start adding con End preview mode Preview website Open website in preview mode - Preview content? - You have ended preview mode, do you want to continue previewing this content? - Preview + Preview website? + ou have ended preview mode, do you want to enable it again to view the latest saved version of your website? + Preview latest version + View published version View published version? You are in Preview Mode, do you want exit in order to view the published version of your website? View published version diff --git a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs index cc8fc975d2..ec9d66859e 100644 --- a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs +++ b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs @@ -11,6 +11,7 @@ using Umbraco.Core.Hosting; namespace Umbraco.Web.Hosting { + // TODO: This has been migrated to netcore public class AspNetHostingEnvironment : IHostingEnvironment { @@ -67,9 +68,6 @@ namespace Umbraco.Web.Hosting switch (_hostingSettings.LocalTempStorageLocation) { - case LocalTempStorage.AspNetTemp: - return _localTempPath = System.IO.Path.Combine(HttpRuntime.CodegenDir, "UmbracoData"); - case LocalTempStorage.EnvironmentTemp: // environment temp is unique, we need a folder per site @@ -88,10 +86,8 @@ namespace Umbraco.Web.Hosting return _localTempPath = siteTemp; - //case LocalTempStorage.Default: - //case LocalTempStorage.Unknown: default: - return _localTempPath = MapPathContentRoot("~/App_Data/TEMP"); + return _localTempPath = MapPathContentRoot(Constants.SystemDirectories.TempData); } } } diff --git a/src/Umbraco.Web/Macros/PartialViewMacroPage.cs b/src/Umbraco.Web/Macros/PartialViewMacroPage.cs deleted file mode 100644 index 7297fec6d3..0000000000 --- a/src/Umbraco.Web/Macros/PartialViewMacroPage.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Umbraco.Web.Models; -using Umbraco.Web.Mvc; - -namespace Umbraco.Web.Macros -{ - /// - /// The base view class that PartialViewMacro views need to inherit from - /// - public abstract class PartialViewMacroPage : UmbracoViewPage - { } -} diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 758839314b..b84a003813 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -203,7 +203,6 @@ -