Merge branch 'temp8' of https://github.com/umbraco/Umbraco-CMS into temp8
This commit is contained in:
@@ -15,31 +15,35 @@
|
||||
<language>en-US</language>
|
||||
<tags>umbraco</tags>
|
||||
<dependencies>
|
||||
<!--
|
||||
note: dependencies are specified as [x.y.z,x.999999) eg [2.1.0,2.999999) and NOT [2.1.0,3.0.0) because
|
||||
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="AutoMapper" version="[7.0.1,7.999999)" />
|
||||
<dependency id="LightInject" version="[5.1.2,5.999999)" />
|
||||
<dependency id="LightInject.Annotation" version="[1.1.0,1.999999)" />
|
||||
<dependency id="LightInject.Web" version="[2.0.0,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.Identity.Core" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Client" version="[5.2.6,5.999999)" />
|
||||
<dependency id="Microsoft.Owin" version="[4.0.0,4.999999)" />
|
||||
<dependency id="MiniProfiler" version="[3.2.0.157,3.999999)" />
|
||||
<dependency id="Newtonsoft.Json" version="[11.0.2,11.999999)" />
|
||||
<dependency id="Semver" version="[2.0.4,2.999999)" />
|
||||
<dependency id="Serilog" version="[2.7.1,2.999999)" />
|
||||
<dependency id="Serilog.Enrichers.Process" version="[2.0.1,2.999999)" />
|
||||
<dependency id="Serilog.Enrichers.Thread" version="[3.0.0,3.999999)" />
|
||||
<dependency id="Serilog.Filters.Expressions" version="[2.0.0,2.999999)" />
|
||||
<dependency id="Serilog.Formatting.Compact" version="[1.0.0,1.999999)" />
|
||||
<dependency id="Serilog.Formatting.Compact.Reader" version="[1.0.2,1.999999)" />
|
||||
<dependency id="Serilog.Settings.AppSettings" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Serilog.Sinks.File" version="[4.0.0,4.999999)" />
|
||||
<dependency id="Umbraco.SqlServerCE" version="[4.0.0.1,4.999999)" />
|
||||
<dependency id="NPoco" version="[3.9.4,3.999999)" />
|
||||
|
||||
<group targetFramework="net472">
|
||||
<!--
|
||||
note: dependencies are specified as [x.y.z,x.999999) eg [2.1.0,2.999999) and NOT [2.1.0,3.0.0) because
|
||||
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="AutoMapper" version="[8.0.0,8.999999)" />
|
||||
<dependency id="LightInject" version="[5.4.0,5.999999)" />
|
||||
<dependency id="LightInject.Annotation" version="[1.1.0,1.999999)" />
|
||||
<dependency id="LightInject.Web" version="[2.0.0,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.Identity.Core" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi.Client" version="[5.2.7,5.999999)" />
|
||||
<dependency id="Microsoft.Owin" version="[4.0.1,4.999999)" />
|
||||
<dependency id="MiniProfiler" version="[4.0.138,4.999999)" />
|
||||
<dependency id="Newtonsoft.Json" version="[12.0.1,12.999999)" />
|
||||
<dependency id="Semver" version="[2.0.4,2.999999)" />
|
||||
<dependency id="Serilog" version="[2.8.0,2.999999)" />
|
||||
<dependency id="Serilog.Enrichers.Process" version="[2.0.1,2.999999)" />
|
||||
<dependency id="Serilog.Enrichers.Thread" version="[3.0.0,3.999999)" />
|
||||
<dependency id="Serilog.Filters.Expressions" version="[2.0.0,2.999999)" />
|
||||
<dependency id="Serilog.Formatting.Compact" version="[1.0.0,1.999999)" />
|
||||
<dependency id="Serilog.Formatting.Compact.Reader" version="[1.0.3,1.999999)" />
|
||||
<dependency id="Serilog.Settings.AppSettings" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Serilog.Sinks.File" version="[4.0.0,4.999999)" />
|
||||
<dependency id="Umbraco.SqlServerCE" version="[4.0.0.1,4.999999)" />
|
||||
<dependency id="NPoco" version="[3.9.4,3.999999)" />
|
||||
</group>
|
||||
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
||||
@@ -15,30 +15,35 @@
|
||||
<language>en-US</language>
|
||||
<tags>umbraco</tags>
|
||||
<dependencies>
|
||||
<!--
|
||||
note: dependencies are specified as [x.y.z,x.999999) eg [2.1.0,2.999999) and NOT [2.1.0,3.0.0) because
|
||||
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="UmbracoCms.Core" version="[$version$]" />
|
||||
<dependency id="AutoMapper" version="[7.0.1,7.999999)" />
|
||||
<dependency id="ClientDependency" version="[1.9.7,1.999999)" />
|
||||
<dependency id="ClientDependency-Mvc5" version="[1.8.0,1.999999)" />
|
||||
<dependency id="CSharpTest.Net.Collections" version="[14.906.1403.1082,14.999999)" />
|
||||
<dependency id="Examine" version="[1.0.0-beta078,1.999999)" />
|
||||
<dependency id="HtmlAgilityPack" version="[1.8.9,1.999999)" />
|
||||
<dependency id="ImageProcessor" version="[2.6.2.25,2.999999)" />
|
||||
<dependency id="LightInject.Mvc" version="[2.0.0,2.999999)" />
|
||||
<dependency id="LightInject.WebApi" version="[2.0.0,2.999999)" />
|
||||
<dependency id="Markdown" version="[2.2.1,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.Identity.Owin" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.Mvc" version="[5.2.6,5.999999)" />
|
||||
<dependency id="Microsoft.AspNet.SignalR.Core" version="[2.2.3,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi" version="[5.2.6,5.999999)" />
|
||||
<dependency id="Microsoft.Owin.Host.SystemWeb" version="[4.0.0,4.999999)" />
|
||||
<dependency id="Microsoft.Owin.Security.Cookies" version="[4.0.0,4.999999)" />
|
||||
<dependency id="Microsoft.Owin.Security.OAuth" version="[4.0.0,4.999999)" />
|
||||
<dependency id="System.Threading.Tasks.Dataflow" version="[4.8.0,4.999999)" />
|
||||
|
||||
<group targetFramework="net472">
|
||||
|
||||
<!--
|
||||
note: dependencies are specified as [x.y.z,x.999999) eg [2.1.0,2.999999) and NOT [2.1.0,3.0.0) because
|
||||
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="UmbracoCms.Core" version="[$version$]" />
|
||||
<dependency id="ClientDependency" version="[1.9.7,1.999999)" />
|
||||
<dependency id="ClientDependency-Mvc5" version="[1.8.0,1.999999)" />
|
||||
<dependency id="CSharpTest.Net.Collections" version="[14.906.1403.1082,14.999999)" />
|
||||
<dependency id="Examine" version="[1.0.0-beta078,1.999999)" />
|
||||
<dependency id="HtmlAgilityPack" version="[1.8.14,1.999999)" />
|
||||
<dependency id="ImageProcessor" version="[2.6.2.25,2.999999)" />
|
||||
<dependency id="LightInject.Mvc" version="[2.0.0,2.999999)" />
|
||||
<dependency id="LightInject.WebApi" version="[2.0.0,2.999999)" />
|
||||
<dependency id="Markdown" version="[2.2.1,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.Identity.Owin" version="[2.2.2,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.Mvc" version="[5.2.7,5.999999)" />
|
||||
<dependency id="Microsoft.AspNet.SignalR.Core" version="[2.4.0,2.999999)" />
|
||||
<dependency id="Microsoft.AspNet.WebApi" version="[5.2.7,5.999999)" />
|
||||
<dependency id="Microsoft.Owin.Host.SystemWeb" version="[4.0.1,4.999999)" />
|
||||
<dependency id="Microsoft.Owin.Security.Cookies" version="[4.0.1,4.999999)" />
|
||||
<dependency id="Microsoft.Owin.Security.OAuth" version="[4.0.1,4.999999)" />
|
||||
<dependency id="System.Threading.Tasks.Dataflow" version="[4.9.0,4.999999)" />
|
||||
|
||||
</group>
|
||||
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
||||
@@ -15,18 +15,25 @@
|
||||
<language>en-US</language>
|
||||
<tags>umbraco</tags>
|
||||
<dependencies>
|
||||
<dependency id="UmbracoCms.Web" version="[$version$]" />
|
||||
<!--
|
||||
note: dependencies are specified as [x.y.z,x.999999) eg [2.1.0,2.999999) and NOT [2.1.0,3.0.0) because
|
||||
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="Microsoft.AspNet.SignalR.Core" version="[2.2.3, 2.999999)" />
|
||||
<dependency id="Umbraco.ModelsBuilder.Ui" version="[8.0.0-alpha.36]" />
|
||||
<dependency id="ImageProcessor.Web" version="[4.9.3.25,4.999999)" />
|
||||
<dependency id="ImageProcessor.Web.Config" version="[2.4.1.19,2.999999)" />
|
||||
<dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="[2.0.1,2.999999)" />
|
||||
<dependency id="Microsoft.Net.Compilers" version="[2.10.0,2.999999)" />
|
||||
|
||||
<group targetFramework="net472">
|
||||
|
||||
<dependency id="UmbracoCms.Web" version="[$version$]" />
|
||||
<!--
|
||||
note: dependencies are specified as [x.y.z,x.999999) eg [2.1.0,2.999999) and NOT [2.1.0,3.0.0) because
|
||||
the latter would pick anything below 3.0.0 and that includes prereleases such as 3.0.0-alpha, and we do
|
||||
not want this to happen as the alpha of the next major is, really, the next major already.
|
||||
-->
|
||||
<dependency id="Microsoft.AspNet.SignalR.Core" version="[2.4.0, 2.999999)" />
|
||||
<dependency id="Umbraco.ModelsBuilder.Ui" version="[8.0.0-alpha.37]" />
|
||||
<dependency id="ImageProcessor.Web" version="[4.9.3.25,4.999999)" />
|
||||
<dependency id="ImageProcessor.Web.Config" version="[2.4.1.19,2.999999)" />
|
||||
<dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="[2.0.1,2.999999)" />
|
||||
<dependency id="Microsoft.Net.Compilers" version="[2.10.0,2.999999)" />
|
||||
|
||||
</group>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Umbraco.Core.Configuration
|
||||
private static string _reservedPaths;
|
||||
private static string _reservedUrls;
|
||||
//ensure the built on (non-changeable) reserved paths are there at all times
|
||||
internal const string StaticReservedPaths = "~/app_plugins/,~/install/,"; //must end with a comma!
|
||||
internal const string StaticReservedPaths = "~/app_plugins/,~/install/,~/mini-profiler-resources/,"; //must end with a comma!
|
||||
internal const string StaticReservedUrls = "~/config/splashes/noNodes.aspx,~/.well-known,"; //must end with a comma!
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -109,10 +109,9 @@ namespace Umbraco.Core
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<Property> GetNonGroupedProperties(this IContentBase content)
|
||||
{
|
||||
var propertyIdsInTabs = content.PropertyGroups.SelectMany(pg => pg.PropertyTypes);
|
||||
return content.Properties
|
||||
.Where(property => propertyIdsInTabs.Contains(property.PropertyType) == false)
|
||||
.OrderBy(x => x.PropertyType.SortOrder);
|
||||
.Where(x => x.PropertyType.PropertyGroupId == null)
|
||||
.OrderBy(x => x.PropertyType.SortOrder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -178,8 +177,7 @@ namespace Umbraco.Core
|
||||
var property = content.Properties.FirstOrDefault(x => x.Alias.InvariantEquals(propertyTypeAlias));
|
||||
if (property != null) return property;
|
||||
|
||||
var contentTypeService = contentTypeBaseServiceProvider.For(content);
|
||||
var contentType = contentTypeService.Get(content.ContentTypeId);
|
||||
var contentType = contentTypeBaseServiceProvider.GetContentTypeOf(content);
|
||||
var propertyType = contentType.CompositionPropertyTypes
|
||||
.FirstOrDefault(x => x.Alias.InvariantEquals(propertyTypeAlias));
|
||||
if (propertyType == null)
|
||||
@@ -208,8 +206,7 @@ namespace Umbraco.Core
|
||||
/// </remarks>
|
||||
public static string StoreFile(this IContentBase content, IContentTypeBaseServiceProvider contentTypeBaseServiceProvider, string propertyTypeAlias, string filename, Stream filestream, string filepath)
|
||||
{
|
||||
var contentTypeService = contentTypeBaseServiceProvider.For(content);
|
||||
var contentType = contentTypeService.Get(content.ContentTypeId);
|
||||
var contentType = contentTypeBaseServiceProvider.GetContentTypeOf(content);
|
||||
var propertyType = contentType
|
||||
.CompositionPropertyTypes.FirstOrDefault(x => x.Alias.InvariantEquals(propertyTypeAlias));
|
||||
if (propertyType == null) throw new ArgumentException("Invalid property type alias " + propertyTypeAlias + ".");
|
||||
|
||||
@@ -1,34 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
[HostProtection(SecurityAction.LinkDemand, SharedState = true)]
|
||||
public class CancellableEnumerableObjectEventArgs<T> : CancellableObjectEventArgs<IEnumerable<T>>, IEquatable<CancellableEnumerableObjectEventArgs<T>>
|
||||
/// <summary>
|
||||
/// Represents event data, for events that support cancellation, and expose impacted objects.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEventObject">The type of the exposed, impacted objects.</typeparam>
|
||||
public class CancellableEnumerableObjectEventArgs<TEventObject> : CancellableObjectEventArgs<IEnumerable<TEventObject>>, IEquatable<CancellableEnumerableObjectEventArgs<TEventObject>>
|
||||
{
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<T> eventObject, bool canCancel, EventMessages messages, IDictionary<string, object> additionalData)
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<TEventObject> eventObject, bool canCancel, EventMessages messages, IDictionary<string, object> additionalData)
|
||||
: base(eventObject, canCancel, messages, additionalData)
|
||||
{ }
|
||||
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<T> eventObject, bool canCancel, EventMessages eventMessages)
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<TEventObject> eventObject, bool canCancel, EventMessages eventMessages)
|
||||
: base(eventObject, canCancel, eventMessages)
|
||||
{ }
|
||||
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<T> eventObject, EventMessages eventMessages)
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<TEventObject> eventObject, EventMessages eventMessages)
|
||||
: base(eventObject, eventMessages)
|
||||
{ }
|
||||
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<T> eventObject, bool canCancel)
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<TEventObject> eventObject, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{ }
|
||||
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<T> eventObject)
|
||||
public CancellableEnumerableObjectEventArgs(IEnumerable<TEventObject> eventObject)
|
||||
: base(eventObject)
|
||||
{ }
|
||||
|
||||
public bool Equals(CancellableEnumerableObjectEventArgs<T> other)
|
||||
public bool Equals(CancellableEnumerableObjectEventArgs<TEventObject> other)
|
||||
{
|
||||
if (other is null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
@@ -41,7 +43,7 @@ namespace Umbraco.Core.Events
|
||||
if (obj is null) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((CancellableEnumerableObjectEventArgs<T>)obj);
|
||||
return Equals((CancellableEnumerableObjectEventArgs<TEventObject>)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
@@ -49,4 +51,4 @@ namespace Umbraco.Core.Events
|
||||
return HashCodeHelper.GetHashCode(EventObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Security.Permissions;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Event args for that can support cancellation
|
||||
/// Represents event data for events that support cancellation.
|
||||
/// </summary>
|
||||
[HostProtection(SecurityAction.LinkDemand, SharedState = true)]
|
||||
public class CancellableEventArgs : EventArgs, IEquatable<CancellableEventArgs>
|
||||
{
|
||||
private bool _cancel;
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Permissions;
|
||||
using Umbraco.Core.Models;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Used as a base class for the generic type CancellableObjectEventArgs{T} so that we can get direct 'object' access to the underlying EventObject
|
||||
/// Provides a base class for classes representing event data, for events that support cancellation, and expose an impacted object.
|
||||
/// </summary>
|
||||
[HostProtection(SecurityAction.LinkDemand, SharedState = true)]
|
||||
public abstract class CancellableObjectEventArgs : CancellableEventArgs
|
||||
{
|
||||
protected CancellableObjectEventArgs(object eventObject, bool canCancel, EventMessages messages, IDictionary<string, object> additionalData)
|
||||
@@ -41,90 +36,11 @@ namespace Umbraco.Core.Events
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the object relating to the event
|
||||
/// Gets or sets the impacted object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is protected so that inheritors can expose it with their own name
|
||||
/// </remarks>
|
||||
internal object EventObject { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event args for a strongly typed object that can support cancellation
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
[HostProtection(SecurityAction.LinkDemand, SharedState = true)]
|
||||
public class CancellableObjectEventArgs<T> : CancellableObjectEventArgs, IEquatable<CancellableObjectEventArgs<T>>
|
||||
{
|
||||
public CancellableObjectEventArgs(T eventObject, bool canCancel, EventMessages messages, IDictionary<string, object> additionalData)
|
||||
: base(eventObject, canCancel, messages, additionalData)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(T eventObject, bool canCancel, EventMessages eventMessages)
|
||||
: base(eventObject, canCancel, eventMessages)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(T eventObject, EventMessages eventMessages)
|
||||
: base(eventObject, eventMessages)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(T eventObject, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(T eventObject)
|
||||
: base(eventObject)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the object relating to the event
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is protected so that inheritors can expose it with their own name
|
||||
/// </remarks>
|
||||
protected new T EventObject
|
||||
{
|
||||
get { return (T) base.EventObject; }
|
||||
set { base.EventObject = value; }
|
||||
}
|
||||
|
||||
public bool Equals(CancellableObjectEventArgs<T> other)
|
||||
{
|
||||
if (other is null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return base.Equals(other) && EqualityComparer<T>.Default.Equals(EventObject, other.EventObject);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is null) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((CancellableObjectEventArgs<T>)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return (base.GetHashCode() * 397) ^ EqualityComparer<T>.Default.GetHashCode(EventObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(CancellableObjectEventArgs<T> left, CancellableObjectEventArgs<T> right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(CancellableObjectEventArgs<T> left, CancellableObjectEventArgs<T> right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Represent event data, for events that support cancellation, and expose an impacted object.
|
||||
/// </summary>
|
||||
/// <typeparam name="TEventObject">The type of the exposed, impacted object.</typeparam>
|
||||
public class CancellableObjectEventArgs<TEventObject> : CancellableObjectEventArgs, IEquatable<CancellableObjectEventArgs<TEventObject>>
|
||||
{
|
||||
public CancellableObjectEventArgs(TEventObject eventObject, bool canCancel, EventMessages messages, IDictionary<string, object> additionalData)
|
||||
: base(eventObject, canCancel, messages, additionalData)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(TEventObject eventObject, bool canCancel, EventMessages eventMessages)
|
||||
: base(eventObject, canCancel, eventMessages)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(TEventObject eventObject, EventMessages eventMessages)
|
||||
: base(eventObject, eventMessages)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(TEventObject eventObject, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
}
|
||||
|
||||
public CancellableObjectEventArgs(TEventObject eventObject)
|
||||
: base(eventObject)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the impacted object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is protected so that inheritors can expose it with their own name
|
||||
/// </remarks>
|
||||
protected new TEventObject EventObject
|
||||
{
|
||||
get => (TEventObject) base.EventObject;
|
||||
set => base.EventObject = value;
|
||||
}
|
||||
|
||||
public bool Equals(CancellableObjectEventArgs<TEventObject> other)
|
||||
{
|
||||
if (other is null) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return base.Equals(other) && EqualityComparer<TEventObject>.Default.Equals(EventObject, other.EventObject);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is null) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((CancellableObjectEventArgs<TEventObject>)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return (base.GetHashCode() * 397) ^ EqualityComparer<TEventObject>.Default.GetHashCode(EventObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator ==(CancellableObjectEventArgs<TEventObject> left, CancellableObjectEventArgs<TEventObject> right)
|
||||
{
|
||||
return Equals(left, right);
|
||||
}
|
||||
|
||||
public static bool operator !=(CancellableObjectEventArgs<TEventObject> left, CancellableObjectEventArgs<TEventObject> right)
|
||||
{
|
||||
return !Equals(left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents event data for the Published event.
|
||||
/// </summary>
|
||||
public class ContentPublishedEventArgs : PublishEventArgs<IContent>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentPublishedEventArgs"/> class.
|
||||
/// </summary>
|
||||
public ContentPublishedEventArgs(IEnumerable<IContent> eventObject, bool canCancel, EventMessages eventMessages)
|
||||
: base(eventObject, canCancel, eventMessages)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a culture has been published, during a Published event.
|
||||
/// </summary>
|
||||
public bool HasPublishedCulture(IContent content, string culture)
|
||||
=> content.WasPropertyDirty("_changedCulture_" + culture);
|
||||
=> content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.ChangedCulture + culture);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a culture has been unpublished, during a Published event.
|
||||
/// </summary>
|
||||
public bool HasUnpublishedCulture(IContent content, string culture)
|
||||
=> content.WasPropertyDirty("_unpublishedCulture_" + culture);
|
||||
|
||||
|
||||
|
||||
=> content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + culture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents event data for the Publishing event.
|
||||
/// </summary>
|
||||
public class ContentPublishingEventArgs : PublishEventArgs<IContent>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ContentPublishingEventArgs"/>
|
||||
/// Initializes a new instance of the <see cref="ContentPublishingEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="eventMessages"></param>
|
||||
public ContentPublishingEventArgs(IEnumerable<IContent> eventObject, EventMessages eventMessages)
|
||||
: base(eventObject, eventMessages)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a culture is being published, during a Publishing event.
|
||||
@@ -27,7 +25,6 @@ namespace Umbraco.Core.Events
|
||||
/// Determines whether a culture is being unpublished, during a Publishing event.
|
||||
/// </summary>
|
||||
public bool IsUnpublishingCulture(IContent content, string culture)
|
||||
=> content.IsPropertyDirty("_unpublishedCulture_" + culture); //bit of a hack since we know that the content implementation tracks changes this way
|
||||
|
||||
=> content.IsPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + culture); //bit of a hack since we know that the content implementation tracks changes this way
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents event data for the Saved event.
|
||||
/// </summary>
|
||||
public class ContentSavedEventArgs : SaveEventArgs<IContent>
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ContentSavedEventArgs"/>
|
||||
/// Initializes a new instance of the <see cref="ContentSavedEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="messages"></param>
|
||||
/// <param name="additionalData"></param>
|
||||
public ContentSavedEventArgs(IEnumerable<IContent> eventObject, EventMessages messages, IDictionary<string, object> additionalData)
|
||||
: base(eventObject, false, messages, additionalData)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a culture has been saved, during a Saved event.
|
||||
/// </summary>
|
||||
public bool HasSavedCulture(IContent content, string culture)
|
||||
=> content.WasPropertyDirty("_updatedCulture_" + culture);
|
||||
=> content.WasPropertyDirty(ContentBase.ChangeTrackingPrefix.UpdatedCulture + culture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Represent event data for the Saving event.
|
||||
/// </summary>
|
||||
public class ContentSavingEventArgs : SaveEventArgs<IContent>
|
||||
{
|
||||
#region Factory Methods
|
||||
|
||||
/// <summary>
|
||||
/// Converts <see cref="ContentSavingEventArgs"/> to <see cref="ContentSavedEventArgs"/> while preserving all args state
|
||||
/// </summary>
|
||||
@@ -43,24 +46,32 @@ namespace Umbraco.Core.Events
|
||||
EventState = EventState,
|
||||
AdditionalData = AdditionalData
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ContentSavingEventArgs(IEnumerable<IContent> eventObject, EventMessages eventMessages) : base(eventObject, eventMessages)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentSavingEventArgs"/> class.
|
||||
/// </summary>
|
||||
public ContentSavingEventArgs(IEnumerable<IContent> eventObject, EventMessages eventMessages)
|
||||
: base(eventObject, eventMessages)
|
||||
{ }
|
||||
|
||||
public ContentSavingEventArgs(IContent eventObject, EventMessages eventMessages) : base(eventObject, eventMessages)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ContentSavingEventArgs"/> class.
|
||||
/// </summary>
|
||||
public ContentSavingEventArgs(IContent eventObject, EventMessages eventMessages)
|
||||
: base(eventObject, eventMessages)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether a culture is being saved, during a Saving event.
|
||||
/// </summary>
|
||||
public bool IsSavingCulture(IContent content, string culture) => content.CultureInfos.TryGetValue(culture, out var cultureInfo) && cultureInfo.IsDirty();
|
||||
public bool IsSavingCulture(IContent content, string culture)
|
||||
=> content.CultureInfos.TryGetValue(culture, out var cultureInfo) && cultureInfo.IsDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,6 @@ namespace Umbraco.Core.Models
|
||||
: base(name, parent, contentType, properties, culture)
|
||||
{
|
||||
if (contentType == null) throw new ArgumentNullException(nameof(contentType));
|
||||
ContentType = new SimpleContentType(contentType);
|
||||
_publishedState = PublishedState.Unpublished;
|
||||
PublishedVersionId = 0;
|
||||
}
|
||||
@@ -79,7 +78,6 @@ namespace Umbraco.Core.Models
|
||||
: base(name, parentId, contentType, properties, culture)
|
||||
{
|
||||
if (contentType == null) throw new ArgumentNullException(nameof(contentType));
|
||||
ContentType = new SimpleContentType(contentType);
|
||||
_publishedState = PublishedState.Unpublished;
|
||||
PublishedVersionId = 0;
|
||||
}
|
||||
@@ -172,12 +170,6 @@ namespace Umbraco.Core.Models
|
||||
[IgnoreDataMember]
|
||||
public bool Edited { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ContentType used by this content object
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
public ISimpleContentType ContentType { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public DateTime? PublishDate { get; set; } // set by persistence
|
||||
@@ -242,7 +234,7 @@ namespace Umbraco.Core.Models
|
||||
public string GetPublishName(string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) return PublishName;
|
||||
if (!ContentTypeBase.VariesByCulture()) return null;
|
||||
if (!ContentType.VariesByCulture()) return null;
|
||||
if (_publishInfos == null) return null;
|
||||
return _publishInfos.TryGetValue(culture, out var infos) ? infos.Name : null;
|
||||
}
|
||||
@@ -251,7 +243,7 @@ namespace Umbraco.Core.Models
|
||||
public DateTime? GetPublishDate(string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) return PublishDate;
|
||||
if (!ContentTypeBase.VariesByCulture()) return null;
|
||||
if (!ContentType.VariesByCulture()) return null;
|
||||
if (_publishInfos == null) return null;
|
||||
return _publishInfos.TryGetValue(culture, out var infos) ? infos.Date : (DateTime?)null;
|
||||
}
|
||||
@@ -311,13 +303,7 @@ namespace Umbraco.Core.Models
|
||||
/// <remarks>Leaves PropertyTypes intact after change</remarks>
|
||||
internal void ChangeContentType(IContentType contentType)
|
||||
{
|
||||
ContentTypeId = contentType.Id;
|
||||
ContentType = new SimpleContentType(contentType);
|
||||
ContentTypeBase = contentType;
|
||||
Properties.EnsurePropertyTypes(PropertyTypes);
|
||||
|
||||
Properties.CollectionChanged -= PropertiesChanged; // be sure not to double add
|
||||
Properties.CollectionChanged += PropertiesChanged;
|
||||
ChangeContentType(contentType, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -328,19 +314,15 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="clearProperties">Boolean indicating whether to clear PropertyTypes upon change</param>
|
||||
internal void ChangeContentType(IContentType contentType, bool clearProperties)
|
||||
{
|
||||
ChangeContentType(new SimpleContentType(contentType));
|
||||
|
||||
if (clearProperties)
|
||||
{
|
||||
ContentTypeId = contentType.Id;
|
||||
ContentType = new SimpleContentType(contentType);
|
||||
ContentTypeBase = contentType;
|
||||
Properties.EnsureCleanPropertyTypes(PropertyTypes);
|
||||
Properties.EnsureCleanPropertyTypes(contentType.CompositionPropertyTypes);
|
||||
else
|
||||
Properties.EnsurePropertyTypes(contentType.CompositionPropertyTypes);
|
||||
|
||||
Properties.CollectionChanged -= PropertiesChanged; // be sure not to double add
|
||||
Properties.CollectionChanged += PropertiesChanged;
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeContentType(contentType);
|
||||
Properties.CollectionChanged -= PropertiesChanged; // be sure not to double add
|
||||
Properties.CollectionChanged += PropertiesChanged;
|
||||
}
|
||||
|
||||
public override void ResetWereDirtyProperties()
|
||||
@@ -385,19 +367,19 @@ namespace Umbraco.Core.Models
|
||||
public override bool IsPropertyDirty(string propertyName)
|
||||
{
|
||||
//Special check here since we want to check if the request is for changed cultures
|
||||
if (propertyName.StartsWith("_publishedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.PublishedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_publishedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.PublishedCulture);
|
||||
return _currentPublishCultureChanges.addedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_unpublishedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.UnpublishedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_unpublishedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UnpublishedCulture);
|
||||
return _currentPublishCultureChanges.removedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_changedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.ChangedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_changedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.ChangedCulture);
|
||||
return _currentPublishCultureChanges.updatedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
|
||||
@@ -409,19 +391,19 @@ namespace Umbraco.Core.Models
|
||||
public override bool WasPropertyDirty(string propertyName)
|
||||
{
|
||||
//Special check here since we want to check if the request is for changed cultures
|
||||
if (propertyName.StartsWith("_publishedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.PublishedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_publishedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.PublishedCulture);
|
||||
return _previousPublishCultureChanges.addedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_unpublishedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.UnpublishedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_unpublishedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UnpublishedCulture);
|
||||
return _previousPublishCultureChanges.removedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_changedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.ChangedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_changedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.ChangedCulture);
|
||||
return _previousPublishCultureChanges.updatedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
|
||||
@@ -453,9 +435,6 @@ namespace Umbraco.Core.Models
|
||||
|
||||
//fixme - need to reset change tracking bits
|
||||
|
||||
//need to manually clone this since it's not settable
|
||||
clonedContent.ContentType = ContentType;
|
||||
|
||||
//if culture infos exist then deal with event bindings
|
||||
if (clonedContent._publishInfos != null)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
@@ -14,21 +15,30 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[DataContract(IsReference = true)]
|
||||
[DebuggerDisplay("Id: {Id}, Name: {Name}, ContentType: {ContentTypeBase.Alias}")]
|
||||
[DebuggerDisplay("Id: {Id}, Name: {Name}, ContentType: {ContentType.Alias}")]
|
||||
public abstract class ContentBase : TreeEntityBase, IContentBase
|
||||
{
|
||||
|
||||
private int _contentTypeId;
|
||||
protected IContentTypeComposition ContentTypeBase;
|
||||
private int _writerId;
|
||||
private PropertyCollection _properties;
|
||||
private ContentCultureInfosCollection _cultureInfos;
|
||||
internal IReadOnlyList<PropertyType> AllPropertyTypes { get; }
|
||||
|
||||
#region Used for change tracking
|
||||
|
||||
private (HashSet<string> addedCultures, HashSet<string> removedCultures, HashSet<string> updatedCultures) _currentCultureChanges;
|
||||
private (HashSet<string> addedCultures, HashSet<string> removedCultures, HashSet<string> updatedCultures) _previousCultureChanges;
|
||||
|
||||
public static class ChangeTrackingPrefix
|
||||
{
|
||||
public const string UpdatedCulture = "_updatedCulture_";
|
||||
public const string ChangedCulture = "_changedCulture_";
|
||||
public const string PublishedCulture = "_publishedCulture_";
|
||||
public const string UnpublishedCulture = "_unpublishedCulture_";
|
||||
public const string AddedCulture = "_addedCulture_";
|
||||
public const string RemovedCulture = "_removedCulture_";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -53,7 +63,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
private ContentBase(string name, IContentTypeComposition contentType, PropertyCollection properties, string culture = null)
|
||||
{
|
||||
ContentTypeBase = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
ContentType = contentType?.ToSimple() ?? throw new ArgumentNullException(nameof(contentType));
|
||||
|
||||
// initially, all new instances have
|
||||
Id = 0; // no identity
|
||||
@@ -63,7 +73,21 @@ namespace Umbraco.Core.Models
|
||||
|
||||
_contentTypeId = contentType.Id;
|
||||
_properties = properties ?? throw new ArgumentNullException(nameof(properties));
|
||||
_properties.EnsurePropertyTypes(PropertyTypes);
|
||||
_properties.EnsurePropertyTypes(contentType.CompositionPropertyTypes);
|
||||
|
||||
//track all property types on this content type, these can never change during the lifetime of this single instance
|
||||
//there is no real extra memory overhead of doing this since these property types are already cached on this object via the
|
||||
//properties already.
|
||||
AllPropertyTypes = new List<PropertyType>(contentType.CompositionPropertyTypes);
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public ISimpleContentType ContentType { get; private set; }
|
||||
|
||||
internal void ChangeContentType(ISimpleContentType contentType)
|
||||
{
|
||||
ContentType = contentType;
|
||||
ContentTypeId = contentType.Id;
|
||||
}
|
||||
|
||||
protected void PropertiesChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
@@ -71,8 +95,6 @@ namespace Umbraco.Core.Models
|
||||
OnPropertyChanged(nameof(Properties));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Id of the user who wrote/updated this entity
|
||||
/// </summary>
|
||||
@@ -96,13 +118,13 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
//There will be cases where this has not been updated to reflect the true content type ID.
|
||||
//This will occur when inserting new content.
|
||||
if (_contentTypeId == 0 && ContentTypeBase != null && ContentTypeBase.HasIdentity)
|
||||
if (_contentTypeId == 0 && ContentType != null)
|
||||
{
|
||||
_contentTypeId = ContentTypeBase.Id;
|
||||
_contentTypeId = ContentType.Id;
|
||||
}
|
||||
return _contentTypeId;
|
||||
}
|
||||
protected set => SetPropertyValueAndDetectChanges(value, ref _contentTypeId, nameof(ContentTypeId));
|
||||
private set => SetPropertyValueAndDetectChanges(value, ref _contentTypeId, nameof(ContentTypeId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -124,20 +146,6 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the enumeration of property groups for the entity.
|
||||
/// TODO: remove this proxy method
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
public IEnumerable<PropertyGroup> PropertyGroups => ContentTypeBase.CompositionPropertyGroups;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the numeration of property types for the entity.
|
||||
/// TODO: remove this proxy method
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
public IEnumerable<PropertyType> PropertyTypes => ContentTypeBase.CompositionPropertyTypes;
|
||||
|
||||
#region Cultures
|
||||
|
||||
// notes - common rules
|
||||
@@ -178,7 +186,7 @@ namespace Umbraco.Core.Models
|
||||
public string GetCultureName(string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) return Name;
|
||||
if (!ContentTypeBase.VariesByCulture()) return null;
|
||||
if (!ContentType.VariesByCulture()) return null;
|
||||
if (_cultureInfos == null) return null;
|
||||
return _cultureInfos.TryGetValue(culture, out var infos) ? infos.Name : null;
|
||||
}
|
||||
@@ -187,7 +195,7 @@ namespace Umbraco.Core.Models
|
||||
public DateTime? GetUpdateDate(string culture)
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) return null;
|
||||
if (!ContentTypeBase.VariesByCulture()) return null;
|
||||
if (!ContentType.VariesByCulture()) return null;
|
||||
if (_cultureInfos == null) return null;
|
||||
return _cultureInfos.TryGetValue(culture, out var infos) ? infos.Date : (DateTime?)null;
|
||||
}
|
||||
@@ -195,7 +203,7 @@ namespace Umbraco.Core.Models
|
||||
/// <inheritdoc />
|
||||
public void SetCultureName(string name, string culture)
|
||||
{
|
||||
if (ContentTypeBase.VariesByCulture()) // set on variant content type
|
||||
if (ContentType.VariesByCulture()) // set on variant content type
|
||||
{
|
||||
if (culture.IsNullOrWhiteSpace()) // invariant is ok
|
||||
{
|
||||
@@ -299,21 +307,10 @@ namespace Umbraco.Core.Models
|
||||
/// <inheritdoc />
|
||||
public void SetValue(string propertyTypeAlias, object value, string culture = null, string segment = null)
|
||||
{
|
||||
if (Properties.Contains(propertyTypeAlias))
|
||||
{
|
||||
Properties[propertyTypeAlias].SetValue(value, culture, segment);
|
||||
//bump the culture to be flagged for updating
|
||||
this.TouchCulture(culture);
|
||||
return;
|
||||
}
|
||||
|
||||
var propertyType = PropertyTypes.FirstOrDefault(x => x.Alias.InvariantEquals(propertyTypeAlias));
|
||||
if (propertyType == null)
|
||||
if (!Properties.TryGetValue(propertyTypeAlias, out var property))
|
||||
throw new InvalidOperationException($"No PropertyType exists with the supplied alias \"{propertyTypeAlias}\".");
|
||||
|
||||
var property = propertyType.CreateProperty();
|
||||
property.SetValue(value, culture, segment);
|
||||
Properties.Add(property);
|
||||
|
||||
//bump the culture to be flagged for updating
|
||||
this.TouchCulture(culture);
|
||||
@@ -402,19 +399,19 @@ namespace Umbraco.Core.Models
|
||||
return true;
|
||||
|
||||
//Special check here since we want to check if the request is for changed cultures
|
||||
if (propertyName.StartsWith("_addedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.AddedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_addedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.AddedCulture);
|
||||
return _currentCultureChanges.addedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_removedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.RemovedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_removedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.RemovedCulture);
|
||||
return _currentCultureChanges.removedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_updatedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.UpdatedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_updatedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UpdatedCulture);
|
||||
return _currentCultureChanges.updatedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
|
||||
@@ -429,19 +426,19 @@ namespace Umbraco.Core.Models
|
||||
return true;
|
||||
|
||||
//Special check here since we want to check if the request is for changed cultures
|
||||
if (propertyName.StartsWith("_addedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.AddedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_addedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.AddedCulture);
|
||||
return _previousCultureChanges.addedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_removedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.RemovedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_removedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.RemovedCulture);
|
||||
return _previousCultureChanges.removedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
if (propertyName.StartsWith("_updatedCulture_"))
|
||||
if (propertyName.StartsWith(ChangeTrackingPrefix.UpdatedCulture))
|
||||
{
|
||||
var culture = propertyName.TrimStart("_updatedCulture_");
|
||||
var culture = propertyName.TrimStart(ChangeTrackingPrefix.UpdatedCulture);
|
||||
return _previousCultureChanges.updatedCultures?.Contains(culture) ?? false;
|
||||
}
|
||||
|
||||
@@ -478,6 +475,9 @@ namespace Umbraco.Core.Models
|
||||
|
||||
var clonedContent = (ContentBase)clone;
|
||||
|
||||
//need to manually clone this since it's not settable
|
||||
clonedContent.ContentType = ContentType;
|
||||
|
||||
//if culture infos exist then deal with event bindings
|
||||
if (clonedContent._cultureInfos != null)
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Core.Models
|
||||
return Array.Empty<string>();
|
||||
|
||||
var culturesUnpublishing = content.CultureInfos.Values
|
||||
.Where(x => content.IsPropertyDirty("_unpublishedCulture_" + x.Culture))
|
||||
.Where(x => content.IsPropertyDirty(ContentBase.ChangeTrackingPrefix.UnpublishedCulture + x.Culture))
|
||||
.Select(x => x.Culture);
|
||||
|
||||
return culturesUnpublishing.ToList();
|
||||
@@ -88,8 +88,7 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
content.CultureInfos.Clear();
|
||||
content.CultureInfos = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (culture == null || culture == "*")
|
||||
content.Name = other.Name;
|
||||
@@ -158,8 +157,9 @@ namespace Umbraco.Core.Models
|
||||
if (!content.PublishCultureInfos.TryGetValue(culture, out var publishInfos))
|
||||
continue;
|
||||
|
||||
// if it's not dirty, it means it hasn't changed so there's nothing to adjust
|
||||
if (!publishInfos.IsDirty())
|
||||
continue; //if it's not dirty, it means it hasn't changed so there's nothing to adjust
|
||||
continue;
|
||||
|
||||
content.PublishCultureInfos.AddOrUpdate(culture, publishInfos.Name, date);
|
||||
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace Umbraco.Core.Models
|
||||
_allowedTemplates = new List<ITemplate>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ISimpleContentType ToSimple() => new SimpleContentType(this);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsPublishing => IsPublishingConst;
|
||||
|
||||
@@ -97,8 +100,8 @@ namespace Umbraco.Core.Models
|
||||
/// <returns>True if AllowedTemplates contains the templateId else False</returns>
|
||||
public bool IsAllowedTemplate(int templateId)
|
||||
{
|
||||
return AllowedTemplates == null
|
||||
? false
|
||||
return AllowedTemplates == null
|
||||
? false
|
||||
: AllowedTemplates.Any(t => t.Id == templateId);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ namespace Umbraco.Core.Models
|
||||
_variations = ContentVariation.Nothing;
|
||||
}
|
||||
|
||||
public abstract ISimpleContentType ToSimple();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content type is publishing.
|
||||
/// </summary>
|
||||
|
||||
@@ -14,5 +14,14 @@
|
||||
/// Gets or sets the path of the entity.
|
||||
/// </summary>
|
||||
public string Path { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Proxy of the Id
|
||||
/// </summary>
|
||||
public int NodeId
|
||||
{
|
||||
get => Id;
|
||||
set => Id = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,6 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
DateTime? PublishDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content type of this content.
|
||||
/// </summary>
|
||||
ISimpleContentType ContentType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a culture is published.
|
||||
/// </summary>
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
int ContentTypeId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content type of this content.
|
||||
/// </summary>
|
||||
ISimpleContentType ContentType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the writer.
|
||||
/// </summary>
|
||||
@@ -58,7 +63,7 @@ namespace Umbraco.Core.Models
|
||||
/// culture name, which must be get or set via the <see cref="TreeEntityBase.Name"/> property.</para>
|
||||
/// </remarks>
|
||||
ContentCultureInfosCollection CultureInfos { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available cultures.
|
||||
/// </summary>
|
||||
@@ -95,18 +100,6 @@ namespace Umbraco.Core.Models
|
||||
/// <remarks>Properties are loaded as part of the Content object graph</remarks>
|
||||
PropertyCollection Properties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of PropertyGroups available on this Content object
|
||||
/// </summary>
|
||||
/// <remarks>PropertyGroups are kind of lazy loaded as part of the object graph</remarks>
|
||||
IEnumerable<PropertyGroup> PropertyGroups { get; }
|
||||
|
||||
/// <summary>
|
||||
/// List of PropertyTypes available on this Content object
|
||||
/// </summary>
|
||||
/// <remarks>PropertyTypes are kind of lazy loaded as part of the object graph</remarks>
|
||||
IEnumerable<PropertyType> PropertyTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the content entity has a property with the supplied alias.
|
||||
/// </summary>
|
||||
|
||||
@@ -159,5 +159,10 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="propertyGroupName">Name of the PropertyGroup to move the PropertyType to</param>
|
||||
/// <returns></returns>
|
||||
bool MovePropertyType(string propertyTypeAlias, string propertyGroupName);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="ISimpleContentType"/> corresponding to this content type.
|
||||
/// </summary>
|
||||
ISimpleContentType ToSimple();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,5 @@
|
||||
using Umbraco.Core.Persistence.Mappers;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
public interface IMedia : IContentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the ContentType used by this Media object
|
||||
/// </summary>
|
||||
IMediaType ContentType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="IMediaType"/> for the current content object
|
||||
/// </summary>
|
||||
/// <param name="contentType">New ContentType for this content</param>
|
||||
/// <remarks>Leaves PropertyTypes intact after change</remarks>
|
||||
void ChangeContentType(IMediaType contentType);
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="IMediaType"/> for the current content object and removes PropertyTypes,
|
||||
/// which are not part of the new ContentType.
|
||||
/// </summary>
|
||||
/// <param name="contentType">New ContentType for this content</param>
|
||||
/// <param name="clearProperties">Boolean indicating whether to clear PropertyTypes upon change</param>
|
||||
void ChangeContentType(IMediaType contentType, bool clearProperties);
|
||||
}
|
||||
{ }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
@@ -11,10 +9,5 @@ namespace Umbraco.Core.Models
|
||||
/// String alias of the default ContentType
|
||||
/// </summary>
|
||||
string ContentTypeAlias { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ContentType used by this content object
|
||||
/// </summary>
|
||||
IMemberType ContentType { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
namespace Umbraco.Core.Models
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a simplified view of a content type.
|
||||
/// </summary>
|
||||
public interface ISimpleContentType
|
||||
public interface ISimpleContentType : IUmbracoEntity
|
||||
{
|
||||
new int Id { get; }
|
||||
new string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the alias of the content type.
|
||||
/// </summary>
|
||||
string Alias { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the content type.
|
||||
/// </summary>
|
||||
int Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default template of the content type.
|
||||
/// </summary>
|
||||
@@ -35,11 +35,6 @@
|
||||
/// </summary>
|
||||
bool IsContainer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the content type.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether content of that type can be created at the root of the tree.
|
||||
/// </summary>
|
||||
|
||||
@@ -10,8 +10,6 @@ namespace Umbraco.Core.Models
|
||||
[DataContract(IsReference = true)]
|
||||
public class Media : ContentBase, IMedia
|
||||
{
|
||||
private IMediaType _contentType;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for creating a Media object
|
||||
/// </summary>
|
||||
@@ -31,9 +29,7 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="properties">Collection of properties</param>
|
||||
public Media(string name, IMedia parent, IMediaType contentType, PropertyCollection properties)
|
||||
: base(name, parent, contentType, properties)
|
||||
{
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
}
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor for creating a Media object
|
||||
@@ -54,30 +50,16 @@ namespace Umbraco.Core.Models
|
||||
/// <param name="properties">Collection of properties</param>
|
||||
public Media(string name, int parentId, IMediaType contentType, PropertyCollection properties)
|
||||
: base(name, parentId, contentType, properties)
|
||||
{
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ContentType used by this Media object
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
public IMediaType ContentType => _contentType;
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Changes the <see cref="IMediaType"/> for the current Media object
|
||||
/// </summary>
|
||||
/// <param name="contentType">New MediaType for this Media</param>
|
||||
/// <remarks>Leaves PropertyTypes intact after change</remarks>
|
||||
public void ChangeContentType(IMediaType contentType)
|
||||
internal void ChangeContentType(IMediaType contentType)
|
||||
{
|
||||
ContentTypeId = contentType.Id;
|
||||
_contentType = contentType;
|
||||
ContentTypeBase = contentType;
|
||||
Properties.EnsurePropertyTypes(PropertyTypes);
|
||||
|
||||
Properties.CollectionChanged -= PropertiesChanged; // be sure not to double add
|
||||
Properties.CollectionChanged += PropertiesChanged;
|
||||
ChangeContentType(contentType, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,33 +68,17 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
/// <param name="contentType">New MediaType for this Media</param>
|
||||
/// <param name="clearProperties">Boolean indicating whether to clear PropertyTypes upon change</param>
|
||||
public void ChangeContentType(IMediaType contentType, bool clearProperties)
|
||||
internal void ChangeContentType(IMediaType contentType, bool clearProperties)
|
||||
{
|
||||
ChangeContentType(new SimpleContentType(contentType));
|
||||
|
||||
if (clearProperties)
|
||||
{
|
||||
ContentTypeId = contentType.Id;
|
||||
_contentType = contentType;
|
||||
ContentTypeBase = contentType;
|
||||
Properties.EnsureCleanPropertyTypes(PropertyTypes);
|
||||
Properties.EnsureCleanPropertyTypes(contentType.CompositionPropertyTypes);
|
||||
else
|
||||
Properties.EnsurePropertyTypes(contentType.CompositionPropertyTypes);
|
||||
|
||||
Properties.CollectionChanged -= PropertiesChanged; // be sure not to double add
|
||||
Properties.CollectionChanged += PropertiesChanged;
|
||||
return;
|
||||
}
|
||||
|
||||
ChangeContentType(contentType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the Trashed state of the content object
|
||||
/// </summary>
|
||||
/// <param name="isTrashed">Boolean indicating whether content is trashed (true) or not trashed (false)</param>
|
||||
/// <param name="parentId"> </param>
|
||||
public void ChangeTrashedState(bool isTrashed, int parentId = -20)
|
||||
{
|
||||
Trashed = isTrashed;
|
||||
//The Media Recycle Bin Id is -21 so we correct that here
|
||||
ParentId = parentId == -20 ? -21 : parentId;
|
||||
Properties.CollectionChanged -= PropertiesChanged; // be sure not to double add
|
||||
Properties.CollectionChanged += PropertiesChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,20 +15,17 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
public static string GetUrl(this IMedia media, string propertyAlias, ILogger logger)
|
||||
{
|
||||
var propertyType = media.PropertyTypes.FirstOrDefault(x => x.Alias.InvariantEquals(propertyAlias));
|
||||
if (propertyType == null) return string.Empty;
|
||||
|
||||
var val = media.Properties[propertyType];
|
||||
if (val == null) return string.Empty;
|
||||
if (!media.Properties.TryGetValue(propertyAlias, out var property))
|
||||
return string.Empty;
|
||||
|
||||
// TODO: would need to be adjusted to variations, when media become variants
|
||||
var jsonString = val.GetValue() as string;
|
||||
if (jsonString == null) return string.Empty;
|
||||
if (!(property.GetValue() is string jsonString))
|
||||
return string.Empty;
|
||||
|
||||
if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.UploadField)
|
||||
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.UploadField)
|
||||
return jsonString;
|
||||
|
||||
if (propertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.ImageCropper)
|
||||
if (property.PropertyType.PropertyEditorAlias == Constants.PropertyEditors.Aliases.ImageCropper)
|
||||
{
|
||||
if (jsonString.DetectIsJson() == false)
|
||||
return jsonString;
|
||||
|
||||
@@ -41,6 +41,9 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ISimpleContentType ToSimple() => new SimpleContentType(this);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsPublishing => IsPublishingConst;
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ namespace Umbraco.Core.Models
|
||||
public class Member : ContentBase, IMember
|
||||
{
|
||||
private IDictionary<string, object> _additionalData;
|
||||
private IMemberType _contentType;
|
||||
private readonly string _contentTypeAlias;
|
||||
private string _username;
|
||||
private string _email;
|
||||
private string _rawPasswordValue;
|
||||
@@ -29,8 +27,6 @@ namespace Umbraco.Core.Models
|
||||
public Member(IMemberType contentType)
|
||||
: base("", -1, contentType, new PropertyCollection())
|
||||
{
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
IsApproved = true;
|
||||
|
||||
//this cannot be null but can be empty
|
||||
@@ -49,8 +45,6 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
IsApproved = true;
|
||||
|
||||
//this cannot be null but can be empty
|
||||
@@ -73,8 +67,6 @@ namespace Umbraco.Core.Models
|
||||
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullOrEmptyException(nameof(name));
|
||||
if (string.IsNullOrWhiteSpace(username)) throw new ArgumentNullOrEmptyException(nameof(username));
|
||||
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
_email = email;
|
||||
_username = username;
|
||||
IsApproved = isApproved;
|
||||
@@ -96,9 +88,6 @@ namespace Umbraco.Core.Models
|
||||
public Member(string name, string email, string username, string rawPasswordValue, IMemberType contentType)
|
||||
: base(name, -1, contentType, new PropertyCollection())
|
||||
{
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
|
||||
_email = email;
|
||||
_username = username;
|
||||
_rawPasswordValue = rawPasswordValue;
|
||||
@@ -119,8 +108,6 @@ namespace Umbraco.Core.Models
|
||||
public Member(string name, string email, string username, string rawPasswordValue, IMemberType contentType, bool isApproved)
|
||||
: base(name, -1, contentType, new PropertyCollection())
|
||||
{
|
||||
_contentType = contentType ?? throw new ArgumentNullException(nameof(contentType));
|
||||
_contentTypeAlias = contentType.Alias;
|
||||
_email = email;
|
||||
_username = username;
|
||||
_rawPasswordValue = rawPasswordValue;
|
||||
@@ -473,7 +460,7 @@ namespace Umbraco.Core.Models
|
||||
/// String alias of the default ContentType
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public virtual string ContentTypeAlias => _contentTypeAlias;
|
||||
public virtual string ContentTypeAlias => ContentType.Alias;
|
||||
|
||||
/// <summary>
|
||||
/// User key from the Provider.
|
||||
@@ -504,12 +491,6 @@ namespace Umbraco.Core.Models
|
||||
ProviderUserKey = Key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the ContentType used by this content object
|
||||
/// </summary>
|
||||
[IgnoreDataMember]
|
||||
public IMemberType ContentType => _contentType;
|
||||
|
||||
/* Internal experiment - only used for mapping queries.
|
||||
* Adding these to have first level properties instead of the Properties collection.
|
||||
*/
|
||||
@@ -575,17 +556,6 @@ namespace Umbraco.Core.Models
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void PerformDeepClone(object clone)
|
||||
{
|
||||
base.PerformDeepClone(clone);
|
||||
|
||||
var clonedEntity = (Member)clone;
|
||||
|
||||
//need to manually clone this since it's not settable
|
||||
clonedEntity._contentType = (IMemberType)ContentType.DeepClone();
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
[DoNotClone]
|
||||
|
||||
@@ -31,6 +31,9 @@ namespace Umbraco.Core.Models
|
||||
MemberTypePropertyTypes = new Dictionary<string, MemberTypePropertyProfileAccess>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override ISimpleContentType ToSimple() => new SimpleContentType(this);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsPublishing => IsPublishingConst;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a property.
|
||||
/// Adds or updates a property.
|
||||
/// </summary>
|
||||
internal new void Add(Property property)
|
||||
{
|
||||
|
||||
@@ -87,8 +87,20 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
lock (_publishedDataTypesLocker)
|
||||
{
|
||||
var dataTypes = _dataTypeService.GetAll(ids);
|
||||
_publishedDataTypes = dataTypes.ToDictionary(x => x.Id, CreatePublishedDataType);
|
||||
if (_publishedDataTypes == null)
|
||||
{
|
||||
var dataTypes = _dataTypeService.GetAll();
|
||||
_publishedDataTypes = dataTypes.ToDictionary(x => x.Id, CreatePublishedDataType);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var id in ids)
|
||||
_publishedDataTypes.Remove(id);
|
||||
|
||||
var dataTypes = _dataTypeService.GetAll(ids);
|
||||
foreach (var dataType in dataTypes)
|
||||
_publishedDataTypes[dataType.Id] = CreatePublishedDataType(dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
namespace Umbraco.Core.Models
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Umbraco.Core.Models.Entities;
|
||||
|
||||
namespace Umbraco.Core.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements <see cref="ISimpleContentType"/>.
|
||||
@@ -9,14 +13,34 @@
|
||||
/// Initializes a new instance of the <see cref="SimpleContentType"/> class.
|
||||
/// </summary>
|
||||
public SimpleContentType(IContentType contentType)
|
||||
: this((IContentTypeBase)contentType)
|
||||
{
|
||||
DefaultTemplate = contentType.DefaultTemplate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SimpleContentType"/> class.
|
||||
/// </summary>
|
||||
public SimpleContentType(IMediaType mediaType)
|
||||
: this((IContentTypeBase)mediaType)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SimpleContentType"/> class.
|
||||
/// </summary>
|
||||
public SimpleContentType(IMemberType memberType)
|
||||
: this((IContentTypeBase)memberType)
|
||||
{ }
|
||||
|
||||
private SimpleContentType(IContentTypeBase contentType)
|
||||
{
|
||||
if (contentType == null) throw new ArgumentNullException(nameof(contentType));
|
||||
|
||||
Id = contentType.Id;
|
||||
Alias = contentType.Alias;
|
||||
DefaultTemplate = contentType.DefaultTemplate;
|
||||
Variations = contentType.Variations;
|
||||
Icon = contentType.Icon;
|
||||
IsContainer = contentType.IsContainer;
|
||||
Icon = contentType.Icon;
|
||||
Name = contentType.Name;
|
||||
AllowedAsRoot = contentType.AllowedAsRoot;
|
||||
IsElement = contentType.IsElement;
|
||||
@@ -25,8 +49,7 @@
|
||||
/// <inheritdoc />
|
||||
public string Alias { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public int Id { get; }
|
||||
public int Id { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITemplate DefaultTemplate { get; }
|
||||
@@ -39,8 +62,7 @@
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool IsContainer { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -80,5 +102,33 @@
|
||||
return ((Alias != null ? Alias.GetHashCode() : 0) * 397) ^ Id;
|
||||
}
|
||||
}
|
||||
|
||||
// we have to have all this, because we're an IUmbracoEntity, because that is
|
||||
// required by the query expression visitor / SimpleContentTypeMapper
|
||||
|
||||
string ITreeEntity.Name { get => this.Name; set => throw new NotImplementedException(); }
|
||||
int IEntity.Id { get => this.Id; set => throw new NotImplementedException(); }
|
||||
bool IEntity.HasIdentity => this.Id != default;
|
||||
int ITreeEntity.CreatorId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
int ITreeEntity.ParentId { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
int ITreeEntity.Level { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
string ITreeEntity.Path { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
int ITreeEntity.SortOrder { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
bool ITreeEntity.Trashed => throw new NotImplementedException();
|
||||
Guid IEntity.Key { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
DateTime IEntity.CreateDate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
DateTime IEntity.UpdateDate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
DateTime? IEntity.DeleteDate { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
void ITreeEntity.SetParent(ITreeEntity parent) => throw new NotImplementedException();
|
||||
object IDeepCloneable.DeepClone() => throw new NotImplementedException();
|
||||
bool IRememberBeingDirty.WasDirty() => throw new NotImplementedException();
|
||||
bool IRememberBeingDirty.WasPropertyDirty(string propertyName) => throw new NotImplementedException();
|
||||
void IRememberBeingDirty.ResetWereDirtyProperties() => throw new NotImplementedException();
|
||||
void IRememberBeingDirty.ResetDirtyProperties(bool rememberDirty) => throw new NotImplementedException();
|
||||
IEnumerable<string> IRememberBeingDirty.GetWereDirtyProperties() => throw new NotImplementedException();
|
||||
bool ICanBeDirty.IsDirty() => throw new NotImplementedException();
|
||||
bool ICanBeDirty.IsPropertyDirty(string propName) => throw new NotImplementedException();
|
||||
IEnumerable<string> ICanBeDirty.GetDirtyProperties() => throw new NotImplementedException();
|
||||
void ICanBeDirty.ResetDirtyProperties() => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Umbraco.Core.Persistence
|
||||
do
|
||||
{
|
||||
c = unwrapped;
|
||||
if (unwrapped is ProfiledDbConnection profiled) unwrapped = profiled.InnerConnection;
|
||||
if (unwrapped is ProfiledDbConnection profiled) unwrapped = profiled.WrappedConnection;
|
||||
if (unwrapped is RetryDbConnection retrying) unwrapped = retrying.Inner;
|
||||
|
||||
} while (c != unwrapped);
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
Add<AuditItemMapper>();
|
||||
Add<ContentMapper>();
|
||||
Add<ContentTypeMapper>();
|
||||
Add<SimpleContentTypeMapper>();
|
||||
Add<DataTypeMapper>();
|
||||
Add<DictionaryMapper>();
|
||||
Add<DictionaryTranslationMapper>();
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections.Concurrent;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Dtos;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Mappers
|
||||
{
|
||||
[MapperFor(typeof(ISimpleContentType))]
|
||||
[MapperFor(typeof(SimpleContentType))]
|
||||
public sealed class SimpleContentTypeMapper : BaseMapper
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, DtoMapModel> PropertyInfoCacheInstance = new ConcurrentDictionary<string, DtoMapModel>();
|
||||
|
||||
internal override ConcurrentDictionary<string, DtoMapModel> PropertyInfoCache => PropertyInfoCacheInstance;
|
||||
|
||||
protected override void BuildMap()
|
||||
{
|
||||
if (PropertyInfoCache.IsEmpty == false) return;
|
||||
|
||||
CacheMap<ContentType, NodeDto>(src => src.Id, dto => dto.NodeId);
|
||||
CacheMap<ContentType, NodeDto>(src => src.CreateDate, dto => dto.CreateDate);
|
||||
CacheMap<ContentType, NodeDto>(src => src.Level, dto => dto.Level);
|
||||
CacheMap<ContentType, NodeDto>(src => src.ParentId, dto => dto.ParentId);
|
||||
CacheMap<ContentType, NodeDto>(src => src.Path, dto => dto.Path);
|
||||
CacheMap<ContentType, NodeDto>(src => src.SortOrder, dto => dto.SortOrder);
|
||||
CacheMap<ContentType, NodeDto>(src => src.Name, dto => dto.Text);
|
||||
CacheMap<ContentType, NodeDto>(src => src.Trashed, dto => dto.Trashed);
|
||||
CacheMap<ContentType, NodeDto>(src => src.Key, dto => dto.UniqueId);
|
||||
CacheMap<ContentType, NodeDto>(src => src.CreatorId, dto => dto.UserId);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.Alias, dto => dto.Alias);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.AllowedAsRoot, dto => dto.AllowAtRoot);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.Description, dto => dto.Description);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.Icon, dto => dto.Icon);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.IsContainer, dto => dto.IsContainer);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.IsElement, dto => dto.IsElement);
|
||||
CacheMap<ContentType, ContentTypeDto>(src => src.Thumbnail, dto => dto.Thumbnail);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ namespace Umbraco.Core.Persistence
|
||||
where TConnection : class, IDbConnection
|
||||
{
|
||||
var profiled = connection as ProfiledDbConnection;
|
||||
return profiled == null ? connection as TConnection : profiled.InnerConnection as TConnection;
|
||||
return profiled == null ? connection as TConnection : profiled.WrappedConnection as TConnection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
|
||||
if (m.Expression != null
|
||||
&& m.Expression.Type != typeof(T)
|
||||
&& TypeHelper.IsTypeAssignableFrom<IUmbracoEntity>(m.Expression.Type)
|
||||
&& TypeHelper.IsTypeAssignableFrom<IUmbracoEntity>(m.Expression.Type) //TODO: Could this just be `IEntity` ? why does it need to be IUmbracoEntity, we aren't even using the reference to that below
|
||||
&& EndsWithConstant(m) == false)
|
||||
{
|
||||
//if this is the case, it means we have a sub expression / nested property access, such as: x.ContentType.Alias == "Test";
|
||||
|
||||
@@ -7,8 +7,6 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
public interface IDocumentRepository : IContentRepository<int, IContent>, IReadRepository<Guid, IContent>
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Clears the publishing schedule for all entries having an a date before (lower than, or equal to) a specified date.
|
||||
/// </summary>
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NPoco;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
@@ -120,15 +119,15 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
break;
|
||||
case QueryType.Single:
|
||||
case QueryType.Many:
|
||||
// R# may flag this ambiguous and red-squiggle it, but it is not
|
||||
sql = sql.Select<DocumentDto>(r =>
|
||||
r.Select(documentDto => documentDto.ContentDto, r1 =>
|
||||
r1.Select(contentDto => contentDto.NodeDto))
|
||||
.Select(documentDto => documentDto.DocumentVersionDto, r1 =>
|
||||
r1.Select(documentVersionDto => documentVersionDto.ContentVersionDto))
|
||||
.Select(documentDto => documentDto.PublishedVersionDto, "pdv", r1 =>
|
||||
r1.Select(documentVersionDto => documentVersionDto.ContentVersionDto, "pcv")))
|
||||
|
||||
//we've put this in a local function so that the below sql.Select statement doesn't have a problem
|
||||
//thinking that the call is ambiguous
|
||||
NPocoSqlExtensions.SqlRef<DocumentDto> SelectStatement(NPocoSqlExtensions.SqlRef<DocumentDto> r) =>
|
||||
r.Select(documentDto => documentDto.ContentDto, r1 => r1.Select(contentDto => contentDto.NodeDto))
|
||||
.Select(documentDto => documentDto.DocumentVersionDto, r1 => r1.Select(documentVersionDto => documentVersionDto.ContentVersionDto))
|
||||
.Select(documentDto => documentDto.PublishedVersionDto, "pdv", r1 => r1.Select(documentVersionDto => documentVersionDto.ContentVersionDto, "pcv"));
|
||||
|
||||
sql = sql.Select<DocumentDto>(SelectStatement)
|
||||
// select the variant name, coalesce to the invariant name, as "variantName"
|
||||
.AndSelect(VariantNameSqlExpression + " AS variantName");
|
||||
break;
|
||||
@@ -954,8 +953,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
protected override string ApplySystemOrdering(ref Sql<ISqlContext> sql, Ordering ordering)
|
||||
{
|
||||
// note: 'updater' is the user who created the latest draft version,
|
||||
@@ -1187,17 +1184,18 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private void SetVariations(Content content, IDictionary<int, List<ContentVariation>> contentVariations, IDictionary<int, List<DocumentVariation>> documentVariations)
|
||||
{
|
||||
if (contentVariations.TryGetValue(content.VersionId, out var contentVariation))
|
||||
foreach (var v in contentVariation)
|
||||
content.SetCultureInfo(v.Culture, v.Name, v.Date);
|
||||
|
||||
if (content.PublishedVersionId > 0 && contentVariations.TryGetValue(content.PublishedVersionId, out contentVariation))
|
||||
{
|
||||
foreach (var v in contentVariation)
|
||||
content.SetPublishInfo(v.Culture, v.Name, v.Date);
|
||||
}
|
||||
|
||||
if (documentVariations.TryGetValue(content.Id, out var documentVariation))
|
||||
content.SetCultureEdited(documentVariation.Where(x => x.Edited).Select(x => x.Culture));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="mediaTypeAlias"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public static IContent CreateContent(this IContentService contentService, string name, Udi parentId, string mediaTypeAlias, int userId = 0)
|
||||
public static IContent CreateContent(this IContentService contentService, string name, Udi parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var guidUdi = parentId as GuidUdi;
|
||||
if (guidUdi == null)
|
||||
|
||||
@@ -32,27 +32,27 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Saves a blueprint.
|
||||
/// </summary>
|
||||
void SaveBlueprint(IContent content, int userId = 0);
|
||||
void SaveBlueprint(IContent content, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a blueprint.
|
||||
/// </summary>
|
||||
void DeleteBlueprint(IContent content, int userId = 0);
|
||||
void DeleteBlueprint(IContent content, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new content item from a blueprint.
|
||||
/// </summary>
|
||||
IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = 0);
|
||||
IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes blueprints for a content type.
|
||||
/// </summary>
|
||||
void DeleteBlueprintsOfType(int contentTypeId, int userId = 0);
|
||||
void DeleteBlueprintsOfType(int contentTypeId, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes blueprints for content types.
|
||||
/// </summary>
|
||||
void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = 0);
|
||||
void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -237,13 +237,13 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Saves a document.
|
||||
/// </summary>
|
||||
OperationResult Save(IContent content, int userId = 0, bool raiseEvents = true);
|
||||
OperationResult Save(IContent content, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Saves documents.
|
||||
/// </summary>
|
||||
// TODO: why only 1 result not 1 per content?!
|
||||
OperationResult Save(IEnumerable<IContent> contents, int userId = 0, bool raiseEvents = true);
|
||||
OperationResult Save(IEnumerable<IContent> contents, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a document.
|
||||
@@ -252,7 +252,7 @@ namespace Umbraco.Core.Services
|
||||
/// <para>This method will also delete associated media files, child content and possibly associated domains.</para>
|
||||
/// <para>This method entirely clears the content from the database.</para>
|
||||
/// </remarks>
|
||||
OperationResult Delete(IContent content, int userId = 0);
|
||||
OperationResult Delete(IContent content, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all documents of a given document type.
|
||||
@@ -261,7 +261,7 @@ namespace Umbraco.Core.Services
|
||||
/// <para>All non-deleted descendants of the deleted documents are moved to the recycle bin.</para>
|
||||
/// <para>This operation is potentially dangerous and expensive.</para>
|
||||
/// </remarks>
|
||||
void DeleteOfType(int documentTypeId, int userId = 0);
|
||||
void DeleteOfType(int documentTypeId, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all documents of given document types.
|
||||
@@ -270,17 +270,17 @@ namespace Umbraco.Core.Services
|
||||
/// <para>All non-deleted descendants of the deleted documents are moved to the recycle bin.</para>
|
||||
/// <para>This operation is potentially dangerous and expensive.</para>
|
||||
/// </remarks>
|
||||
void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = 0);
|
||||
void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes versions of a document prior to a given date.
|
||||
/// </summary>
|
||||
void DeleteVersions(int id, DateTime date, int userId = 0);
|
||||
void DeleteVersions(int id, DateTime date, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a version of a document.
|
||||
/// </summary>
|
||||
void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = 0);
|
||||
void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Moves a document under a new parent.
|
||||
/// </summary>
|
||||
void Move(IContent content, int parentId, int userId = 0);
|
||||
void Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Copies a document.
|
||||
@@ -297,7 +297,7 @@ namespace Umbraco.Core.Services
|
||||
/// <remarks>
|
||||
/// <para>Recursively copies all children.</para>
|
||||
/// </remarks>
|
||||
IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = 0);
|
||||
IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Copies a document.
|
||||
@@ -305,12 +305,12 @@ namespace Umbraco.Core.Services
|
||||
/// <remarks>
|
||||
/// <para>Optionally recursively copies all children.</para>
|
||||
/// </remarks>
|
||||
IContent Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = 0);
|
||||
IContent Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Moves a document to the recycle bin.
|
||||
/// </summary>
|
||||
OperationResult MoveToRecycleBin(IContent content, int userId = 0);
|
||||
OperationResult MoveToRecycleBin(IContent content, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Empties the recycle bin.
|
||||
@@ -320,12 +320,12 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Sorts documents.
|
||||
/// </summary>
|
||||
OperationResult Sort(IEnumerable<IContent> items, int userId = 0, bool raiseEvents = true);
|
||||
OperationResult Sort(IEnumerable<IContent> items, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Sorts documents.
|
||||
/// </summary>
|
||||
OperationResult Sort(IEnumerable<int> ids, int userId = 0, bool raiseEvents = true);
|
||||
OperationResult Sort(IEnumerable<int> ids, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -341,12 +341,11 @@ namespace Umbraco.Core.Services
|
||||
/// <para>If the content type is variant, then culture can be either '*' or an actual culture, but neither 'null' nor
|
||||
/// 'empty'. If the content type is invariant, then culture can be either '*' or null or empty.</para>
|
||||
/// </remarks>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="raiseEvents"></param>
|
||||
/// <returns></returns>
|
||||
PublishResult SaveAndPublish(IContent content, string culture = "*", int userId = 0, bool raiseEvents = true);
|
||||
/// <param name="content">The document to publish.</param>
|
||||
/// <param name="culture">The culture to publish.</param>
|
||||
/// <param name="userId">The identifier of the user performing the action.</param>
|
||||
/// <param name="raiseEvents">A value indicating whether to raise events.</param>
|
||||
PublishResult SaveAndPublish(IContent content, string culture = "*", int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Saves and publishes a document.
|
||||
@@ -356,12 +355,11 @@ namespace Umbraco.Core.Services
|
||||
/// <para>When a culture is being published, it includes all varying values along with all invariant values.</para>
|
||||
/// <para>The document is *always* saved, even when publishing fails.</para>
|
||||
/// </remarks>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="content">The document to publish.</param>
|
||||
/// <param name="cultures">The cultures to publish.</param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="raiseEvents"></param>
|
||||
/// <returns></returns>
|
||||
PublishResult SaveAndPublish(IContent content, string[] cultures, int userId = 0, bool raiseEvents = true);
|
||||
/// <param name="userId">The identifier of the user performing the action.</param>
|
||||
/// <param name="raiseEvents">A value indicating whether to raise events.</param>
|
||||
PublishResult SaveAndPublish(IContent content, string[] cultures, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Saves and publishes a document branch.
|
||||
@@ -377,7 +375,7 @@ namespace Umbraco.Core.Services
|
||||
/// only those documents that are already published, are republished. When <c>true</c>, all documents are
|
||||
/// published. The root of the branch is always published, regardless of <paramref name="force"/>.</para>
|
||||
/// </remarks>
|
||||
IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string culture = "*", int userId = 0);
|
||||
IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string culture = "*", int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves and publishes a document branch.
|
||||
@@ -391,7 +389,7 @@ namespace Umbraco.Core.Services
|
||||
/// only those documents that are already published, are republished. When <c>true</c>, all documents are
|
||||
/// published. The root of the branch is always published, regardless of <paramref name="force"/>.</para>
|
||||
/// </remarks>
|
||||
IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string[] cultures, int userId = 0);
|
||||
IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string[] cultures, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves and publishes a document branch.
|
||||
@@ -416,7 +414,7 @@ namespace Umbraco.Core.Services
|
||||
IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force,
|
||||
Func<IContent, HashSet<string>> shouldPublish,
|
||||
Func<IContent, HashSet<string>, bool> publishCultures,
|
||||
int userId = 0);
|
||||
int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Unpublishes a document.
|
||||
@@ -428,7 +426,7 @@ namespace Umbraco.Core.Services
|
||||
/// <para>If the content type is variant, then culture can be either '*' or an actual culture, but neither null nor
|
||||
/// empty. If the content type is invariant, then culture can be either '*' or null or empty.</para>
|
||||
/// </remarks>
|
||||
PublishResult Unpublish(IContent content, string culture = "*", int userId = 0);
|
||||
PublishResult Unpublish(IContent content, string culture = "*", int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a document is path-publishable.
|
||||
@@ -445,7 +443,7 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Saves a document and raises the "sent to publication" events.
|
||||
/// </summary>
|
||||
bool SendToPublication(IContent content, int userId = 0);
|
||||
bool SendToPublication(IContent content, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Publishes and unpublishes scheduled documents.
|
||||
@@ -480,27 +478,27 @@ namespace Umbraco.Core.Services
|
||||
/// <summary>
|
||||
/// Creates a document.
|
||||
/// </summary>
|
||||
IContent Create(string name, Guid parentId, string documentTypeAlias, int userId = 0);
|
||||
IContent Create(string name, Guid parentId, string documentTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a document.
|
||||
/// </summary>
|
||||
IContent Create(string name, int parentId, string documentTypeAlias, int userId = 0);
|
||||
IContent Create(string name, int parentId, string documentTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a document.
|
||||
/// </summary>
|
||||
IContent Create(string name, IContent parent, string documentTypeAlias, int userId = 0);
|
||||
IContent Create(string name, IContent parent, string documentTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates and saves a document.
|
||||
/// </summary>
|
||||
IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = 0);
|
||||
IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates and saves a document.
|
||||
/// </summary>
|
||||
IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = 0);
|
||||
IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -516,7 +514,7 @@ namespace Umbraco.Core.Services
|
||||
/// <remarks>
|
||||
/// <para>When no culture is specified, all cultures are rolled back.</para>
|
||||
/// </remarks>
|
||||
OperationResult Rollback(int id, int versionId, string culture = "*", int userId = 0);
|
||||
OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Constants.Security.SuperUserId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -18,5 +18,10 @@ namespace Umbraco.Core.Services
|
||||
/// to retrieve the content / media / whatever type as <see cref="IContentTypeComposition"/>.</para>
|
||||
/// </remarks>
|
||||
IContentTypeBaseService For(IContentBase contentBase);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content type of an <see cref="IContentBase"/> object.
|
||||
/// </summary>
|
||||
IContentTypeComposition GetContentTypeOf(IContentBase contentBase);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace Umbraco.Core.Services
|
||||
IEnumerable<TItem> GetChildren(int id);
|
||||
bool HasChildren(int id);
|
||||
|
||||
void Save(TItem item, int userId = 0);
|
||||
void Save(IEnumerable<TItem> items, int userId = 0);
|
||||
void Save(TItem item, int userId = Constants.Security.SuperUserId);
|
||||
void Save(IEnumerable<TItem> items, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
void Delete(TItem item, int userId = 0);
|
||||
void Delete(IEnumerable<TItem> item, int userId = 0);
|
||||
void Delete(TItem item, int userId = Constants.Security.SuperUserId);
|
||||
void Delete(IEnumerable<TItem> item, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
|
||||
Attempt<string[]> ValidateComposition(TItem compo);
|
||||
@@ -63,15 +63,15 @@ namespace Umbraco.Core.Services
|
||||
/// <returns></returns>
|
||||
bool HasContainerInPath(string contentPath);
|
||||
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentContainerId, string name, int userId = 0);
|
||||
Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = 0);
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentContainerId, string name, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = Constants.Security.SuperUserId);
|
||||
EntityContainer GetContainer(int containerId);
|
||||
EntityContainer GetContainer(Guid containerId);
|
||||
IEnumerable<EntityContainer> GetContainers(int[] containerIds);
|
||||
IEnumerable<EntityContainer> GetContainers(TItem contentType);
|
||||
IEnumerable<EntityContainer> GetContainers(string folderName, int level);
|
||||
Attempt<OperationResult> DeleteContainer(int containerId, int userId = 0);
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = 0);
|
||||
Attempt<OperationResult> DeleteContainer(int containerId, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
Attempt<OperationResult<MoveOperationStatusType>> Move(TItem moving, int containerId);
|
||||
Attempt<OperationResult<MoveOperationStatusType, TItem>> Copy(TItem copying, int containerId);
|
||||
|
||||
@@ -9,15 +9,15 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
public interface IDataTypeService : IService
|
||||
{
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentId, string name, int userId = 0);
|
||||
Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = 0);
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentId, string name, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = Constants.Security.SuperUserId);
|
||||
EntityContainer GetContainer(int containerId);
|
||||
EntityContainer GetContainer(Guid containerId);
|
||||
IEnumerable<EntityContainer> GetContainers(string folderName, int level);
|
||||
IEnumerable<EntityContainer> GetContainers(IDataType dataType);
|
||||
IEnumerable<EntityContainer> GetContainers(int[] containerIds);
|
||||
Attempt<OperationResult> DeleteContainer(int containerId, int userId = 0);
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = 0);
|
||||
Attempt<OperationResult> DeleteContainer(int containerId, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="IDataType"/> by its Name
|
||||
@@ -52,14 +52,14 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="dataType"><see cref="IDataType"/> to save</param>
|
||||
/// <param name="userId">Id of the user issuing the save</param>
|
||||
void Save(IDataType dataType, int userId = 0);
|
||||
void Save(IDataType dataType, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a collection of <see cref="IDataType"/>
|
||||
/// </summary>
|
||||
/// <param name="dataTypeDefinitions"><see cref="IDataType"/> to save</param>
|
||||
/// <param name="userId">Id of the user issuing the save</param>
|
||||
void Save(IEnumerable<IDataType> dataTypeDefinitions, int userId = 0);
|
||||
void Save(IEnumerable<IDataType> dataTypeDefinitions, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a collection of <see cref="IDataType"/>
|
||||
@@ -78,7 +78,7 @@ namespace Umbraco.Core.Services
|
||||
/// </remarks>
|
||||
/// <param name="dataType"><see cref="IDataType"/> to delete</param>
|
||||
/// <param name="userId">Id of the user issuing the deletion</param>
|
||||
void Delete(IDataType dataType, int userId = 0);
|
||||
void Delete(IDataType dataType, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="IDataType"/> by its control Id
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace Umbraco.Core.Services
|
||||
IPartialView GetPartialView(string path);
|
||||
IPartialView GetPartialViewMacro(string path);
|
||||
IEnumerable<IPartialView> GetPartialViewMacros(params string[] names);
|
||||
Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = 0);
|
||||
Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = 0);
|
||||
bool DeletePartialView(string path, int userId = 0);
|
||||
bool DeletePartialViewMacro(string path, int userId = 0);
|
||||
Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = 0);
|
||||
Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = 0);
|
||||
Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId);
|
||||
bool DeletePartialView(string path, int userId = Constants.Security.SuperUserId);
|
||||
bool DeletePartialViewMacro(string path, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = Constants.Security.SuperUserId);
|
||||
Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = Constants.Security.SuperUserId);
|
||||
bool ValidatePartialView(PartialView partialView);
|
||||
bool ValidatePartialViewMacro(PartialView partialView);
|
||||
|
||||
@@ -45,14 +45,14 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="stylesheet"><see cref="Stylesheet"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the stylesheet</param>
|
||||
void SaveStylesheet(Stylesheet stylesheet, int userId = 0);
|
||||
void SaveStylesheet(Stylesheet stylesheet, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a stylesheet by its name
|
||||
/// </summary>
|
||||
/// <param name="path">Name incl. extension of the Stylesheet to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the stylesheet</param>
|
||||
void DeleteStylesheet(string path, int userId = 0);
|
||||
void DeleteStylesheet(string path, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a <see cref="Stylesheet"/>
|
||||
@@ -79,14 +79,14 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="script"><see cref="Script"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the script</param>
|
||||
void SaveScript(Script script, int userId = 0);
|
||||
void SaveScript(Script script, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a script by its name
|
||||
/// </summary>
|
||||
/// <param name="path">Name incl. extension of the Script to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the script</param>
|
||||
void DeleteScript(string path, int userId = 0);
|
||||
void DeleteScript(string path, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a <see cref="Script"/>
|
||||
@@ -187,7 +187,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="template"><see cref="ITemplate"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the template</param>
|
||||
void SaveTemplate(ITemplate template, int userId = 0);
|
||||
void SaveTemplate(ITemplate template, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a template for a content type
|
||||
@@ -198,16 +198,16 @@ namespace Umbraco.Core.Services
|
||||
/// <returns>
|
||||
/// The template created
|
||||
/// </returns>
|
||||
Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = 0);
|
||||
Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = 0);
|
||||
ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a template by its alias
|
||||
/// </summary>
|
||||
/// <param name="alias">Alias of the <see cref="ITemplate"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the template</param>
|
||||
void DeleteTemplate(string alias, int userId = 0);
|
||||
void DeleteTemplate(string alias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a <see cref="ITemplate"/>
|
||||
@@ -221,7 +221,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="templates">List of <see cref="Template"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user</param>
|
||||
void SaveTemplate(IEnumerable<ITemplate> templates, int userId = 0);
|
||||
void SaveTemplate(IEnumerable<ITemplate> templates, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content of a template as a stream.
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem"><see cref="IDictionaryItem"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the dictionary item</param>
|
||||
void Save(IDictionaryItem dictionaryItem, int userId = 0);
|
||||
void Save(IDictionaryItem dictionaryItem, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a <see cref="IDictionaryItem"/> object and its related translations
|
||||
@@ -94,7 +94,7 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem"><see cref="IDictionaryItem"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the dictionary item</param>
|
||||
void Delete(IDictionaryItem dictionaryItem, int userId = 0);
|
||||
void Delete(IDictionaryItem dictionaryItem, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="ILanguage"/> by its id
|
||||
@@ -153,14 +153,14 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="language"><see cref="ILanguage"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the language</param>
|
||||
void Save(ILanguage language, int userId = 0);
|
||||
void Save(ILanguage language, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a <see cref="ILanguage"/> by removing it and its usages from the db
|
||||
/// </summary>
|
||||
/// <param name="language"><see cref="ILanguage"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the language</param>
|
||||
void Delete(ILanguage language, int userId = 0);
|
||||
void Delete(ILanguage language, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the full dictionary key map.
|
||||
|
||||
@@ -39,14 +39,14 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="macro"><see cref="IMacro"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the macro</param>
|
||||
void Delete(IMacro macro, int userId = 0);
|
||||
void Delete(IMacro macro, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves an <see cref="IMacro"/>
|
||||
/// </summary>
|
||||
/// <param name="macro"><see cref="IMacro"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the macro</param>
|
||||
void Save(IMacro macro, int userId = 0);
|
||||
void Save(IMacro macro, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
///// <summary>
|
||||
///// Gets a list all available <see cref="IMacroPropertyType"/> plugins
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the media item</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
IMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = 0);
|
||||
IMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the media item</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
IMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = 0);
|
||||
IMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the media item</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
IMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = 0);
|
||||
IMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IMedia"/> object by Id
|
||||
@@ -152,14 +152,14 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="parentId">Id of the Media's new Parent</param>
|
||||
/// <param name="userId">Id of the User moving the Media</param>
|
||||
/// <returns>True if moving succeeded, otherwise False</returns>
|
||||
Attempt<OperationResult> Move(IMedia media, int parentId, int userId = 0);
|
||||
Attempt<OperationResult> Move(IMedia media, int parentId, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes an <see cref="IMedia"/> object by moving it to the Recycle Bin
|
||||
/// </summary>
|
||||
/// <param name="media">The <see cref="IMedia"/> to delete</param>
|
||||
/// <param name="userId">Id of the User deleting the Media</param>
|
||||
Attempt<OperationResult> MoveToRecycleBin(IMedia media, int userId = 0);
|
||||
Attempt<OperationResult> MoveToRecycleBin(IMedia media, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Empties the Recycle Bin by deleting all <see cref="IMedia"/> that resides in the bin
|
||||
@@ -172,7 +172,7 @@ namespace Umbraco.Core.Services
|
||||
/// <remarks>This needs extra care and attention as its potentially a dangerous and extensive operation</remarks>
|
||||
/// <param name="mediaTypeId">Id of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional Id of the user deleting Media</param>
|
||||
void DeleteMediaOfType(int mediaTypeId, int userId = 0);
|
||||
void DeleteMediaOfType(int mediaTypeId, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes all media of the specified types. All Descendants of deleted media that is not of these types is moved to Recycle Bin.
|
||||
@@ -180,7 +180,7 @@ namespace Umbraco.Core.Services
|
||||
/// <remarks>This needs extra care and attention as its potentially a dangerous and extensive operation</remarks>
|
||||
/// <param name="mediaTypeIds">Ids of the <see cref="IMediaType"/>s</param>
|
||||
/// <param name="userId">Optional Id of the user issuing the delete operation</param>
|
||||
void DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = 0);
|
||||
void DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Permanently deletes an <see cref="IMedia"/> object
|
||||
@@ -191,7 +191,7 @@ namespace Umbraco.Core.Services
|
||||
/// </remarks>
|
||||
/// <param name="media">The <see cref="IMedia"/> to delete</param>
|
||||
/// <param name="userId">Id of the User deleting the Media</param>
|
||||
Attempt<OperationResult> Delete(IMedia media, int userId = 0);
|
||||
Attempt<OperationResult> Delete(IMedia media, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a single <see cref="IMedia"/> object
|
||||
@@ -199,7 +199,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="media">The <see cref="IMedia"/> to save</param>
|
||||
/// <param name="userId">Id of the User saving the Media</param>
|
||||
/// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
|
||||
Attempt<OperationResult> Save(IMedia media, int userId = 0, bool raiseEvents = true);
|
||||
Attempt<OperationResult> Save(IMedia media, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Saves a collection of <see cref="IMedia"/> objects
|
||||
@@ -207,7 +207,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="medias">Collection of <see cref="IMedia"/> to save</param>
|
||||
/// <param name="userId">Id of the User saving the Media</param>
|
||||
/// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
|
||||
Attempt<OperationResult> Save(IEnumerable<IMedia> medias, int userId = 0, bool raiseEvents = true);
|
||||
Attempt<OperationResult> Save(IEnumerable<IMedia> medias, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IMedia"/> object by its 'UniqueId'
|
||||
@@ -250,7 +250,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="id">Id of the <see cref="IMedia"/> object to delete versions from</param>
|
||||
/// <param name="versionDate">Latest version date</param>
|
||||
/// <param name="userId">Optional Id of the User deleting versions of a Content object</param>
|
||||
void DeleteVersions(int id, DateTime versionDate, int userId = 0);
|
||||
void DeleteVersions(int id, DateTime versionDate, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Permanently deletes specific version(s) from an <see cref="IMedia"/> object.
|
||||
@@ -259,7 +259,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="versionId">Id of the version to delete</param>
|
||||
/// <param name="deletePriorVersions">Boolean indicating whether to delete versions prior to the versionId</param>
|
||||
/// <param name="userId">Optional Id of the User deleting versions of a Content object</param>
|
||||
void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = 0);
|
||||
void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IMedia"/> object from the path stored in the 'umbracoFile' property.
|
||||
@@ -304,7 +304,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="raiseEvents"></param>
|
||||
/// <returns>True if sorting succeeded, otherwise False</returns>
|
||||
bool Sort(IEnumerable<IMedia> items, int userId = 0, bool raiseEvents = true);
|
||||
bool Sort(IEnumerable<IMedia> items, int userId = Constants.Security.SuperUserId, bool raiseEvents = true);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
|
||||
@@ -319,7 +319,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the media item</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = 0);
|
||||
IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="IMedia"/> object using the alias of the <see cref="IMediaType"/>
|
||||
@@ -334,7 +334,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the media item</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = 0);
|
||||
IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content of a media as a stream.
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="packageDefinition"></param>
|
||||
/// <param name="packageFile"></param>
|
||||
/// <param name="userId"></param>
|
||||
IEnumerable<string> InstallCompiledPackageFiles(PackageDefinition packageDefinition, FileInfo packageFile, int userId = 0);
|
||||
IEnumerable<string> InstallCompiledPackageFiles(PackageDefinition packageDefinition, FileInfo packageFile, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Installs the data, entities, objects contained in an umbraco package file (zip)
|
||||
@@ -35,7 +35,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="packageDefinition"></param>
|
||||
/// <param name="packageFile"></param>
|
||||
/// <param name="userId"></param>
|
||||
InstallationSummary InstallCompiledPackageData(PackageDefinition packageDefinition, FileInfo packageFile, int userId = 0);
|
||||
InstallationSummary InstallCompiledPackageData(PackageDefinition packageDefinition, FileInfo packageFile, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Uninstalls all versions of the package by name
|
||||
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="packageName"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
UninstallationSummary UninstallPackage(string packageName, int userId = 0);
|
||||
UninstallationSummary UninstallPackage(string packageName, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Umbraco.Core.Services
|
||||
/// <param name="alreadyInstalled">If the package is an upgrade, the original/current PackageDefinition is returned</param>
|
||||
/// <returns></returns>
|
||||
PackageInstallType GetPackageInstallType(string packageName, SemVersion packageVersion, out PackageDefinition alreadyInstalled);
|
||||
void DeleteInstalledPackage(int packageId, int userId = 0);
|
||||
void DeleteInstalledPackage(int packageId, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Persists a package definition to storage
|
||||
@@ -89,7 +89,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
IEnumerable<PackageDefinition> GetAllCreatedPackages();
|
||||
PackageDefinition GetCreatedPackageById(int id);
|
||||
void DeleteCreatedPackage(int id, int userId = 0);
|
||||
void DeleteCreatedPackage(int id, int userId = Constants.Security.SuperUserId);
|
||||
|
||||
/// <summary>
|
||||
/// Persists a package definition to storage
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="contentTypeAlias">Alias of the <see cref="IContentType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the content</param>
|
||||
/// <returns><see cref="IContent"/></returns>
|
||||
public IContent Create(string name, Guid parentId, string contentTypeAlias, int userId = 0)
|
||||
public IContent Create(string name, Guid parentId, string contentTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="contentTypeAlias">The alias of the content type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the content.</param>
|
||||
/// <returns>The content object.</returns>
|
||||
public IContent Create(string name, int parentId, string contentTypeAlias, int userId = 0)
|
||||
public IContent Create(string name, int parentId, string contentTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="contentTypeAlias">The alias of the content type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the content.</param>
|
||||
/// <returns>The content object.</returns>
|
||||
public IContent Create(string name, IContent parent, string contentTypeAlias, int userId = 0)
|
||||
public IContent Create(string name, IContent parent, string contentTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="contentTypeAlias">The alias of the content type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the content.</param>
|
||||
/// <returns>The content object.</returns>
|
||||
public IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = 0)
|
||||
public IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="contentTypeAlias">The alias of the content type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the content.</param>
|
||||
/// <returns>The content object.</returns>
|
||||
public IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = 0)
|
||||
public IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -749,7 +749,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
#region Save, Publish, Unpublish
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationResult Save(IContent content, int userId = 0, bool raiseEvents = true)
|
||||
public OperationResult Save(IContent content, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var publishedState = content.PublishedState;
|
||||
if (publishedState != PublishedState.Published && publishedState != PublishedState.Unpublished)
|
||||
@@ -807,7 +807,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationResult Save(IEnumerable<IContent> contents, int userId = 0, bool raiseEvents = true)
|
||||
public OperationResult Save(IEnumerable<IContent> contents, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
var contentsA = contents.ToArray();
|
||||
@@ -847,7 +847,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public PublishResult SaveAndPublish(IContent content, string culture = "*", int userId = 0, bool raiseEvents = true)
|
||||
public PublishResult SaveAndPublish(IContent content, string culture = "*", int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -908,14 +908,15 @@ namespace Umbraco.Core.Services.Implement
|
||||
: new PublishResult(PublishResultType.FailedPublishNothingToPublish, evtMsgs, content);
|
||||
}
|
||||
|
||||
// TODO: currently, no way to know which one failed
|
||||
if (cultures.Select(content.PublishCulture).Any(isValid => !isValid))
|
||||
return new PublishResult(PublishResultType.FailedPublishContentInvalid, evtMsgs, content); //fixme: no way to know which one failed?
|
||||
return new PublishResult(PublishResultType.FailedPublishContentInvalid, evtMsgs, content);
|
||||
|
||||
return CommitDocumentChanges(content, userId, raiseEvents);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public PublishResult Unpublish(IContent content, string culture = "*", int userId = 0)
|
||||
public PublishResult Unpublish(IContent content, string culture = "*", int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
|
||||
@@ -980,7 +981,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <see cref="CommitDocumentChanges"/> to actually commit the changes to the database.</para>
|
||||
/// <para>The document is *always* saved, even when publishing fails.</para>
|
||||
/// </remarks>
|
||||
internal PublishResult CommitDocumentChanges(IContent content, int userId = 0, bool raiseEvents = true)
|
||||
internal PublishResult CommitDocumentChanges(IContent content, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -991,7 +992,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
private PublishResult CommitDocumentChangesInternal(IScope scope, IContent content, int userId = 0, bool raiseEvents = true, bool branchOne = false, bool branchRoot = false)
|
||||
private PublishResult CommitDocumentChangesInternal(IScope scope, IContent content, int userId = Constants.Security.SuperUserId, bool raiseEvents = true, bool branchOne = false, bool branchRoot = false)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
PublishResult publishResult = null;
|
||||
@@ -1055,9 +1056,10 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
// reset published state from temp values (publishing, unpublishing) to original value
|
||||
// (published, unpublished) in order to save the document, unchanged
|
||||
//TODO: why? this seems odd, were just setting the exact same value that it already has
|
||||
// instead do we want to just set the PublishState?
|
||||
// (published, unpublished) in order to save the document, unchanged - yes, this is odd,
|
||||
// but: (a) it means we don't reproduce the PublishState logic here and (b) setting the
|
||||
// PublishState to anything other than Publishing or Unpublishing - which is precisely
|
||||
// what we want to do here - throws
|
||||
content.Published = content.Published;
|
||||
}
|
||||
}
|
||||
@@ -1080,9 +1082,10 @@ namespace Umbraco.Core.Services.Implement
|
||||
else
|
||||
{
|
||||
// reset published state from temp values (publishing, unpublishing) to original value
|
||||
// (published, unpublished) in order to save the document, unchanged
|
||||
//TODO: why? this seems odd, were just setting the exact same value that it already has
|
||||
// instead do we want to just set the PublishState?
|
||||
// (published, unpublished) in order to save the document, unchanged - yes, this is odd,
|
||||
// but: (a) it means we don't reproduce the PublishState logic here and (b) setting the
|
||||
// PublishState to anything other than Publishing or Unpublishing - which is precisely
|
||||
// what we want to do here - throws
|
||||
content.Published = content.Published;
|
||||
}
|
||||
}
|
||||
@@ -1356,7 +1359,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string culture = "*", int userId = 0)
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string culture = "*", int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// note: EditedValue and PublishedValue are objects here, so it is important to .Equals()
|
||||
// and not to == them, else we would be comparing references, and that is a bad thing
|
||||
@@ -1398,7 +1401,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string[] cultures, int userId = 0)
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string[] cultures, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// note: EditedValue and PublishedValue are objects here, so it is important to .Equals()
|
||||
// and not to == them, else we would be comparing references, and that is a bad thing
|
||||
@@ -1438,7 +1441,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent document, bool force,
|
||||
Func<IContent, HashSet<string>> shouldPublish,
|
||||
Func<IContent, HashSet<string>, bool> publishCultures,
|
||||
int userId = 0)
|
||||
int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (shouldPublish == null) throw new ArgumentNullException(nameof(shouldPublish));
|
||||
if (publishCultures == null) throw new ArgumentNullException(nameof(publishCultures));
|
||||
@@ -1507,9 +1510,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
Audit(AuditType.Publish, userId, document.Id, "Branch published");
|
||||
|
||||
// trigger events for the entire branch
|
||||
// (SaveAndPublishBranchOne does *not* do it)
|
||||
scope.Events.Dispatch(TreeChanged, this, new TreeChange<IContent>(document, TreeChangeTypes.RefreshBranch).ToEventArgs());
|
||||
|
||||
//fixme - in the SaveAndPublishBranchOne -> CommitDocumentChangesInternal publishing/published is going to be raised there, so are we raising it 2x for the same thing?
|
||||
scope.Events.Dispatch(Published, this, new ContentPublishedEventArgs(publishedDocuments, false, evtMsgs), nameof(Published));
|
||||
|
||||
scope.Complete();
|
||||
@@ -1617,7 +1619,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="id">Id of the <see cref="IContent"/> object to delete versions from</param>
|
||||
/// <param name="versionDate">Latest version date</param>
|
||||
/// <param name="userId">Optional Id of the User deleting versions of a Content object</param>
|
||||
public void DeleteVersions(int id, DateTime versionDate, int userId = 0)
|
||||
public void DeleteVersions(int id, DateTime versionDate, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -1647,7 +1649,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="versionId">Id of the version to delete</param>
|
||||
/// <param name="deletePriorVersions">Boolean indicating whether to delete versions prior to the versionId</param>
|
||||
/// <param name="userId">Optional Id of the User deleting versions of a Content object</param>
|
||||
public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = 0)
|
||||
public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -1733,7 +1735,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="content">The <see cref="IContent"/> to move</param>
|
||||
/// <param name="parentId">Id of the Content's new Parent</param>
|
||||
/// <param name="userId">Optional Id of the User moving the Content</param>
|
||||
public void Move(IContent content, int parentId, int userId = 0)
|
||||
public void Move(IContent content, int parentId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// if moving to the recycle bin then use the proper method
|
||||
if (parentId == Constants.System.RecycleBinContent)
|
||||
@@ -1909,7 +1911,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="relateToOriginal">Boolean indicating whether the copy should be related to the original</param>
|
||||
/// <param name="userId">Optional Id of the User copying the Content</param>
|
||||
/// <returns>The newly created <see cref="IContent"/> object</returns>
|
||||
public IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = 0)
|
||||
public IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return Copy(content, parentId, relateToOriginal, true, userId);
|
||||
}
|
||||
@@ -1924,7 +1926,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="recursive">A value indicating whether to recursively copy children.</param>
|
||||
/// <param name="userId">Optional Id of the User copying the Content</param>
|
||||
/// <returns>The newly created <see cref="IContent"/> object</returns>
|
||||
public IContent Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = 0)
|
||||
public IContent Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var copy = content.DeepCloneWithResetIdentities();
|
||||
copy.ParentId = parentId;
|
||||
@@ -2027,7 +2029,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="content">The <see cref="IContent"/> to send to publication</param>
|
||||
/// <param name="userId">Optional Id of the User issuing the send to publication</param>
|
||||
/// <returns>True if sending publication was successful otherwise false</returns>
|
||||
public bool SendToPublication(IContent content, int userId = 0)
|
||||
public bool SendToPublication(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -2081,7 +2083,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="raiseEvents"></param>
|
||||
/// <returns>Result indicating what action was taken when handling the command.</returns>
|
||||
public OperationResult Sort(IEnumerable<IContent> items, int userId = 0, bool raiseEvents = true)
|
||||
public OperationResult Sort(IEnumerable<IContent> items, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -2110,7 +2112,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="raiseEvents"></param>
|
||||
/// <returns>Result indicating what action was taken when handling the command.</returns>
|
||||
public OperationResult Sort(IEnumerable<int> ids, int userId = 0, bool raiseEvents = true)
|
||||
public OperationResult Sort(IEnumerable<int> ids, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -2595,7 +2597,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </remarks>
|
||||
/// <param name="contentTypeIds">Id of the <see cref="IContentType"/></param>
|
||||
/// <param name="userId">Optional Id of the user issuing the delete operation</param>
|
||||
public void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = 0)
|
||||
public void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: This currently this is called from the ContentTypeService but that needs to change,
|
||||
// if we are deleting a content type, we should just delete the data and do this operation slightly differently.
|
||||
@@ -2671,7 +2673,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <remarks>This needs extra care and attention as its potentially a dangerous and extensive operation</remarks>
|
||||
/// <param name="contentTypeId">Id of the <see cref="IContentType"/></param>
|
||||
/// <param name="userId">Optional id of the user deleting the media</param>
|
||||
public void DeleteOfType(int contentTypeId, int userId = 0)
|
||||
public void DeleteOfType(int contentTypeId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
DeleteOfTypes(new[] { contentTypeId }, userId);
|
||||
}
|
||||
@@ -2729,7 +2731,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveBlueprint(IContent content, int userId = 0)
|
||||
public void SaveBlueprint(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
//always ensure the blueprint is at the root
|
||||
if (content.ParentId != -1)
|
||||
@@ -2755,7 +2757,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlueprint(IContent content, int userId = 0)
|
||||
public void DeleteBlueprint(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -2768,7 +2770,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private static readonly string[] ArrayOfOneNullString = { null };
|
||||
|
||||
public IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = 0)
|
||||
public IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (blueprint == null) throw new ArgumentNullException(nameof(blueprint));
|
||||
|
||||
@@ -2817,7 +2819,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = 0)
|
||||
public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -2844,7 +2846,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlueprintsOfType(int contentTypeId, int userId = 0)
|
||||
public void DeleteBlueprintsOfType(int contentTypeId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
DeleteBlueprintsOfTypes(new[] { contentTypeId }, userId);
|
||||
}
|
||||
@@ -2853,7 +2855,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#region Rollback
|
||||
|
||||
public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = 0)
|
||||
public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
public IContentTypeBaseService For(IContentBase contentBase)
|
||||
{
|
||||
if (contentBase == null) throw new ArgumentNullException(nameof(contentBase));
|
||||
switch (contentBase)
|
||||
{
|
||||
case IContent _:
|
||||
@@ -30,5 +31,12 @@ namespace Umbraco.Core.Services.Implement
|
||||
throw new ArgumentException($"Invalid contentBase type: {contentBase.GetType().FullName}" , nameof(contentBase));
|
||||
}
|
||||
}
|
||||
|
||||
// note: this should be a default interface method with C# 8
|
||||
public IContentTypeComposition GetContentTypeOf(IContentBase contentBase)
|
||||
{
|
||||
if (contentBase == null) throw new ArgumentNullException(nameof(contentBase));
|
||||
return For(contentBase)?.Get(contentBase.ContentTypeId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -376,7 +376,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#region Save
|
||||
|
||||
public void Save(TItem item, int userId = 0)
|
||||
public void Save(TItem item, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -414,7 +414,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(IEnumerable<TItem> items, int userId = 0)
|
||||
public void Save(IEnumerable<TItem> items, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var itemsA = items.ToArray();
|
||||
|
||||
@@ -460,7 +460,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#region Delete
|
||||
|
||||
public void Delete(TItem item, int userId = 0)
|
||||
public void Delete(TItem item, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -514,7 +514,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete(IEnumerable<TItem> items, int userId = 0)
|
||||
public void Delete(IEnumerable<TItem> items, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var itemsA = items.ToArray();
|
||||
|
||||
@@ -735,7 +735,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
protected Guid ContainerObjectType => EntityContainer.GetContainerObjectType(ContainedObjectType);
|
||||
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentId, string name, int userId = 0)
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentId, string name, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
@@ -775,7 +775,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = 0)
|
||||
public Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -869,7 +869,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public Attempt<OperationResult> DeleteContainer(int containerId, int userId = 0)
|
||||
public Attempt<OperationResult> DeleteContainer(int containerId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
@@ -906,7 +906,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = 0)
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#region Containers
|
||||
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentId, string name, int userId = 0)
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> CreateContainer(int parentId, string name, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
@@ -119,7 +119,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = 0)
|
||||
public Attempt<OperationResult> SaveContainer(EntityContainer container, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
return OperationResult.Attempt.Succeed(evtMsgs);
|
||||
}
|
||||
|
||||
public Attempt<OperationResult> DeleteContainer(int containerId, int userId = 0)
|
||||
public Attempt<OperationResult> DeleteContainer(int containerId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
@@ -186,7 +186,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
return OperationResult.Attempt.Succeed(evtMsgs);
|
||||
}
|
||||
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = 0)
|
||||
public Attempt<OperationResult<OperationResultType, EntityContainer>> RenameContainer(int id, string name, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
@@ -331,7 +331,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="dataType"><see cref="IDataType"/> to save</param>
|
||||
/// <param name="userId">Id of the user issuing the save</param>
|
||||
public void Save(IDataType dataType, int userId = 0)
|
||||
public void Save(IDataType dataType, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
dataType.CreatorId = userId;
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="dataTypeDefinitions"><see cref="IDataType"/> to save</param>
|
||||
/// <param name="userId">Id of the user issuing the save</param>
|
||||
public void Save(IEnumerable<IDataType> dataTypeDefinitions, int userId = 0)
|
||||
public void Save(IEnumerable<IDataType> dataTypeDefinitions, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
Save(dataTypeDefinitions, userId, true);
|
||||
}
|
||||
@@ -413,7 +413,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </remarks>
|
||||
/// <param name="dataType"><see cref="IDataType"/> to delete</param>
|
||||
/// <param name="userId">Optional Id of the user issuing the deletion</param>
|
||||
public void Delete(IDataType dataType, int userId = 0)
|
||||
public void Delete(IDataType dataType, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="stylesheet"><see cref="Stylesheet"/> to save</param>
|
||||
/// <param name="userId"></param>
|
||||
public void SaveStylesheet(Stylesheet stylesheet, int userId = 0)
|
||||
public void SaveStylesheet(Stylesheet stylesheet, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="path">Name incl. extension of the Stylesheet to delete</param>
|
||||
/// <param name="userId"></param>
|
||||
public void DeleteStylesheet(string path, int userId = 0)
|
||||
public void DeleteStylesheet(string path, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -217,7 +217,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="script"><see cref="Script"/> to save</param>
|
||||
/// <param name="userId"></param>
|
||||
public void SaveScript(Script script, int userId = 0)
|
||||
public void SaveScript(Script script, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -242,7 +242,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="path">Name incl. extension of the Script to delete</param>
|
||||
/// <param name="userId"></param>
|
||||
public void DeleteScript(string path, int userId = 0)
|
||||
public void DeleteScript(string path, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -338,7 +338,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <returns>
|
||||
/// The template created
|
||||
/// </returns>
|
||||
public Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = 0)
|
||||
public Attempt<OperationResult<OperationResultType, ITemplate>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var template = new Template(contentTypeName,
|
||||
//NOTE: We are NOT passing in the content type alias here, we want to use it's name since we don't
|
||||
@@ -395,7 +395,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="masterTemplate"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = 0)
|
||||
public ITemplate CreateTemplateWithIdentity(string name, string alias, string content, ITemplate masterTemplate = null, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// file might already be on disk, if so grab the content to avoid overwriting
|
||||
var template = new Template(name, alias)
|
||||
@@ -529,7 +529,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="template"><see cref="Template"/> to save</param>
|
||||
/// <param name="userId"></param>
|
||||
public void SaveTemplate(ITemplate template, int userId = 0)
|
||||
public void SaveTemplate(ITemplate template, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -553,7 +553,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="templates">List of <see cref="Template"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user</param>
|
||||
public void SaveTemplate(IEnumerable<ITemplate> templates, int userId = 0)
|
||||
public void SaveTemplate(IEnumerable<ITemplate> templates, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var templatesA = templates.ToArray();
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
@@ -579,7 +579,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="alias">Alias of the <see cref="ITemplate"/> to delete</param>
|
||||
/// <param name="userId"></param>
|
||||
public void DeleteTemplate(string alias, int userId = 0)
|
||||
public void DeleteTemplate(string alias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -723,17 +723,17 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = 0)
|
||||
public Attempt<IPartialView> CreatePartialView(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return CreatePartialViewMacro(partialView, PartialViewType.PartialView, snippetName, userId);
|
||||
}
|
||||
|
||||
public Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = 0)
|
||||
public Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, string snippetName = null, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return CreatePartialViewMacro(partialView, PartialViewType.PartialViewMacro, snippetName, userId);
|
||||
}
|
||||
|
||||
private Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, PartialViewType partialViewType, string snippetName = null, int userId = 0)
|
||||
private Attempt<IPartialView> CreatePartialViewMacro(IPartialView partialView, PartialViewType partialViewType, string snippetName = null, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
string partialViewHeader;
|
||||
switch (partialViewType)
|
||||
@@ -799,17 +799,17 @@ namespace Umbraco.Core.Services.Implement
|
||||
return Attempt<IPartialView>.Succeed(partialView);
|
||||
}
|
||||
|
||||
public bool DeletePartialView(string path, int userId = 0)
|
||||
public bool DeletePartialView(string path, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return DeletePartialViewMacro(path, PartialViewType.PartialView, userId);
|
||||
}
|
||||
|
||||
public bool DeletePartialViewMacro(string path, int userId = 0)
|
||||
public bool DeletePartialViewMacro(string path, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return DeletePartialViewMacro(path, PartialViewType.PartialViewMacro, userId);
|
||||
}
|
||||
|
||||
private bool DeletePartialViewMacro(string path, PartialViewType partialViewType, int userId = 0)
|
||||
private bool DeletePartialViewMacro(string path, PartialViewType partialViewType, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -839,17 +839,17 @@ namespace Umbraco.Core.Services.Implement
|
||||
return true;
|
||||
}
|
||||
|
||||
public Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = 0)
|
||||
public Attempt<IPartialView> SavePartialView(IPartialView partialView, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return SavePartialView(partialView, PartialViewType.PartialView, userId);
|
||||
}
|
||||
|
||||
public Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = 0)
|
||||
public Attempt<IPartialView> SavePartialViewMacro(IPartialView partialView, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
return SavePartialView(partialView, PartialViewType.PartialViewMacro, userId);
|
||||
}
|
||||
|
||||
private Attempt<IPartialView> SavePartialView(IPartialView partialView, PartialViewType partialViewType, int userId = 0)
|
||||
private Attempt<IPartialView> SavePartialView(IPartialView partialView, PartialViewType partialViewType, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem"><see cref="IDictionaryItem"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the dictionary item</param>
|
||||
public void Save(IDictionaryItem dictionaryItem, int userId = 0)
|
||||
public void Save(IDictionaryItem dictionaryItem, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -256,7 +256,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="dictionaryItem"><see cref="IDictionaryItem"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the dictionary item</param>
|
||||
public void Delete(IDictionaryItem dictionaryItem, int userId = 0)
|
||||
public void Delete(IDictionaryItem dictionaryItem, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -356,7 +356,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="language"><see cref="ILanguage"/> to save</param>
|
||||
/// <param name="userId">Optional id of the user saving the language</param>
|
||||
public void Save(ILanguage language, int userId = 0)
|
||||
public void Save(ILanguage language, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -409,7 +409,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="language"><see cref="ILanguage"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the language</param>
|
||||
public void Delete(ILanguage language, int userId = 0)
|
||||
public void Delete(ILanguage language, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="macro"><see cref="IMacro"/> to delete</param>
|
||||
/// <param name="userId">Optional id of the user deleting the macro</param>
|
||||
public void Delete(IMacro macro, int userId = 0)
|
||||
public void Delete(IMacro macro, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="macro"><see cref="IMacro"/> to save</param>
|
||||
/// <param name="userId">Optional Id of the user deleting the macro</param>
|
||||
public void Save(IMacro macro, int userId = 0)
|
||||
public void Save(IMacro macro, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="mediaTypeAlias">Alias of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user creating the media item</param>
|
||||
/// <returns><see cref="IMedia"/></returns>
|
||||
public IMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = 0)
|
||||
public IMedia CreateMedia(string name, Guid parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var parent = GetById(parentId);
|
||||
return CreateMedia(name, parent, mediaTypeAlias, userId);
|
||||
@@ -130,7 +130,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="mediaTypeAlias">The alias of the media type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the media.</param>
|
||||
/// <returns>The media object.</returns>
|
||||
public IMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = 0)
|
||||
public IMedia CreateMedia(string name, int parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var mediaType = GetMediaType(mediaTypeAlias);
|
||||
if (mediaType == null)
|
||||
@@ -160,7 +160,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="mediaTypeAlias">The alias of the media type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the media.</param>
|
||||
/// <returns>The media object.</returns>
|
||||
public IMedia CreateMedia(string name, string mediaTypeAlias, int userId = 0)
|
||||
public IMedia CreateMedia(string name, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// not locking since not saving anything
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="mediaTypeAlias">The alias of the media type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the media.</param>
|
||||
/// <returns>The media object.</returns>
|
||||
public IMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = 0)
|
||||
public IMedia CreateMedia(string name, IMedia parent, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (parent == null) throw new ArgumentNullException(nameof(parent));
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="mediaTypeAlias">The alias of the media type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the media.</param>
|
||||
/// <returns>The media object.</returns>
|
||||
public IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = 0)
|
||||
public IMedia CreateMediaWithIdentity(string name, int parentId, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -251,7 +251,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="mediaTypeAlias">The alias of the media type.</param>
|
||||
/// <param name="userId">The optional id of the user creating the media.</param>
|
||||
/// <returns>The media object.</returns>
|
||||
public IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = 0)
|
||||
public IMedia CreateMediaWithIdentity(string name, IMedia parent, string mediaTypeAlias, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (parent == null) throw new ArgumentNullException(nameof(parent));
|
||||
|
||||
@@ -632,7 +632,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="media">The <see cref="IMedia"/> to save</param>
|
||||
/// <param name="userId">Id of the User saving the Media</param>
|
||||
/// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
|
||||
public Attempt<OperationResult> Save(IMedia media, int userId = 0, bool raiseEvents = true)
|
||||
public Attempt<OperationResult> Save(IMedia media, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -677,7 +677,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="medias">Collection of <see cref="IMedia"/> to save</param>
|
||||
/// <param name="userId">Id of the User saving the Media</param>
|
||||
/// <param name="raiseEvents">Optional boolean indicating whether or not to raise events.</param>
|
||||
public Attempt<OperationResult> Save(IEnumerable<IMedia> medias, int userId = 0, bool raiseEvents = true)
|
||||
public Attempt<OperationResult> Save(IEnumerable<IMedia> medias, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
var mediasA = medias.ToArray();
|
||||
@@ -724,7 +724,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="media">The <see cref="IMedia"/> to delete</param>
|
||||
/// <param name="userId">Id of the User deleting the Media</param>
|
||||
public Attempt<OperationResult> Delete(IMedia media, int userId = 0)
|
||||
public Attempt<OperationResult> Delete(IMedia media, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -785,7 +785,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="id">Id of the <see cref="IMedia"/> object to delete versions from</param>
|
||||
/// <param name="versionDate">Latest version date</param>
|
||||
/// <param name="userId">Optional Id of the User deleting versions of a Media object</param>
|
||||
public void DeleteVersions(int id, DateTime versionDate, int userId = 0)
|
||||
public void DeleteVersions(int id, DateTime versionDate, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -809,7 +809,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteVersions(IScope scope, bool wlock, int id, DateTime versionDate, int userId = 0)
|
||||
private void DeleteVersions(IScope scope, bool wlock, int id, DateTime versionDate, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var args = new DeleteRevisionsEventArgs(id, dateToRetain: versionDate);
|
||||
if (scope.Events.DispatchCancelable(DeletingVersions, this, args))
|
||||
@@ -832,7 +832,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="versionId">Id of the version to delete</param>
|
||||
/// <param name="deletePriorVersions">Boolean indicating whether to delete versions prior to the versionId</param>
|
||||
/// <param name="userId">Optional Id of the User deleting versions of a Media object</param>
|
||||
public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = 0)
|
||||
public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -872,7 +872,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </summary>
|
||||
/// <param name="media">The <see cref="IMedia"/> to delete</param>
|
||||
/// <param name="userId">Id of the User deleting the Media</param>
|
||||
public Attempt<OperationResult> MoveToRecycleBin(IMedia media, int userId = 0)
|
||||
public Attempt<OperationResult> MoveToRecycleBin(IMedia media, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
var moves = new List<Tuple<IMedia, string>>();
|
||||
@@ -916,7 +916,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="media">The <see cref="IMedia"/> to move</param>
|
||||
/// <param name="parentId">Id of the Media's new Parent</param>
|
||||
/// <param name="userId">Id of the User moving the Media</param>
|
||||
public Attempt<OperationResult> Move(IMedia media, int parentId, int userId = 0)
|
||||
public Attempt<OperationResult> Move(IMedia media, int parentId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -1084,7 +1084,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="raiseEvents"></param>
|
||||
/// <returns>True if sorting succeeded, otherwise False</returns>
|
||||
public bool Sort(IEnumerable<IMedia> items, int userId = 0, bool raiseEvents = true)
|
||||
public bool Sort(IEnumerable<IMedia> items, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var itemsA = items.ToArray();
|
||||
if (itemsA.Length == 0) return true;
|
||||
@@ -1273,7 +1273,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </remarks>
|
||||
/// <param name="mediaTypeIds">Id of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user deleting the media</param>
|
||||
public void DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = 0)
|
||||
public void DeleteMediaOfTypes(IEnumerable<int> mediaTypeIds, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: This currently this is called from the ContentTypeService but that needs to change,
|
||||
// if we are deleting a content type, we should just delete the data and do this operation slightly differently.
|
||||
@@ -1338,7 +1338,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <remarks>This needs extra care and attention as its potentially a dangerous and extensive operation</remarks>
|
||||
/// <param name="mediaTypeId">Id of the <see cref="IMediaType"/></param>
|
||||
/// <param name="userId">Optional id of the user deleting the media</param>
|
||||
public void DeleteMediaOfType(int mediaTypeId, int userId = 0)
|
||||
public void DeleteMediaOfType(int mediaTypeId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
DeleteMediaOfTypes(new[] { mediaTypeId }, userId);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
public CompiledPackage GetCompiledPackageInfo(FileInfo packageFile) => _packageInstallation.ReadPackage(packageFile);
|
||||
|
||||
public IEnumerable<string> InstallCompiledPackageFiles(PackageDefinition packageDefinition, FileInfo packageFile, int userId = 0)
|
||||
public IEnumerable<string> InstallCompiledPackageFiles(PackageDefinition packageDefinition, FileInfo packageFile, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (packageDefinition == null) throw new ArgumentNullException(nameof(packageDefinition));
|
||||
if (packageDefinition.Id == default) throw new ArgumentException("The package definition has not been persisted");
|
||||
@@ -118,7 +118,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
return files;
|
||||
}
|
||||
|
||||
public InstallationSummary InstallCompiledPackageData(PackageDefinition packageDefinition, FileInfo packageFile, int userId = 0)
|
||||
public InstallationSummary InstallCompiledPackageData(PackageDefinition packageDefinition, FileInfo packageFile, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
if (packageDefinition == null) throw new ArgumentNullException(nameof(packageDefinition));
|
||||
if (packageDefinition.Id == default) throw new ArgumentException("The package definition has not been persisted");
|
||||
@@ -141,7 +141,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
return summary;
|
||||
}
|
||||
|
||||
public UninstallationSummary UninstallPackage(string packageName, int userId = 0)
|
||||
public UninstallationSummary UninstallPackage(string packageName, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
//this is ordered by descending version
|
||||
var allPackageVersions = GetInstalledPackageByName(packageName)?.ToList();
|
||||
@@ -187,7 +187,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#region Created/Installed Package Repositories
|
||||
|
||||
public void DeleteCreatedPackage(int id, int userId = 0)
|
||||
public void DeleteCreatedPackage(int id, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var package = GetCreatedPackageById(id);
|
||||
if (package == null) return;
|
||||
@@ -236,7 +236,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
public bool SaveInstalledPackage(PackageDefinition definition) => _installedPackages.SavePackage(definition);
|
||||
|
||||
public void DeleteInstalledPackage(int packageId, int userId = 0)
|
||||
public void DeleteInstalledPackage(int packageId, int userId = Constants.Security.SuperUserId)
|
||||
{
|
||||
var package = GetInstalledPackageById(packageId);
|
||||
if (package == null) return;
|
||||
|
||||
@@ -55,25 +55,25 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!-- note: NuGet deals with transitive references now -->
|
||||
<PackageReference Include="AutoMapper" Version="7.0.1" />
|
||||
<PackageReference Include="LightInject" Version="5.1.2" />
|
||||
<PackageReference Include="AutoMapper" Version="8.0.0" />
|
||||
<PackageReference Include="LightInject" Version="5.4.0" />
|
||||
<PackageReference Include="LightInject.Annotation" Version="1.1.0" />
|
||||
<PackageReference Include="LightInject.Web" Version="2.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.Identity.Core">
|
||||
<Version>2.2.2</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client">
|
||||
<Version>5.2.6</Version>
|
||||
<Version>5.2.7</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Owin">
|
||||
<Version>4.0.0</Version>
|
||||
<Version>4.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="MiniProfiler" Version="3.2.0.157" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="MiniProfiler" Version="4.0.138" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="NPoco" Version="3.9.4" />
|
||||
<PackageReference Include="Semver" Version="2.0.4" />
|
||||
<PackageReference Include="Serilog">
|
||||
<Version>2.7.1</Version>
|
||||
<Version>2.8.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Serilog.Enrichers.Process">
|
||||
<Version>2.0.1</Version>
|
||||
@@ -88,7 +88,7 @@
|
||||
<Version>1.0.0</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Serilog.Formatting.Compact.Reader">
|
||||
<Version>1.0.2</Version>
|
||||
<Version>1.0.3</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Serilog.Settings.AppSettings">
|
||||
<Version>2.2.2</Version>
|
||||
@@ -302,6 +302,7 @@
|
||||
<Compile Include="DisposableObjectSlim.cs" />
|
||||
<Compile Include="EnumExtensions.cs" />
|
||||
<Compile Include="Events\CancellableEnumerableObjectEventArgs.cs" />
|
||||
<Compile Include="Events\CancellableObjectEventArgsOfTEventObject.cs" />
|
||||
<Compile Include="Events\ContentPublishedEventArgs.cs" />
|
||||
<Compile Include="Events\ContentPublishingEventArgs.cs" />
|
||||
<Compile Include="Events\ContentSavedEventArgs.cs" />
|
||||
@@ -473,6 +474,7 @@
|
||||
<Compile Include="Persistence\Mappers\AuditEntryMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\AuditItemMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\ConsentMapper.cs" />
|
||||
<Compile Include="Persistence\Mappers\SimpleContentTypeMapper.cs" />
|
||||
<Compile Include="Persistence\Repositories\IAuditEntryRepository.cs" />
|
||||
<Compile Include="Persistence\Repositories\IConsentRepository.cs" />
|
||||
<Compile Include="Persistence\Repositories\Implement\AuditEntryRepository.cs" />
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<ItemGroup>
|
||||
<!-- note: NuGet deals with transitive references now -->
|
||||
<PackageReference Include="Examine" Version="1.0.0-beta078" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="NPoco" Version="3.9.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -64,23 +64,23 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0"/>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
@@ -88,7 +88,7 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
@@ -100,11 +100,11 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
|
||||
@@ -264,7 +264,7 @@ AnotherContentFinder
|
||||
public void Resolves_Assigned_Mappers()
|
||||
{
|
||||
var foundTypes1 = _typeLoader.GetAssignedMapperTypes();
|
||||
Assert.AreEqual(29, foundTypes1.Count());
|
||||
Assert.AreEqual(30, foundTypes1.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,22 +1,60 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Composing.Composers;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
|
||||
namespace Umbraco.Tests.Models
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentExtensionsTests : UmbracoTestBase
|
||||
{
|
||||
#region Others
|
||||
private IContentTypeService _contentTypeService;
|
||||
|
||||
protected override void Compose()
|
||||
{
|
||||
base.Compose();
|
||||
|
||||
Composition.Register(_ => Mock.Of<ILogger>());
|
||||
Composition.ComposeFileSystems();
|
||||
|
||||
Composition.Register(_ => Mock.Of<IDataTypeService>());
|
||||
Composition.Register(_ => Mock.Of<IContentSection>());
|
||||
|
||||
// all this is required so we can validate properties...
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>()) { Alias = "test" };
|
||||
Composition.Register(_ => new DataEditorCollection(new[] { editor }));
|
||||
Composition.Register<PropertyEditorCollection>();
|
||||
var dataType = Mock.Of<IDataType>();
|
||||
Mock.Get(dataType).Setup(x => x.Configuration).Returns(() => new object());
|
||||
var dataTypeService = Mock.Of<IDataTypeService>();
|
||||
Mock.Get(dataTypeService)
|
||||
.Setup(x => x.GetDataType(It.IsAny<int>()))
|
||||
.Returns(() => dataType);
|
||||
|
||||
_contentTypeService = Mock.Of<IContentTypeService>();
|
||||
var mediaTypeService = Mock.Of<IMediaTypeService>();
|
||||
var memberTypeService = Mock.Of<IMemberTypeService>();
|
||||
Composition.Register(_ => ServiceContext.CreatePartial(dataTypeService: dataTypeService, contentTypeBaseServiceProvider: new ContentTypeBaseServiceProvider(_contentTypeService, mediaTypeService, memberTypeService)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DirtyProperty_Reset_Clears_SavedPublishedState()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
content.PublishedState = PublishedState.Publishing;
|
||||
@@ -30,6 +68,8 @@ namespace Umbraco.Tests.Models
|
||||
public void DirtyProperty_OnlyIfActuallyChanged_Content()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// if you assign a content property with its value it is not dirty
|
||||
@@ -52,6 +92,8 @@ namespace Umbraco.Tests.Models
|
||||
public void DirtyProperty_OnlyIfActuallyChanged_User()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
var prop = content.Properties.First();
|
||||
|
||||
@@ -76,6 +118,8 @@ namespace Umbraco.Tests.Models
|
||||
public void DirtyProperty_UpdateDate()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
var prop = content.Properties.First();
|
||||
|
||||
@@ -99,6 +143,8 @@ namespace Umbraco.Tests.Models
|
||||
public void DirtyProperty_WasDirty_ContentProperty()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
content.ResetDirtyProperties(false);
|
||||
Assert.IsFalse(content.IsDirty());
|
||||
@@ -126,6 +172,8 @@ namespace Umbraco.Tests.Models
|
||||
public void DirtyProperty_WasDirty_ContentSortOrder()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
content.ResetDirtyProperties(false);
|
||||
Assert.IsFalse(content.IsDirty());
|
||||
@@ -153,6 +201,8 @@ namespace Umbraco.Tests.Models
|
||||
public void DirtyProperty_WasDirty_UserProperty()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
var prop = content.Properties.First();
|
||||
content.ResetDirtyProperties(false);
|
||||
@@ -178,7 +228,5 @@ namespace Umbraco.Tests.Models
|
||||
//Assert.IsFalse(content.WasDirty()); // not impacted by user properties
|
||||
Assert.IsTrue(content.WasDirty()); // now it is!
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ using Umbraco.Core.Models.Entities;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Serialization;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Tests.Testing;
|
||||
@@ -28,6 +29,8 @@ namespace Umbraco.Tests.Models
|
||||
[TestFixture]
|
||||
public class ContentTests : UmbracoTestBase
|
||||
{
|
||||
private IContentTypeService _contentTypeService;
|
||||
|
||||
protected override void Compose()
|
||||
{
|
||||
base.Compose();
|
||||
@@ -48,19 +51,25 @@ namespace Umbraco.Tests.Models
|
||||
Mock.Get(dataTypeService)
|
||||
.Setup(x => x.GetDataType(It.IsAny<int>()))
|
||||
.Returns(() => dataType);
|
||||
Composition.Register(_ => ServiceContext.CreatePartial(dataTypeService: dataTypeService));
|
||||
|
||||
_contentTypeService = Mock.Of<IContentTypeService>();
|
||||
var mediaTypeService = Mock.Of<IMediaTypeService>();
|
||||
var memberTypeService = Mock.Of<IMemberTypeService>();
|
||||
Composition.Register(_ => ServiceContext.CreatePartial(dataTypeService: dataTypeService, contentTypeBaseServiceProvider: new ContentTypeBaseServiceProvider(_contentTypeService, mediaTypeService, memberTypeService)));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Variant_Culture_Names_Track_Dirty_Changes()
|
||||
{
|
||||
var contentType = new ContentType(-1) { Alias = "contentType" };
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = new Content("content", -1, contentType) { Id = 1, VersionId = 1 };
|
||||
|
||||
const string langFr = "fr-FR";
|
||||
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
|
||||
Assert.IsFalse(content.IsPropertyDirty("CultureInfos")); //hasn't been changed
|
||||
|
||||
Thread.Sleep(500); //The "Date" wont be dirty if the test runs too fast since it will be the same date
|
||||
@@ -123,6 +132,7 @@ namespace Umbraco.Tests.Models
|
||||
|
||||
//ensure that nothing is marked as dirty
|
||||
contentType.ResetDirtyProperties(false);
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
@@ -138,6 +148,8 @@ namespace Umbraco.Tests.Models
|
||||
public void All_Dirty_Properties_Get_Reset()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
content.ResetDirtyProperties(false);
|
||||
@@ -154,6 +166,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -167,6 +181,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -183,6 +199,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -199,6 +217,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
content.Id = 10;
|
||||
content.Key = new Guid("29181B97-CB8F-403F-86DE-5FEB497F4800");
|
||||
@@ -278,6 +298,8 @@ namespace Umbraco.Tests.Models
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
contentType.Id = 99;
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
content.SetCultureName("Hello", "en-US");
|
||||
@@ -387,6 +409,8 @@ namespace Umbraco.Tests.Models
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
contentType.Id = 99;
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
content.SetCultureName("Hello", "en-US");
|
||||
@@ -458,6 +482,8 @@ namespace Umbraco.Tests.Models
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
contentType.Id = 99;
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
var i = 200;
|
||||
foreach (var property in content.Properties)
|
||||
@@ -509,10 +535,12 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
content.PropertyValues(new {title = "This is the new title"});
|
||||
content.PropertyValues(new { title = "This is the new title"});
|
||||
|
||||
// Assert
|
||||
Assert.That(content.Properties.Any(), Is.True);
|
||||
@@ -527,6 +555,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -543,14 +573,12 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
contentType.PropertyGroups.Add(new PropertyGroup(true) { Name = "Test Group", SortOrder = 3 });
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.PropertyGroups.Count, Is.EqualTo(3));
|
||||
Assert.That(content.PropertyGroups.Count(), Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -573,7 +601,6 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
contentType.PropertyGroups["Content"].PropertyTypes.Add(new PropertyType("test", ValueStorageType.Ntext, "subtitle")
|
||||
@@ -587,7 +614,6 @@ namespace Umbraco.Tests.Models
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.PropertyGroups["Content"].PropertyTypes.Count, Is.EqualTo(3));
|
||||
Assert.That(content.PropertyGroups.First(x => x.Name == "Content").PropertyTypes.Count, Is.EqualTo(3));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -595,6 +621,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -617,6 +645,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -637,8 +667,6 @@ namespace Umbraco.Tests.Models
|
||||
|
||||
// Assert
|
||||
Assert.That(content.Properties.Count, Is.EqualTo(5));
|
||||
Assert.That(content.PropertyTypes.Count(), Is.EqualTo(5));
|
||||
Assert.That(content.PropertyGroups.Count(), Is.EqualTo(3));
|
||||
Assert.That(content.Properties["subtitle"].GetValue(), Is.EqualTo("Subtitle Test"));
|
||||
Assert.That(content.Properties["title"].GetValue(), Is.EqualTo("Textpage textpage"));
|
||||
}
|
||||
@@ -648,6 +676,8 @@ namespace Umbraco.Tests.Models
|
||||
{
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act - note that the PropertyType's properties like SortOrder is not updated through the Content object
|
||||
@@ -669,6 +699,8 @@ namespace Umbraco.Tests.Models
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -676,8 +708,6 @@ namespace Umbraco.Tests.Models
|
||||
|
||||
// Assert
|
||||
Assert.That(content.Properties.Contains("author"), Is.True);
|
||||
Assert.That(content.PropertyGroups.Count(), Is.EqualTo(1));
|
||||
Assert.That(content.PropertyTypes.Count(), Is.EqualTo(3));
|
||||
//Note: There was 4 properties, after changing ContentType 1 has been added (no properties are deleted)
|
||||
Assert.That(content.Properties.Count, Is.EqualTo(5));
|
||||
}
|
||||
@@ -688,6 +718,8 @@ namespace Umbraco.Tests.Models
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -705,6 +737,8 @@ namespace Umbraco.Tests.Models
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
var simpleContentType = MockedContentTypes.CreateSimpleContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
// Act
|
||||
@@ -723,6 +757,7 @@ namespace Umbraco.Tests.Models
|
||||
public void Can_Change_ContentType_On_Content_And_Clear_Old_PropertyTypes()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
//// Arrange
|
||||
//var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
@@ -742,6 +777,8 @@ namespace Umbraco.Tests.Models
|
||||
public void Can_Verify_Content_Is_Published()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "Textpage", -1);
|
||||
|
||||
content.ResetDirtyProperties();
|
||||
@@ -811,6 +848,8 @@ namespace Umbraco.Tests.Models
|
||||
// Arrange
|
||||
var contentType = MockedContentTypes.CreateTextPageContentType();
|
||||
contentType.ResetDirtyProperties(); //reset
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateTextpageContent(contentType, "test", -1);
|
||||
content.ResetDirtyProperties();
|
||||
|
||||
|
||||
@@ -121,16 +121,16 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
break;
|
||||
case 1:
|
||||
map
|
||||
.ForMember(dest => dest.ValueString, opt => opt.ResolveUsing<MemberValueResolver, string>(src => src.ValueString));
|
||||
.ForMember(dest => dest.ValueString, opt => opt.MapFrom<MemberValueResolver, string>(src => src.ValueString));
|
||||
break;
|
||||
case 2:
|
||||
map
|
||||
.ForMember(dest => dest.ValueString, opt => opt.ResolveUsing<ValueResolver>());
|
||||
.ForMember(dest => dest.ValueString, opt => opt.MapFrom<ValueResolver>());
|
||||
break;
|
||||
case 3:
|
||||
// in most cases that should be perfectly enough?
|
||||
map
|
||||
.ForMember(dest => dest.ValueString, opt => opt.ResolveUsing(source => "!!" + source.ValueString + "!!"));
|
||||
.ForMember(dest => dest.ValueString, opt => opt.MapFrom(source => "!!" + source.ValueString + "!!"));
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(ver));
|
||||
|
||||
@@ -4,15 +4,20 @@ using AutoMapper;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Composing.Composers;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
using Current = Umbraco.Web.Composing.Current;
|
||||
|
||||
namespace Umbraco.Tests.Models.Mapping
|
||||
@@ -21,12 +26,37 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
[UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
|
||||
public class ContentWebModelMappingTests : TestWithDatabaseBase
|
||||
{
|
||||
private IContentTypeService _contentTypeService;
|
||||
|
||||
|
||||
protected override void Compose()
|
||||
{
|
||||
base.Compose();
|
||||
|
||||
Composition.RegisterUnique(f => Mock.Of<ICultureDictionaryFactory>());
|
||||
Composition.RegisterUnique(f => Mock.Of<IContentTypeService>());
|
||||
|
||||
Composition.Register(_ => Mock.Of<ILogger>());
|
||||
Composition.ComposeFileSystems();
|
||||
|
||||
Composition.Register(_ => Mock.Of<IDataTypeService>());
|
||||
Composition.Register(_ => Mock.Of<IContentSection>());
|
||||
|
||||
// all this is required so we can validate properties...
|
||||
var editor = new TextboxPropertyEditor(Mock.Of<ILogger>()) { Alias = "test" };
|
||||
Composition.Register(_ => new DataEditorCollection(new[] { editor }));
|
||||
Composition.Register<PropertyEditorCollection>();
|
||||
var dataType = Mock.Of<IDataType>();
|
||||
Mock.Get(dataType).Setup(x => x.Configuration).Returns(() => new object());
|
||||
var dataTypeService = Mock.Of<IDataTypeService>();
|
||||
Mock.Get(dataTypeService)
|
||||
.Setup(x => x.GetDataType(It.IsAny<int>()))
|
||||
.Returns(() => dataType);
|
||||
|
||||
_contentTypeService = Mock.Of<IContentTypeService>();
|
||||
var mediaTypeService = Mock.Of<IMediaTypeService>();
|
||||
var memberTypeService = Mock.Of<IMemberTypeService>();
|
||||
Composition.RegisterUnique(_ => _contentTypeService);
|
||||
Composition.Register(_ => ServiceContext.CreatePartial(dataTypeService: dataTypeService, contentTypeBaseServiceProvider: new ContentTypeBaseServiceProvider(_contentTypeService, mediaTypeService, memberTypeService)));
|
||||
}
|
||||
|
||||
[DataEditor("Test.Test", "Test", "~/Test.html")]
|
||||
@@ -53,6 +83,8 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
public void To_Media_Item_Simple()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateImageMediaType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedMedia.CreateMediaImage(contentType, -1);
|
||||
FixUsers(content);
|
||||
|
||||
@@ -70,6 +102,8 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
public void To_Content_Item_Simple()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
FixUsers(content);
|
||||
|
||||
@@ -87,6 +121,8 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
public void To_Content_Item_Dto()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
FixUsers(content);
|
||||
|
||||
@@ -117,8 +153,8 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
public void To_Display_Model()
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
var contentTypeServiceMock = Mock.Get(Current.Services.ContentTypeService);
|
||||
contentTypeServiceMock.Setup(x => x.Get(contentType.Id)).Returns(() => contentType);
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
Mock.Get(_contentTypeService).Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
|
||||
@@ -127,7 +163,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
|
||||
// need ids for tabs
|
||||
var id = 1;
|
||||
foreach (var g in content.PropertyGroups)
|
||||
foreach (var g in contentType.CompositionPropertyGroups)
|
||||
g.Id = id++;
|
||||
|
||||
var result = Mapper.Map<IContent, ContentItemDisplay>(content);
|
||||
@@ -141,7 +177,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
AssertDisplayProperty(invariantContent, p);
|
||||
}
|
||||
|
||||
Assert.AreEqual(content.PropertyGroups.Count(), invariantContent.Tabs.Count());
|
||||
Assert.AreEqual(contentType.CompositionPropertyGroups.Count(), invariantContent.Tabs.Count());
|
||||
Assert.IsTrue(invariantContent.Tabs.First().IsActive);
|
||||
Assert.IsTrue(invariantContent.Tabs.Except(new[] { invariantContent.Tabs.First() }).All(x => x.IsActive == false));
|
||||
}
|
||||
@@ -151,9 +187,8 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
{
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
contentType.PropertyGroups.Clear();
|
||||
var contentTypeServiceMock = Mock.Get(Current.Services.ContentTypeService);
|
||||
contentTypeServiceMock.Setup(x => x.Get(contentType.Id)).Returns(() => contentType);
|
||||
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
Mock.Get(_contentTypeService).Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
var content = new Content("Home", -1, contentType) { Level = 1, SortOrder = 1, CreatorId = 0, WriterId = 0 };
|
||||
|
||||
@@ -168,7 +203,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
AssertDisplayProperty(invariantContent, p);
|
||||
}
|
||||
|
||||
Assert.AreEqual(content.PropertyGroups.Count(), invariantContent.Tabs.Count());
|
||||
Assert.AreEqual(contentType.CompositionPropertyGroups.Count(), invariantContent.Tabs.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -186,8 +221,8 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
p.Id = idSeed;
|
||||
idSeed++;
|
||||
}
|
||||
var contentTypeServiceMock = Mock.Get(Current.Services.ContentTypeService);
|
||||
contentTypeServiceMock.Setup(x => x.Get(contentType.Id)).Returns(() => contentType);
|
||||
Mock.Get(_contentTypeService).As<IContentTypeBaseService>().Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
Mock.Get(_contentTypeService).Setup(x => x.Get(It.IsAny<int>())).Returns(contentType);
|
||||
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(contentType);
|
||||
@@ -200,7 +235,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
}
|
||||
//need ids for tabs
|
||||
var id = 1;
|
||||
foreach (var g in content.PropertyGroups)
|
||||
foreach (var g in contentType.CompositionPropertyGroups)
|
||||
{
|
||||
g.Id = id;
|
||||
id++;
|
||||
@@ -221,7 +256,7 @@ namespace Umbraco.Tests.Models.Mapping
|
||||
AssertDisplayProperty(invariantContent, p);
|
||||
}
|
||||
|
||||
Assert.AreEqual(content.PropertyGroups.Count(), invariantContent.Tabs.Count() - 1);
|
||||
Assert.AreEqual(contentType.CompositionPropertyGroups.Count(), invariantContent.Tabs.Count() - 1);
|
||||
Assert.IsTrue(invariantContent.Tabs.Any(x => x.Label == Current.Services.TextService.Localize("general/properties")));
|
||||
Assert.AreEqual(2, invariantContent.Tabs.Where(x => x.Label == Current.Services.TextService.Localize("general/properties")).SelectMany(x => x.Properties.Where(p => p.Alias.StartsWith("_umb_") == false)).Count());
|
||||
}
|
||||
|
||||
@@ -67,20 +67,7 @@ namespace Umbraco.Tests.Models
|
||||
Assert.AreEqual(clone.Id, member.Id);
|
||||
Assert.AreEqual(clone.VersionId, member.VersionId);
|
||||
Assert.AreEqual(clone.AdditionalData, member.AdditionalData);
|
||||
Assert.AreNotSame(clone.ContentType, member.ContentType);
|
||||
Assert.AreEqual(clone.ContentType, member.ContentType);
|
||||
Assert.AreEqual(clone.ContentType.PropertyGroups.Count, member.ContentType.PropertyGroups.Count);
|
||||
for (var index = 0; index < member.ContentType.PropertyGroups.Count; index++)
|
||||
{
|
||||
Assert.AreNotSame(clone.ContentType.PropertyGroups[index], member.ContentType.PropertyGroups[index]);
|
||||
Assert.AreEqual(clone.ContentType.PropertyGroups[index], member.ContentType.PropertyGroups[index]);
|
||||
}
|
||||
Assert.AreEqual(clone.ContentType.PropertyTypes.Count(), member.ContentType.PropertyTypes.Count());
|
||||
for (var index = 0; index < member.ContentType.PropertyTypes.Count(); index++)
|
||||
{
|
||||
Assert.AreNotSame(clone.ContentType.PropertyTypes.ElementAt(index), member.ContentType.PropertyTypes.ElementAt(index));
|
||||
Assert.AreEqual(clone.ContentType.PropertyTypes.ElementAt(index), member.ContentType.PropertyTypes.ElementAt(index));
|
||||
}
|
||||
Assert.AreEqual(clone.ContentTypeId, member.ContentTypeId);
|
||||
Assert.AreEqual(clone.CreateDate, member.CreateDate);
|
||||
Assert.AreEqual(clone.CreatorId, member.CreatorId);
|
||||
@@ -112,6 +99,9 @@ namespace Umbraco.Tests.Models
|
||||
Assert.AreEqual(clone.Properties[index], member.Properties[index]);
|
||||
}
|
||||
|
||||
// this can be the same, it is immutable
|
||||
Assert.AreSame(clone.ContentType, member.ContentType);
|
||||
|
||||
//This double verifies by reflection
|
||||
var allProps = clone.GetType().GetProperties();
|
||||
foreach (var propertyInfo in allProps)
|
||||
|
||||
@@ -227,6 +227,9 @@ namespace Umbraco.Tests.Models
|
||||
// now it will work
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
|
||||
// recreate content to re-capture content type variations
|
||||
content = new Content("content", -1, contentType) { Id = 1, VersionId = 1 };
|
||||
|
||||
// invariant name works
|
||||
content.Name = "name";
|
||||
Assert.AreEqual("name", content.GetCultureName(null));
|
||||
|
||||
@@ -130,10 +130,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var hasPropertiesContentType = MockedContentTypes.CreateSimpleContentType("umbTextpage1", "Textpage");
|
||||
ServiceContext.FileService.SaveTemplate(hasPropertiesContentType.DefaultTemplate); // else, FK violation on contentType!
|
||||
|
||||
contentTypeRepository.Save(hasPropertiesContentType);
|
||||
|
||||
IContent content1 = MockedContent.CreateSimpleContent(hasPropertiesContentType);
|
||||
|
||||
// save = create the initial version
|
||||
contentTypeRepository.Save(hasPropertiesContentType);
|
||||
repository.Save(content1);
|
||||
|
||||
versions.Add(content1.VersionId); // the first version
|
||||
@@ -399,9 +400,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository((IScopeAccessor)provider, out var contentTypeRepository);
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage2", "Textpage");
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); // else, FK violation on contentType!
|
||||
contentTypeRepository.Save(contentType);
|
||||
|
||||
IContent textpage = MockedContent.CreateSimpleContent(contentType);
|
||||
|
||||
contentTypeRepository.Save(contentType);
|
||||
repository.Save(textpage);
|
||||
scope.Complete();
|
||||
|
||||
@@ -487,9 +489,10 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var repository = CreateRepository((IScopeAccessor)provider, out var contentTypeRepository);
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("umbTextpage1", "Textpage");
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); // else, FK violation on contentType!
|
||||
contentTypeRepository.Save(contentType);
|
||||
|
||||
var textpage = MockedContent.CreateSimpleContent(contentType);
|
||||
|
||||
contentTypeRepository.Save(contentType);
|
||||
repository.Save(textpage);
|
||||
|
||||
|
||||
|
||||
@@ -61,8 +61,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
udb.EnableSqlCount = false;
|
||||
|
||||
var mediaType = MockedContentTypes.CreateSimpleMediaType("umbTextpage1", "Textpage");
|
||||
var media = MockedMedia.CreateSimpleMedia(mediaType, "hello", -1);
|
||||
mediaTypeRepository.Save(mediaType);
|
||||
|
||||
var media = MockedMedia.CreateSimpleMedia(mediaType, "hello", -1);
|
||||
repository.Save(media);
|
||||
|
||||
udb.EnableSqlCount = true;
|
||||
@@ -271,7 +272,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
|
||||
repository.Save(folder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var types = new[] { 1031 };
|
||||
var query = scope.SqlContext.Query<IMedia>().Where(x => types.Contains(x.ContentTypeId));
|
||||
@@ -302,7 +303,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var folder = MockedMedia.CreateMediaFolder(folderMediaType, -1);
|
||||
repository.Save(folder);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var types = new[] { "Folder" };
|
||||
var query = scope.SqlContext.Query<IMedia>().Where(x => types.Contains(x.ContentType.Alias));
|
||||
|
||||
@@ -164,21 +164,19 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var memberType = MockedContentTypes.CreateSimpleMemberType();
|
||||
memberTypeRepository.Save(memberType);
|
||||
|
||||
|
||||
var member = MockedMember.CreateSimpleMember(memberType, "Johnny Hefty", "johnny@example.com", "123", "hefty");
|
||||
repository.Save(member);
|
||||
|
||||
|
||||
var sut = repository.Get(member.Id);
|
||||
|
||||
Assert.That(sut.ContentType.PropertyGroups.Count(), Is.EqualTo(2));
|
||||
Assert.That(sut.ContentType.PropertyTypes.Count(), Is.EqualTo(3 + Constants.Conventions.Member.GetStandardPropertyTypeStubs().Count));
|
||||
Assert.That(memberType.CompositionPropertyGroups.Count(), Is.EqualTo(2));
|
||||
Assert.That(memberType.CompositionPropertyTypes.Count(), Is.EqualTo(3 + Constants.Conventions.Member.GetStandardPropertyTypeStubs().Count));
|
||||
Assert.That(sut.Properties.Count(), Is.EqualTo(3 + Constants.Conventions.Member.GetStandardPropertyTypeStubs().Count));
|
||||
var grp = sut.PropertyGroups.FirstOrDefault(x => x.Name == Constants.Conventions.Member.StandardPropertiesGroupName);
|
||||
var grp = memberType.CompositionPropertyGroups.FirstOrDefault(x => x.Name == Constants.Conventions.Member.StandardPropertiesGroupName);
|
||||
Assert.IsNotNull(grp);
|
||||
var aliases = Constants.Conventions.Member.GetStandardPropertyTypeStubs().Select(x => x.Key).ToArray();
|
||||
foreach (var p in sut.PropertyTypes.Where(x => aliases.Contains(x.Alias)))
|
||||
foreach (var p in memberType.CompositionPropertyTypes.Where(x => aliases.Contains(x.Alias)))
|
||||
{
|
||||
Assert.AreEqual(grp.Id, p.PropertyGroupId.Value);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.Save(user);
|
||||
|
||||
|
||||
|
||||
// Assert
|
||||
Assert.That(user.HasIdentity, Is.True);
|
||||
@@ -96,9 +96,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.Save(user1);
|
||||
|
||||
|
||||
repository.Save(use2);
|
||||
|
||||
|
||||
|
||||
// Assert
|
||||
Assert.That(user1.HasIdentity, Is.True);
|
||||
@@ -117,7 +117,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
var user = MockedUser.CreateUser();
|
||||
repository.Save(user);
|
||||
|
||||
|
||||
|
||||
// Act
|
||||
var resolved = repository.Get((int)user.Id);
|
||||
@@ -132,9 +132,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_Update_On_UserRepository()
|
||||
{
|
||||
var ct = MockedContentTypes.CreateBasicContentType("test");
|
||||
var content = MockedContent.CreateBasicContent(ct);
|
||||
var mt = MockedContentTypes.CreateSimpleMediaType("testmedia", "TestMedia");
|
||||
var media = MockedMedia.CreateSimpleMedia(mt, "asdf", -1);
|
||||
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
@@ -147,11 +145,12 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
contentTypeRepo.Save(ct);
|
||||
mediaTypeRepo.Save(mt);
|
||||
|
||||
|
||||
var content = MockedContent.CreateBasicContent(ct);
|
||||
var media = MockedMedia.CreateSimpleMedia(mt, "asdf", -1);
|
||||
|
||||
contentRepository.Save(content);
|
||||
mediaRepository.Save(media);
|
||||
|
||||
|
||||
var user = CreateAndCommitUserWithGroup(userRepository, userGroupRepository);
|
||||
|
||||
@@ -171,7 +170,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
resolved.Username = "newName";
|
||||
|
||||
userRepository.Save(resolved);
|
||||
|
||||
|
||||
var updatedItem = (User) userRepository.Get(user.Id);
|
||||
|
||||
// Assert
|
||||
@@ -204,13 +203,13 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
// Act
|
||||
repository.Save(user);
|
||||
|
||||
|
||||
var id = user.Id;
|
||||
|
||||
var repository2 = new UserRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, Mock.Of<IMapperCollection>(),TestObjects.GetGlobalSettings());
|
||||
|
||||
repository2.Delete(user);
|
||||
|
||||
|
||||
|
||||
var resolved = repository2.Get((int) id);
|
||||
|
||||
@@ -373,7 +372,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
scope.Database.AsUmbracoDatabase().EnableSqlCount = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -429,7 +428,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var user = MockedUser.CreateUser();
|
||||
repository.Save(user);
|
||||
|
||||
|
||||
|
||||
var group = MockedUserGroup.CreateUserGroup();
|
||||
userGroupRepository.AddOrUpdateGroupWithUsers(@group, new[] { user.Id });
|
||||
|
||||
@@ -195,7 +195,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
[Test]
|
||||
public void PublishedContentQueryTypedContentList()
|
||||
{
|
||||
var query = new PublishedContentQuery(UmbracoContext.Current.ContentCache, UmbracoContext.Current.MediaCache, UmbracoContext.Current.VariationContextAccessor);
|
||||
var query = new PublishedContentQuery(UmbracoContext.Current.PublishedSnapshot, UmbracoContext.Current.VariationContextAccessor);
|
||||
var result = query.Content(new[] { 1, 2, 4 }).ToArray();
|
||||
Assert.AreEqual(2, result.Length);
|
||||
Assert.AreEqual(1, result[0].Id);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.Services
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate);
|
||||
contentTypeService.Save(contentType);
|
||||
|
||||
var blueprint = MockedContent.CreateTextpageContent(contentType, "hello", -1);
|
||||
var blueprint = MockedContent.CreateTextpageContent(contentType, "hello", Constants.System.Root);
|
||||
blueprint.SetValue("title", "blueprint 1");
|
||||
blueprint.SetValue("bodyText", "blueprint 2");
|
||||
blueprint.SetValue("keywords", "blueprint 3");
|
||||
@@ -92,7 +92,7 @@ namespace Umbraco.Tests.Services
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate);
|
||||
contentTypeService.Save(contentType);
|
||||
|
||||
var blueprint = MockedContent.CreateTextpageContent(contentType, "hello", -1);
|
||||
var blueprint = MockedContent.CreateTextpageContent(contentType, "hello", Constants.System.Root);
|
||||
blueprint.SetValue("title", "blueprint 1");
|
||||
blueprint.SetValue("bodyText", "blueprint 2");
|
||||
blueprint.SetValue("keywords", "blueprint 3");
|
||||
@@ -118,7 +118,7 @@ namespace Umbraco.Tests.Services
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate);
|
||||
contentTypeService.Save(contentType);
|
||||
|
||||
var blueprint = MockedContent.CreateTextpageContent(contentType, "hello", -1);
|
||||
var blueprint = MockedContent.CreateTextpageContent(contentType, "hello", Constants.System.Root);
|
||||
blueprint.SetValue("title", "blueprint 1");
|
||||
blueprint.SetValue("bodyText", "blueprint 2");
|
||||
blueprint.SetValue("keywords", "blueprint 3");
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var blueprint = MockedContent.CreateTextpageContent(i % 2 == 0 ? ct1 : ct2, "hello" + i, -1);
|
||||
var blueprint = MockedContent.CreateTextpageContent(i % 2 == 0 ? ct1 : ct2, "hello" + i, Constants.System.Root);
|
||||
contentService.SaveBlueprint(blueprint);
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
// Act
|
||||
var content = contentService.CreateAndSave("Test", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.CreateAndSave("Test", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
|
||||
content.ContentSchedule.Add(null, DateTime.Now.AddHours(2));
|
||||
contentService.Save(content, Constants.Security.SuperUserId);
|
||||
@@ -292,7 +292,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
// Act
|
||||
var content = contentService.CreateAndSave("Test", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.CreateAndSave("Test", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
content.SetValue("bodyText", "hello world " + Guid.NewGuid());
|
||||
@@ -317,7 +317,7 @@ namespace Umbraco.Tests.Services
|
||||
var results = new List<IContent>();
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
results.Add(contentService.CreateAndSave("Test", -1, "umbTextpage", 0));
|
||||
results.Add(contentService.CreateAndSave("Test", Constants.System.Root, "umbTextpage", 0));
|
||||
}
|
||||
|
||||
var sortedGet = contentService.GetByIds(new[] {results[10].Id, results[5].Id, results[12].Id}).ToArray();
|
||||
@@ -337,7 +337,7 @@ namespace Umbraco.Tests.Services
|
||||
// Act
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
contentService.CreateAndSave("Test", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
contentService.CreateAndSave("Test", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
}
|
||||
|
||||
// Assert
|
||||
@@ -356,7 +356,7 @@ namespace Umbraco.Tests.Services
|
||||
// Act
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
contentService.CreateAndSave("Test", -1, "umbBlah", Constants.Security.SuperUserId);
|
||||
contentService.CreateAndSave("Test", Constants.System.Root, "umbBlah", Constants.Security.SuperUserId);
|
||||
}
|
||||
|
||||
// Assert
|
||||
@@ -371,7 +371,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentTypeService = ServiceContext.ContentTypeService;
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("umbBlah", "test Doc Type");
|
||||
contentTypeService.Save(contentType);
|
||||
var parent = contentService.CreateAndSave("Test", -1, "umbBlah", Constants.Security.SuperUserId);
|
||||
var parent = contentService.CreateAndSave("Test", Constants.System.Root, "umbBlah", Constants.Security.SuperUserId);
|
||||
|
||||
// Act
|
||||
for (int i = 0; i < 20; i++)
|
||||
@@ -391,7 +391,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentTypeService = ServiceContext.ContentTypeService;
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType("umbBlah", "test Doc Type");
|
||||
contentTypeService.Save(contentType);
|
||||
var parent = contentService.CreateAndSave("Test", -1, "umbBlah", Constants.Security.SuperUserId);
|
||||
var parent = contentService.CreateAndSave("Test", Constants.System.Root, "umbBlah", Constants.Security.SuperUserId);
|
||||
|
||||
// Act
|
||||
IContent current = parent;
|
||||
@@ -425,7 +425,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
// Act
|
||||
var content = contentService.Create("Test", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.Create("Test", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
|
||||
// Assert
|
||||
Assert.That(content, Is.Not.Null);
|
||||
@@ -439,7 +439,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
// Act
|
||||
var content = contentService.Create("Test", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.Create("Test", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
|
||||
// Assert
|
||||
Assert.That(content, Is.Not.Null);
|
||||
@@ -453,12 +453,12 @@ namespace Umbraco.Tests.Services
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
// Act
|
||||
var content = contentService.Create("Test", -1, "umbTextpage");
|
||||
var content = contentService.Create("Test", Constants.System.Root, "umbTextpage");
|
||||
|
||||
// Assert
|
||||
Assert.That(content, Is.Not.Null);
|
||||
Assert.That(content.HasIdentity, Is.False);
|
||||
Assert.That(content.CreatorId, Is.EqualTo(0)); //Default to 0 (unknown) since we didn't explicitly set this in the Create call
|
||||
Assert.That(content.CreatorId, Is.EqualTo(Constants.Security.SuperUserId)); //Default to -1 aka SuperUser (unknown) since we didn't explicitly set this in the Create call
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -472,7 +472,7 @@ namespace Umbraco.Tests.Services
|
||||
RawPasswordValue = "test"
|
||||
};
|
||||
ServiceContext.UserService.Save(user);
|
||||
var content = new Content("Test", -1, ServiceContext.ContentTypeService.Get("umbTextpage"));
|
||||
var content = new Content("Test", Constants.System.Root, ServiceContext.ContentTypeService.Get("umbTextpage"));
|
||||
|
||||
// Act
|
||||
ServiceContext.ContentService.Save(content, (int)user.Id);
|
||||
@@ -489,7 +489,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<Exception>(() => contentService.Create("Test", -1, "umbAliasDoesntExist"));
|
||||
Assert.Throws<Exception>(() => contentService.Create("Test", Constants.System.Root, "umbAliasDoesntExist"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -497,7 +497,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
// Arrange
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = new Content(string.Empty, -1, ServiceContext.ContentTypeService.Get("umbTextpage"));
|
||||
var content = new Content(string.Empty, Constants.System.Root, ServiceContext.ContentTypeService.Get("umbTextpage"));
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<InvalidOperationException>(() => contentService.Save(content));
|
||||
@@ -727,7 +727,7 @@ namespace Umbraco.Tests.Services
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
IContent content = new Content("content", -1, contentType);
|
||||
IContent content = new Content("content", Constants.System.Root, contentType);
|
||||
content.SetCultureName("content-fr", langFr.IsoCode);
|
||||
content.SetCultureName("content-en", langUk.IsoCode);
|
||||
content.PublishCulture(langFr.IsoCode);
|
||||
@@ -779,7 +779,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
IContent content = new Content("content", -1, contentType);
|
||||
IContent content = new Content("content", Constants.System.Root, contentType);
|
||||
content.SetCultureName("content-en", langGB.IsoCode);
|
||||
content.SetCultureName("content-fr", langFr.IsoCode);
|
||||
|
||||
@@ -821,7 +821,7 @@ namespace Umbraco.Tests.Services
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
IContent content = new Content("content", -1, contentType);
|
||||
IContent content = new Content("content", Constants.System.Root, contentType);
|
||||
content.SetCultureName("content-fr", langFr.IsoCode);
|
||||
var published = ServiceContext.ContentService.SaveAndPublish(content, langFr.IsoCode);
|
||||
//audit log will only show that french was published
|
||||
@@ -852,7 +852,7 @@ namespace Umbraco.Tests.Services
|
||||
contentType.Variations = ContentVariation.Culture;
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
IContent content = new Content("content", -1, contentType);
|
||||
IContent content = new Content("content", Constants.System.Root, contentType);
|
||||
content.SetCultureName("content-fr", langFr.IsoCode);
|
||||
content.SetCultureName("content-gb", langGB.IsoCode);
|
||||
var published = ServiceContext.ContentService.SaveAndPublish(content, new[] {langGB.IsoCode, langFr.IsoCode});
|
||||
@@ -910,7 +910,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
// Arrange
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var parent = contentService.Create("parent", -1, "umbTextpage");
|
||||
var parent = contentService.Create("parent", Constants.System.Root, "umbTextpage");
|
||||
|
||||
contentService.SaveAndPublish(parent);
|
||||
var content = contentService.Create("child", parent, "umbTextpage");
|
||||
@@ -1235,7 +1235,7 @@ namespace Umbraco.Tests.Services
|
||||
{
|
||||
// Arrange
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = contentService.Create("Home US", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.Create("Home US", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
content.SetValue("author", "Barack Obama");
|
||||
|
||||
// Act
|
||||
@@ -1574,7 +1574,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
var contentType = MockedContentTypes.CreateAllTypesContentType("test", "test");
|
||||
ServiceContext.ContentTypeService.Save(contentType, Constants.Security.SuperUserId);
|
||||
|
||||
|
||||
object obj =
|
||||
new
|
||||
{
|
||||
@@ -1730,7 +1730,7 @@ namespace Umbraco.Tests.Services
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); // else, FK violation on contentType!
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(contentType, "Simple Tags Page", -1);
|
||||
var content = MockedContent.CreateSimpleContent(contentType, "Simple Tags Page", Constants.System.Root);
|
||||
content.AssignTags(propAlias, new[] {"hello", "world"});
|
||||
contentService.Save(content);
|
||||
|
||||
@@ -1906,7 +1906,7 @@ namespace Umbraco.Tests.Services
|
||||
ServiceContext.FileService.SaveTemplate(contentType.DefaultTemplate); // else, FK violation on contentType!
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
var page = new Content("Page", -1, contentType)
|
||||
var page = new Content("Page", Constants.System.Root, contentType)
|
||||
{
|
||||
Level = 1,
|
||||
SortOrder = 1,
|
||||
@@ -2133,7 +2133,7 @@ namespace Umbraco.Tests.Services
|
||||
var contentType = MockedContentTypes.CreateAllTypesContentType("allDataTypes", "All DataTypes");
|
||||
contentTypeService.Save(contentType);
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = MockedContent.CreateAllTypesContent(contentType, "Random Content", -1);
|
||||
var content = MockedContent.CreateAllTypesContent(contentType, "Random Content", Constants.System.Root);
|
||||
contentService.Save(content);
|
||||
var id = content.Id;
|
||||
|
||||
@@ -2186,7 +2186,7 @@ namespace Umbraco.Tests.Services
|
||||
public void Ensure_Content_Xml_Created()
|
||||
{
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = contentService.Create("Home US", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.Create("Home US", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
content.SetValue("author", "Barack Obama");
|
||||
|
||||
contentService.Save(content);
|
||||
@@ -2208,7 +2208,7 @@ namespace Umbraco.Tests.Services
|
||||
public void Ensure_Preview_Xml_Created()
|
||||
{
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = contentService.Create("Home US", -1, "umbTextpage", Constants.Security.SuperUserId);
|
||||
var content = contentService.Create("Home US", Constants.System.Root, "umbTextpage", Constants.Security.SuperUserId);
|
||||
content.SetValue("author", "Barack Obama");
|
||||
|
||||
contentService.Save(content);
|
||||
@@ -2236,10 +2236,10 @@ namespace Umbraco.Tests.Services
|
||||
}
|
||||
|
||||
long total;
|
||||
var entities = service.GetPagedChildren(-1, 0, 6, out total).ToArray();
|
||||
var entities = service.GetPagedChildren(Constants.System.Root, 0, 6, out total).ToArray();
|
||||
Assert.That(entities.Length, Is.EqualTo(6));
|
||||
Assert.That(total, Is.EqualTo(10));
|
||||
entities = service.GetPagedChildren(-1, 1, 6, out total).ToArray();
|
||||
entities = service.GetPagedChildren(Constants.System.Root, 1, 6, out total).ToArray();
|
||||
Assert.That(entities.Length, Is.EqualTo(4));
|
||||
Assert.That(total, Is.EqualTo(10));
|
||||
}
|
||||
@@ -2271,10 +2271,10 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
long total;
|
||||
// children in root including the folder - not the descendants in the folder
|
||||
var entities = service.GetPagedChildren(-1, 0, 6, out total).ToArray();
|
||||
var entities = service.GetPagedChildren(Constants.System.Root, 0, 6, out total).ToArray();
|
||||
Assert.That(entities.Length, Is.EqualTo(6));
|
||||
Assert.That(total, Is.EqualTo(10));
|
||||
entities = service.GetPagedChildren(-1, 1, 6, out total).ToArray();
|
||||
entities = service.GetPagedChildren(Constants.System.Root, 1, 6, out total).ToArray();
|
||||
Assert.That(entities.Length, Is.EqualTo(4));
|
||||
Assert.That(total, Is.EqualTo(10));
|
||||
|
||||
@@ -2290,7 +2290,7 @@ namespace Umbraco.Tests.Services
|
||||
[Test]
|
||||
public void PublishingTest()
|
||||
{
|
||||
var contentType = new ContentType(-1)
|
||||
var contentType = new ContentType(Constants.System.Root)
|
||||
{
|
||||
Alias = "foo",
|
||||
Name = "Foo"
|
||||
@@ -2308,7 +2308,7 @@ namespace Umbraco.Tests.Services
|
||||
ServiceContext.ContentTypeService.Save(contentType);
|
||||
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = contentService.Create("foo", -1, "foo");
|
||||
var content = contentService.Create("foo", Constants.System.Root, "foo");
|
||||
contentService.Save(content);
|
||||
|
||||
Assert.IsFalse(content.Published);
|
||||
@@ -2436,7 +2436,7 @@ namespace Umbraco.Tests.Services
|
||||
contentTypeService.Save(contentType);
|
||||
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = new Content(null, -1, contentType);
|
||||
var content = new Content(null, Constants.System.Root, contentType);
|
||||
|
||||
content.SetCultureName("name-us", langUk.IsoCode);
|
||||
content.SetCultureName("name-fr", langFr.IsoCode);
|
||||
@@ -2471,7 +2471,7 @@ namespace Umbraco.Tests.Services
|
||||
|
||||
var contentService = ServiceContext.ContentService;
|
||||
|
||||
var content = new Content(null, -1, contentType);
|
||||
var content = new Content(null, Constants.System.Root, contentType);
|
||||
content.SetCultureName("root", langUk.IsoCode);
|
||||
contentService.Save(content);
|
||||
|
||||
@@ -2513,13 +2513,13 @@ namespace Umbraco.Tests.Services
|
||||
var o = new[] { 2, 1, 3, 0, 4 }; // randomly different
|
||||
for (var i = 0; i < 5; i++)
|
||||
{
|
||||
var contentA = new Content(null, -1, contentType);
|
||||
var contentA = new Content(null, Constants.System.Root, contentType);
|
||||
contentA.SetCultureName("contentA" + i + "uk", langUk.IsoCode);
|
||||
contentA.SetCultureName("contentA" + o[i] + "fr", langFr.IsoCode);
|
||||
contentA.SetCultureName("contentX" + i + "da", langDa.IsoCode);
|
||||
contentService.Save(contentA);
|
||||
|
||||
var contentB = new Content(null, -1, contentType);
|
||||
var contentB = new Content(null, Constants.System.Root, contentType);
|
||||
contentB.SetCultureName("contentB" + i + "uk", langUk.IsoCode);
|
||||
contentB.SetCultureName("contentB" + o[i] + "fr", langFr.IsoCode);
|
||||
contentB.SetCultureName("contentX" + i + "da", langDa.IsoCode);
|
||||
@@ -2527,7 +2527,7 @@ namespace Umbraco.Tests.Services
|
||||
}
|
||||
|
||||
// get all
|
||||
var list = contentService.GetPagedChildren(-1, 0, 100, out var total).ToList();
|
||||
var list = contentService.GetPagedChildren(Constants.System.Root, 0, 100, out var total).ToList();
|
||||
|
||||
Console.WriteLine("ALL");
|
||||
WriteList(list);
|
||||
@@ -2537,7 +2537,7 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreEqual(11, list.Count);
|
||||
|
||||
// filter
|
||||
list = contentService.GetPagedChildren(-1, 0, 100, out total,
|
||||
list = contentService.GetPagedChildren(Constants.System.Root, 0, 100, out total,
|
||||
SqlContext.Query<IContent>().Where(x => x.Name.Contains("contentX")),
|
||||
Ordering.By("name", culture: langFr.IsoCode)).ToList();
|
||||
|
||||
@@ -2545,7 +2545,7 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreEqual(0, list.Count);
|
||||
|
||||
// filter
|
||||
list = contentService.GetPagedChildren(-1, 0, 100, out total,
|
||||
list = contentService.GetPagedChildren(Constants.System.Root, 0, 100, out total,
|
||||
SqlContext.Query<IContent>().Where(x => x.Name.Contains("contentX")),
|
||||
Ordering.By("name", culture: langDa.IsoCode)).ToList();
|
||||
|
||||
@@ -2556,7 +2556,7 @@ namespace Umbraco.Tests.Services
|
||||
Assert.AreEqual(10, list.Count);
|
||||
|
||||
// filter
|
||||
list = contentService.GetPagedChildren(-1, 0, 100, out total,
|
||||
list = contentService.GetPagedChildren(Constants.System.Root, 0, 100, out total,
|
||||
SqlContext.Query<IContent>().Where(x => x.Name.Contains("contentA")),
|
||||
Ordering.By("name", culture: langFr.IsoCode)).ToList();
|
||||
|
||||
@@ -2569,7 +2569,7 @@ namespace Umbraco.Tests.Services
|
||||
for (var i = 0; i < 5; i++)
|
||||
Assert.AreEqual("contentA" + i + "fr", list[i].GetCultureName(langFr.IsoCode));
|
||||
|
||||
list = contentService.GetPagedChildren(-1, 0, 100, out total,
|
||||
list = contentService.GetPagedChildren(Constants.System.Root, 0, 100, out total,
|
||||
SqlContext.Query<IContent>().Where(x => x.Name.Contains("contentA")),
|
||||
Ordering.By("name", direction: Direction.Descending, culture: langFr.IsoCode)).ToList();
|
||||
|
||||
@@ -2614,7 +2614,7 @@ namespace Umbraco.Tests.Services
|
||||
contentTypeService.Save(contentType);
|
||||
|
||||
var contentService = ServiceContext.ContentService;
|
||||
var content = contentService.Create("Home US", -1, "umbTextpage");
|
||||
var content = contentService.Create("Home US", Constants.System.Root, "umbTextpage");
|
||||
|
||||
// creating content with a name but no culture - will set the invariant name
|
||||
// but, because that content is variant, as soon as we save, we'll need to
|
||||
|
||||
@@ -554,7 +554,6 @@ namespace Umbraco.Tests.Services
|
||||
IContent contentItem = MockedContent.CreateTextpageContent(contentType1, "Testing", -1);
|
||||
ServiceContext.ContentService.SaveAndPublish(contentItem);
|
||||
var initProps = contentItem.Properties.Count;
|
||||
var initPropTypes = contentItem.PropertyTypes.Count();
|
||||
|
||||
//remove a property
|
||||
contentType1.RemovePropertyType(contentType1.PropertyTypes.First().Alias);
|
||||
@@ -563,7 +562,6 @@ namespace Umbraco.Tests.Services
|
||||
//re-load it from the db
|
||||
contentItem = ServiceContext.ContentService.GetById(contentItem.Id);
|
||||
|
||||
Assert.AreEqual(initPropTypes - 1, contentItem.PropertyTypes.Count());
|
||||
Assert.AreEqual(initProps - 1, contentItem.Properties.Count);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,6 @@ namespace Umbraco.Tests.Services
|
||||
IMember member = MockedMember.CreateSimpleMember(memberType, "test", "test@test.com", "pass", "test");
|
||||
ServiceContext.MemberService.Save(member);
|
||||
var initProps = member.Properties.Count;
|
||||
var initPropTypes = member.PropertyTypes.Count();
|
||||
|
||||
//remove a property (NOT ONE OF THE DEFAULTS)
|
||||
var standardProps = Constants.Conventions.Member.GetStandardPropertyTypeStubs();
|
||||
@@ -93,7 +92,6 @@ namespace Umbraco.Tests.Services
|
||||
//re-load it from the db
|
||||
member = ServiceContext.MemberService.GetById(member.Id);
|
||||
|
||||
Assert.AreEqual(initPropTypes - 1, member.PropertyTypes.Count());
|
||||
Assert.AreEqual(initProps - 1, member.Properties.Count);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,20 @@ namespace Umbraco.Tests.TestHelpers.Stubs
|
||||
{
|
||||
if (_enabled == false) return;
|
||||
|
||||
MiniProfiler.Settings.SqlFormatter = new SqlServerFormatter();
|
||||
MiniProfiler.Settings.StackMaxLength = 5000;
|
||||
MiniProfiler.Start();
|
||||
//see https://miniprofiler.com/dotnet/AspDotNet
|
||||
MiniProfiler.Configure(new MiniProfilerOptions
|
||||
{
|
||||
SqlFormatter = new SqlServerFormatter(),
|
||||
StackMaxLength = 5000,
|
||||
});
|
||||
|
||||
MiniProfiler.StartNew();
|
||||
}
|
||||
|
||||
public void Stop(bool discardResults = false)
|
||||
{
|
||||
if (_enabled)
|
||||
MiniProfiler.Stop(discardResults);
|
||||
MiniProfiler.Current.Stop(discardResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Tests.Testing
|
||||
{
|
||||
public static class ContentBaseExtensions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Set property values by alias with an annonymous object.
|
||||
/// Set property values by alias with an anonymous object.
|
||||
/// </summary>
|
||||
/// <remarks>Does not support variants.</remarks>
|
||||
public static void PropertyValues(this IContentBase content, object value, string culture = null, string segment = null)
|
||||
@@ -18,26 +22,12 @@ namespace Umbraco.Tests.Testing
|
||||
var propertyInfos = value.GetType().GetProperties();
|
||||
foreach (var propertyInfo in propertyInfos)
|
||||
{
|
||||
//Check if a PropertyType with alias exists thus being a valid property
|
||||
var propertyType = content.PropertyTypes.FirstOrDefault(x => x.Alias == propertyInfo.Name);
|
||||
if (propertyType == null)
|
||||
if (!content.Properties.TryGetValue(propertyInfo.Name, out var property))
|
||||
throw new Exception($"The property alias {propertyInfo.Name} is not valid, because no PropertyType with this alias exists");
|
||||
|
||||
//Check if a Property with the alias already exists in the collection thus being updated or inserted
|
||||
var item = content.Properties.FirstOrDefault(x => x.Alias == propertyInfo.Name);
|
||||
if (item != null)
|
||||
{
|
||||
item.SetValue(propertyInfo.GetValue(value, null), culture, segment);
|
||||
//Update item with newly added value
|
||||
content.Properties.Add(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Create new Property to add to collection
|
||||
var property = propertyType.CreateProperty();
|
||||
property.SetValue(propertyInfo.GetValue(value, null), culture, segment);
|
||||
content.Properties.Add(property);
|
||||
}
|
||||
property.SetValue(propertyInfo.GetValue(value, null), culture, segment);
|
||||
//Update item with newly added value
|
||||
content.Properties.Add(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,40 +78,39 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="7.0.1" />
|
||||
<PackageReference Include="Castle.Core" Version="4.2.1" />
|
||||
<PackageReference Include="AutoMapper" Version="8.0.0" />
|
||||
<PackageReference Include="Castle.Core" Version="4.3.1" />
|
||||
<PackageReference Include="Examine" Version="1.0.0-beta078" />
|
||||
<PackageReference Include="HtmlAgilityPack">
|
||||
<Version>1.8.9</Version>
|
||||
<Version>1.8.14</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="LightInject" Version="5.1.2" />
|
||||
<PackageReference Include="LightInject" Version="5.4.0" />
|
||||
<PackageReference Include="LightInject.Annotation" Version="1.1.0" />
|
||||
<PackageReference Include="Lucene.Net" Version="3.0.3" />
|
||||
<PackageReference Include="Lucene.Net.Contrib" Version="3.0.3" />
|
||||
<PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.2" />
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Owin" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.SelfHost" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.WebHost" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.Owin" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Owin.Hosting" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Owin.Security" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Owin.Testing" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Owin" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.SelfHost" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.WebHost" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.Owin" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.Owin.Hosting" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.Owin.Security" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.Owin.Testing" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
|
||||
<PackageReference Include="MiniProfiler" Version="3.2.0.157" />
|
||||
<PackageReference Include="Moq" Version="4.8.2" />
|
||||
<PackageReference Include="MiniProfiler" Version="4.0.138" />
|
||||
<PackageReference Include="Moq" Version="4.10.1" />
|
||||
<PackageReference Include="NPoco" Version="3.9.4" />
|
||||
<PackageReference Include="NUnit" Version="3.10.1" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="NUnit" Version="3.11.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.12.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="Owin" Version="1.0" />
|
||||
<PackageReference Include="Selenium.WebDriver" Version="3.11.0" />
|
||||
<PackageReference Include="Selenium.WebDriver" Version="3.141.0" />
|
||||
<PackageReference Include="Semver" Version="2.0.4" />
|
||||
<PackageReference Include="SharpZipLib" Version="0.86.0" />
|
||||
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" />
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.4.0" />
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.2" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Cache\DistributedCacheBinderTests.cs" />
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
m.GetCultureName(It.IsAny<string>()) == (string)x.Attribute("nodeName") &&
|
||||
m.Path == (string)x.Attribute("path") &&
|
||||
m.Properties == new PropertyCollection() &&
|
||||
m.ContentType == Mock.Of<IMediaType>(mt =>
|
||||
m.ContentType == Mock.Of<ISimpleContentType>(mt =>
|
||||
mt.Alias == (string)x.Attribute("nodeTypeAlias") &&
|
||||
mt.Id == (int)x.Attribute("nodeType"))))
|
||||
.ToArray();
|
||||
|
||||
@@ -43,6 +43,14 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.None)]
|
||||
public class ContentControllerTests : TestWithDatabaseBase
|
||||
{
|
||||
private IContentType _contentTypeForMockedContent;
|
||||
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
_contentTypeForMockedContent = null;
|
||||
}
|
||||
|
||||
protected override void ComposeApplication(bool withApplication)
|
||||
{
|
||||
base.ComposeApplication(withApplication);
|
||||
@@ -115,23 +123,42 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
};
|
||||
}
|
||||
|
||||
private IContent GetMockedContent()
|
||||
private IContentType GetMockedContentType()
|
||||
{
|
||||
var content = MockedContent.CreateSimpleContent(MockedContentTypes.CreateSimpleContentType());
|
||||
content.Id = 123;
|
||||
content.Path = "-1,123";
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
//ensure things have ids
|
||||
var ids = 888;
|
||||
foreach (var g in content.PropertyGroups)
|
||||
foreach (var g in contentType.CompositionPropertyGroups)
|
||||
{
|
||||
g.Id = ids;
|
||||
ids++;
|
||||
}
|
||||
foreach (var p in content.PropertyTypes)
|
||||
foreach (var p in contentType.CompositionPropertyGroups)
|
||||
{
|
||||
p.Id = ids;
|
||||
ids++;
|
||||
}
|
||||
|
||||
return contentType;
|
||||
}
|
||||
|
||||
private IContent GetMockedContent()
|
||||
{
|
||||
if (_contentTypeForMockedContent == null)
|
||||
{
|
||||
_contentTypeForMockedContent = GetMockedContentType();
|
||||
Mock.Get(Current.Services.ContentTypeService)
|
||||
.Setup(x => x.Get(_contentTypeForMockedContent.Id))
|
||||
.Returns(_contentTypeForMockedContent);
|
||||
Mock.Get(Current.Services.ContentTypeService)
|
||||
.As<IContentTypeBaseService>()
|
||||
.Setup(x => x.Get(_contentTypeForMockedContent.Id))
|
||||
.Returns(_contentTypeForMockedContent);
|
||||
}
|
||||
|
||||
var content = MockedContent.CreateSimpleContent(_contentTypeForMockedContent);
|
||||
content.Id = 123;
|
||||
content.Path = "-1,123";
|
||||
return content;
|
||||
}
|
||||
|
||||
@@ -229,7 +256,7 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Factory.GetInstance<IProfilingLogger>(),
|
||||
Factory.GetInstance<IRuntimeState>(),
|
||||
helper);
|
||||
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
@@ -251,9 +278,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
{
|
||||
ApiController CtrlFactory(HttpRequestMessage message, UmbracoContext umbracoContext, UmbracoHelper helper)
|
||||
{
|
||||
var contentServiceMock = Mock.Get(Current.Services.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => GetMockedContent());
|
||||
|
||||
var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
var controller = new ContentController(
|
||||
propertyEditorCollection,
|
||||
@@ -336,15 +360,11 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
|
||||
ApiController CtrlFactory(HttpRequestMessage message, UmbracoContext umbracoContext, UmbracoHelper helper)
|
||||
{
|
||||
|
||||
var contentServiceMock = Mock.Get(Current.Services.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => content);
|
||||
contentServiceMock.Setup(x => x.Save(It.IsAny<IContent>(), It.IsAny<int>(), It.IsAny<bool>()))
|
||||
.Returns(new OperationResult(OperationResultType.Success, new Core.Events.EventMessages())); //success
|
||||
|
||||
var contentTypeServiceMock = Mock.Get(Current.Services.ContentTypeService);
|
||||
contentTypeServiceMock.Setup(x => x.Get(content.ContentTypeId)).Returns(() => MockedContentTypes.CreateSimpleContentType());
|
||||
|
||||
var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
var controller = new ContentController(
|
||||
propertyEditorCollection,
|
||||
@@ -369,8 +389,6 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.Item1.StatusCode);
|
||||
var display = JsonConvert.DeserializeObject<ContentItemDisplay>(response.Item2);
|
||||
Assert.AreEqual(1, display.Variants.Count());
|
||||
Assert.AreEqual(content.PropertyGroups.Count(), display.Variants.ElementAt(0).Tabs.Count());
|
||||
Assert.AreEqual(content.PropertyTypes.Count(), display.Variants.ElementAt(0).Tabs.ElementAt(0).Properties.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -380,15 +398,11 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
|
||||
ApiController CtrlFactory(HttpRequestMessage message, UmbracoContext umbracoContext, UmbracoHelper helper)
|
||||
{
|
||||
|
||||
var contentServiceMock = Mock.Get(Current.Services.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => content);
|
||||
contentServiceMock.Setup(x => x.Save(It.IsAny<IContent>(), It.IsAny<int>(), It.IsAny<bool>()))
|
||||
.Returns(new OperationResult(OperationResultType.Success, new Core.Events.EventMessages())); //success
|
||||
|
||||
var contentTypeServiceMock = Mock.Get(Current.Services.ContentTypeService);
|
||||
contentTypeServiceMock.Setup(x => x.Get(content.ContentTypeId)).Returns(() => MockedContentTypes.CreateSimpleContentType());
|
||||
|
||||
var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
var controller = new ContentController(
|
||||
propertyEditorCollection,
|
||||
@@ -428,15 +442,11 @@ namespace Umbraco.Tests.Web.Controllers
|
||||
|
||||
ApiController CtrlFactory(HttpRequestMessage message, UmbracoContext umbracoContext, UmbracoHelper helper)
|
||||
{
|
||||
|
||||
var contentServiceMock = Mock.Get(Current.Services.ContentService);
|
||||
contentServiceMock.Setup(x => x.GetById(123)).Returns(() => content);
|
||||
contentServiceMock.Setup(x => x.Save(It.IsAny<IContent>(), It.IsAny<int>(), It.IsAny<bool>()))
|
||||
.Returns(new OperationResult(OperationResultType.Success, new Core.Events.EventMessages())); //success
|
||||
|
||||
var contentTypeServiceMock = Mock.Get(Current.Services.ContentTypeService);
|
||||
contentTypeServiceMock.Setup(x => x.Get(content.ContentTypeId)).Returns(() => MockedContentTypes.CreateSimpleContentType());
|
||||
|
||||
var propertyEditorCollection = new PropertyEditorCollection(new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
var controller = new ContentController(
|
||||
propertyEditorCollection,
|
||||
|
||||
-5
@@ -105,11 +105,6 @@ function sectionsDirective($timeout, $window, navigationService, treeService, se
|
||||
return;
|
||||
}
|
||||
|
||||
if (scope.userDialog) {
|
||||
closeUserDialog();
|
||||
}
|
||||
|
||||
|
||||
navigationService.hideSearch();
|
||||
navigationService.showTree(section.alias);
|
||||
|
||||
|
||||
+11
-15
@@ -3,7 +3,7 @@
|
||||
|
||||
function ContentNodeInfoDirective($timeout, logResource, eventsService, userService, localizationService, dateHelper, editorService, redirectUrlsResource, overlayService) {
|
||||
|
||||
function link(scope, umbVariantContentCtrl) {
|
||||
function link(scope) {
|
||||
|
||||
var evts = [];
|
||||
var isInfoTab = false;
|
||||
@@ -96,22 +96,17 @@
|
||||
scope.previewOpenUrl = '#/settings/documenttypes/edit/' + scope.documentType.id;
|
||||
}
|
||||
|
||||
//load in the audit trail if we are currently looking at the INFO tab
|
||||
if (umbVariantContentCtrl && umbVariantContentCtrl.editor) {
|
||||
var activeApp = _.find(umbVariantContentCtrl.editor.content.apps, a => a.active);
|
||||
if (activeApp && activeApp.alias === "umbInfo") {
|
||||
isInfoTab = true;
|
||||
loadAuditTrail();
|
||||
loadRedirectUrls();
|
||||
}
|
||||
var activeApp = _.find(scope.node.apps, (a) => a.active);
|
||||
if (activeApp.alias === "umbInfo") {
|
||||
loadRedirectUrls();
|
||||
loadAuditTrail();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
scope.auditTrailPageChange = function (pageNumber) {
|
||||
scope.auditTrailOptions.pageNumber = pageNumber;
|
||||
auditTrailLoaded = false;
|
||||
loadAuditTrail();
|
||||
loadAuditTrail(true);
|
||||
};
|
||||
|
||||
scope.openDocumentType = function (documentType) {
|
||||
@@ -192,10 +187,12 @@
|
||||
editorService.rollback(rollback);
|
||||
};
|
||||
|
||||
function loadAuditTrail() {
|
||||
function loadAuditTrail(forceReload) {
|
||||
|
||||
//don't load this if it's already done
|
||||
if (auditTrailLoaded) { return; };
|
||||
if (auditTrailLoaded && !forceReload) {
|
||||
return;
|
||||
}
|
||||
|
||||
scope.loadingAuditTrail = true;
|
||||
|
||||
@@ -334,8 +331,7 @@
|
||||
if (newValue === oldValue) { return; }
|
||||
|
||||
if (isInfoTab) {
|
||||
auditTrailLoaded = false;
|
||||
loadAuditTrail();
|
||||
loadAuditTrail(true);
|
||||
loadRedirectUrls();
|
||||
setNodePublishStatus();
|
||||
updateCurrentUrls();
|
||||
|
||||
+2
-2
@@ -5,11 +5,11 @@
|
||||
for (var property in obj) {
|
||||
if (obj.hasOwnProperty(property)) {
|
||||
|
||||
if (property.startsWith(propertyPrefix) && obj[property]) {
|
||||
if (property.startsWith(propertyPrefix) && obj[property] !== undefined) {
|
||||
obj[property] = undefined;
|
||||
}
|
||||
|
||||
if (typeof obj[property] == "object") {
|
||||
if (typeof obj[property] === "object") {
|
||||
removeProperty(obj[property], propertyPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
+16
-3
@@ -10,7 +10,7 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function DataTypeSettingsController($scope, dataTypeResource, dataTypeHelper, localizationService) {
|
||||
function DataTypeSettingsController($scope, dataTypeResource, dataTypeHelper, localizationService, notificationsService, overlayService, formHelper) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
vm.saveButtonState = "busy";
|
||||
|
||||
var preValues = dataTypeHelper.createPreValueProps(vm.dataType.preValues);
|
||||
|
||||
|
||||
dataTypeResource.save(vm.dataType, preValues, $scope.model.create).then(function(newDataType) {
|
||||
$scope.model.dataType = newDataType;
|
||||
vm.saveButtonState = "success";
|
||||
@@ -110,6 +110,19 @@
|
||||
if ($scope.model && $scope.model.submit) {
|
||||
$scope.model.submit($scope.model);
|
||||
}
|
||||
}, function(err) {
|
||||
vm.saveButtonState = "error";
|
||||
|
||||
if(err.status === 400) {
|
||||
if (err.data && (err.data.ModelState)) {
|
||||
|
||||
formHelper.handleServerValidation(err.data.ModelState);
|
||||
|
||||
for (var e in err.data.ModelState) {
|
||||
notificationsService.error("Validation", err.data.ModelState[e][0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
@@ -120,4 +133,4 @@
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.DataTypeSettingsController", DataTypeSettingsController);
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
+3
-3
@@ -96,7 +96,7 @@ angular.module("umbraco")
|
||||
$scope.layoutConfigOverlay.rows = $scope.model.value.layouts;
|
||||
$scope.layoutConfigOverlay.columns = $scope.model.value.columns;
|
||||
$scope.layoutConfigOverlay.show = true;
|
||||
|
||||
|
||||
$scope.layoutConfigOverlay.submit = function(model) {
|
||||
$scope.layoutConfigOverlay.show = false;
|
||||
$scope.layoutConfigOverlay = null;
|
||||
@@ -218,8 +218,8 @@ angular.module("umbraco")
|
||||
$scope.editConfigCollectionOverlay.show = true;
|
||||
|
||||
$scope.editConfigCollectionOverlay.submit = function(model) {
|
||||
|
||||
callback(model.config)
|
||||
|
||||
callback(model.config);
|
||||
|
||||
$scope.editConfigCollectionOverlay.show = false;
|
||||
$scope.editConfigCollectionOverlay = null;
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
function modelsBuilderController($scope, umbRequestHelper, $log, $http, modelsBuilderResource) {
|
||||
function modelsBuilderController($scope, $http, umbRequestHelper, modelsBuilderResource) {
|
||||
|
||||
$scope.generate = function() {
|
||||
$scope.generating = true;
|
||||
var vm = this;
|
||||
|
||||
vm.reload = reload;
|
||||
vm.generate = generate;
|
||||
vm.dashboard = null;
|
||||
|
||||
function generate() {
|
||||
vm.generating = true;
|
||||
umbRequestHelper.resourcePromise(
|
||||
$http.post(umbRequestHelper.getApiUrl("modelsBuilderBaseUrl", "BuildModels")),
|
||||
'Failed to generate.')
|
||||
.then(function (result) {
|
||||
$scope.generating = false;
|
||||
$scope.dashboard = result;
|
||||
vm.generating = false;
|
||||
vm.dashboard = result;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
$scope.reload = function () {
|
||||
$scope.ready = false;
|
||||
function reload() {
|
||||
vm.loading = true;
|
||||
modelsBuilderResource.getDashboard().then(function (result) {
|
||||
$scope.dashboard = result;
|
||||
$scope.ready = true;
|
||||
vm.dashboard = result;
|
||||
vm.loading = false;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function init() {
|
||||
modelsBuilderResource.getDashboard().then(function(result) {
|
||||
$scope.dashboard = result;
|
||||
$scope.ready = true;
|
||||
vm.loading = true;
|
||||
modelsBuilderResource.getDashboard().then(function (result) {
|
||||
vm.dashboard = result;
|
||||
vm.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
<div id="modelsBuilder" ng-controller="Umbraco.Dashboard.ModelsBuilderController">
|
||||
|
||||
<div ng-show="ready" style="float: right;">
|
||||
<button type="button" class="btn" ng-click="reload()"><span>Reload</span></button>
|
||||
</div>
|
||||
|
||||
<h3>Models Builder</h3>
|
||||
|
||||
<div ng-show="!ready">
|
||||
Loading...
|
||||
</div>
|
||||
|
||||
<div ng-show="ready">
|
||||
<div ng-bind-html="dashboard.text"></div>
|
||||
|
||||
<div ng-if="dashboard.outOfDateModels">
|
||||
<p>Models are <strong>out-of-date</strong>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div ng-if="dashboard.canGenerate">
|
||||
<div ng-if="dashboard.generateCausesRestart">
|
||||
<p style="color: red; font-weight: bold;">Generating models will restart the application.</p>
|
||||
</div>
|
||||
<div ng-show="!generating">
|
||||
<button type="button" ng-click="generate()" class="btn btn-danger">
|
||||
<span>Generate models</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="umb-loader-wrapper" ng-show="generating">
|
||||
<div class="umb-loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="dashboard.lastError" style="margin-top: 32px;" ng-show="!generating">
|
||||
<span style="color: red; font-weight: bold;">Last generation failed with the following error:</span>
|
||||
<pre style="width: 80%; white-space: pre-line; background: #f8f8f8; padding: 4px; font-size: small;">{{dashboard.lastError}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,44 @@
|
||||
<div id="modelsBuilder" ng-controller="Umbraco.Dashboard.ModelsBuilderController as vm">
|
||||
|
||||
<umb-box>
|
||||
<umb-box-content>
|
||||
|
||||
<div ng-show="!vm.loading" class="pull-right">
|
||||
<button type="button" class="btn" ng-click="vm.reload()"><span>Reload</span></button>
|
||||
</div>
|
||||
|
||||
<h3 class="bold">Models Builder</h3>
|
||||
|
||||
<umb-load-indicator ng-show="vm.loading"></umb-load-indicator>
|
||||
|
||||
<div ng-show="!vm.loading && vm.dashboard">
|
||||
<div ng-bind-html="vm.dashboard.text"></div>
|
||||
|
||||
<div ng-if="vm.dashboard.outOfDateModels">
|
||||
<p>Models are <strong>out-of-date</strong>.</p>
|
||||
</div>
|
||||
|
||||
<div ng-if="vm.dashboard.canGenerate">
|
||||
<div ng-if="vm.dashboard.generateCausesRestart">
|
||||
<p style="color: red; font-weight: bold;">Generating models will restart the application.</p>
|
||||
</div>
|
||||
<div ng-show="!vm.generating">
|
||||
<button type="button" ng-click="vm.generate()" class="btn btn-danger">
|
||||
<span>Generate models</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="umb-loader-wrapper" ng-show="vm.generating">
|
||||
<div class="umb-loader"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="vm.dashboard.lastError" style="margin-top: 32px;" ng-show="!vm.generating">
|
||||
<span style="color: red; font-weight: bold;">Last generation failed with the following error:</span>
|
||||
<pre style="width: 80%; white-space: pre-line; background: #f8f8f8; padding: 4px; font-size: small;">{{vm.dashboard.lastError}}</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</umb-box-content>
|
||||
</umb-box>
|
||||
|
||||
</div>
|
||||
@@ -1,7 +1,18 @@
|
||||
{
|
||||
//array of files we want to inject into the application on app_start
|
||||
javascript: [
|
||||
'~/App_Plugins/ModelsBuilder/modelsbuilder.controller.js',
|
||||
'~/App_Plugins/ModelsBuilder/modelsbuilder.resource.js'
|
||||
// array of files we want to inject into the application
|
||||
"javascript": [
|
||||
"~/App_Plugins/ModelsBuilder/modelsbuilder.controller.js",
|
||||
"~/App_Plugins/ModelsBuilder/modelsbuilder.resource.js"
|
||||
],
|
||||
|
||||
// models builder dashboard
|
||||
"dashboards": [
|
||||
{
|
||||
"alias": "settingsModelsBuilder",
|
||||
"name": "Models Builder",
|
||||
"view": "/App_Plugins/ModelsBuilder/modelsbuilder.html",
|
||||
"sections": [ "settings" ],
|
||||
"weight": 40
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -83,7 +83,7 @@
|
||||
<Folder Include="Views\MacroPartials\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="7.0.1" />
|
||||
<PackageReference Include="AutoMapper" Version="8.0.0" />
|
||||
<PackageReference Include="CSharpTest.Net.Collections" Version="14.906.1403.1082" />
|
||||
<PackageReference Include="ClientDependency" Version="1.9.7" />
|
||||
<PackageReference Include="ClientDependency-Mvc5" Version="1.8.0.0" />
|
||||
@@ -91,21 +91,21 @@
|
||||
<PackageReference Include="ImageProcessor.Web" Version="4.9.3.25" />
|
||||
<PackageReference Include="ImageProcessor.Web.Config" Version="2.4.1.19" />
|
||||
<PackageReference Include="Microsoft.AspNet.Identity.Owin" Version="2.2.2" />
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi" Version="5.2.7" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.10.0" />
|
||||
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="2.0.1" />
|
||||
<PackageReference Include="Microsoft.Net.Compilers" Version="2.10.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<!-- development dependency -->
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Owin.Host.SystemWeb" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Owin.Security.Cookies" Version="4.0.0" />
|
||||
<PackageReference Include="Microsoft.Owin.Security.OAuth" Version="4.0.0" />
|
||||
<PackageReference Include="MiniProfiler" Version="3.2.0.157" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<PackageReference Include="Microsoft.Owin.Host.SystemWeb" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.Owin.Security.Cookies" Version="4.0.1" />
|
||||
<PackageReference Include="Microsoft.Owin.Security.OAuth" Version="4.0.1" />
|
||||
<PackageReference Include="MiniProfiler" Version="4.0.138" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="Umbraco.ModelsBuilder.Ui">
|
||||
<Version>8.0.0-alpha.36</Version>
|
||||
<Version>8.0.0-alpha.37</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" />
|
||||
</ItemGroup>
|
||||
@@ -141,7 +141,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.controller.js" />
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.htm" />
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.html" />
|
||||
<Content Include="App_Plugins\ModelsBuilder\modelsbuilder.resource.js" />
|
||||
<Content Include="Config\grid.editors.config.js" />
|
||||
<Content Include="Config\Lang\cs-CZ.user.xml" />
|
||||
|
||||
@@ -25,4 +25,73 @@
|
||||
<compilation debug="true" xdt:Transform="SetAttributes(debug)" />
|
||||
</system.web>
|
||||
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='Newtonsoft.Json']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='Microsoft.Owin']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='Microsoft.Owin.Security']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='Microsoft.Owin.Security.Cookies']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='Microsoft.Owin.Security.OAuth']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='System.Web.Http']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='System.Web.Mvc']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='System.Web.Mvc']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
<dependentAssembly xdt:Transform="Remove"
|
||||
xdt:Locator="Condition(_defaultNamespace:assemblyIdentity[@name='System.Net.Http.Formatting']])"/>
|
||||
<dependentAssembly xdt:Transform="Insert">
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
</configuration>
|
||||
|
||||
@@ -215,23 +215,23 @@
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
@@ -239,16 +239,20 @@
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.6.0" newVersion="5.2.6.0" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Dashboards;
|
||||
|
||||
namespace Umbraco.Web.Dashboards
|
||||
{
|
||||
[Weight(40)]
|
||||
public class ModelsBuilderDashboard : IDashboard
|
||||
{
|
||||
public string Alias => "settingsModelsBuilder";
|
||||
|
||||
public string[] Sections => new [] { "settings" };
|
||||
|
||||
public string View => "/App_Plugins/ModelsBuilder/modelsbuilder.htm";
|
||||
|
||||
public IAccessRule[] AccessRules => Array.Empty<IAccessRule>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -169,7 +169,8 @@ namespace Umbraco.Web.Editors.Binders
|
||||
var member = MemberService.CreateGenericMembershipProviderMember(model.Name, model.Email, model.Username, Guid.NewGuid().ToString("N"));
|
||||
//we'll just remove all properties here otherwise we'll end up with validation errors, we don't want to persist any property data anyways
|
||||
// in this case.
|
||||
FilterContentTypeProperties(member.ContentType, member.ContentType.PropertyTypes.Select(x => x.Alias).ToArray());
|
||||
memberType = _services.MemberTypeService.Get(member.ContentTypeId);
|
||||
FilterContentTypeProperties(memberType, memberType.PropertyTypes.Select(x => x.Alias).ToArray());
|
||||
return member;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1830,8 +1830,10 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
if (model.ParentId < 0)
|
||||
{
|
||||
//cannot move if the content item is not allowed at the root
|
||||
if (toMove.ContentType.AllowedAsRoot == false)
|
||||
//cannot move if the content item is not allowed at the root unless there are
|
||||
//none allowed at root (in which case all should be allowed at root)
|
||||
var contentTypeService = Services.ContentTypeService;
|
||||
if (toMove.ContentType.AllowedAsRoot == false && contentTypeService.GetAll().Any(ct => ct.AllowedAsRoot))
|
||||
{
|
||||
throw new HttpResponseException(
|
||||
Request.CreateNotificationValidationErrorResponse(
|
||||
@@ -1846,8 +1848,7 @@ namespace Umbraco.Web.Editors
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var contentTypeService = Services.ContentTypeBaseServices.For(parent);
|
||||
var parentContentType = contentTypeService.Get(parent.ContentTypeId);
|
||||
var parentContentType = Services.ContentTypeService.Get(parent.ContentTypeId);
|
||||
//check if the item is allowed under this one
|
||||
if (parentContentType.AllowedContentTypes.Select(x => x.Id).ToArray()
|
||||
.Any(x => x.Value == toMove.ContentType.Id) == false)
|
||||
|
||||
@@ -393,7 +393,11 @@ namespace Umbraco.Web.Editors
|
||||
IEnumerable<IContentType> types;
|
||||
if (contentId == Constants.System.Root)
|
||||
{
|
||||
types = Services.ContentTypeService.GetAll().Where(x => x.AllowedAsRoot).ToList();
|
||||
var allContentTypes = Services.ContentTypeService.GetAll().ToList();
|
||||
bool AllowedAsRoot(IContentType x) => x.AllowedAsRoot;
|
||||
types = allContentTypes.Any(AllowedAsRoot)
|
||||
? allContentTypes.Where(AllowedAsRoot).ToList()
|
||||
: allContentTypes;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -403,8 +407,7 @@ namespace Umbraco.Web.Editors
|
||||
return Enumerable.Empty<ContentTypeBasic>();
|
||||
}
|
||||
|
||||
var contentTypeService = Services.ContentTypeBaseServices.For(contentItem);
|
||||
var contentType = contentTypeService.Get(contentItem.ContentTypeId);
|
||||
var contentType = Services.ContentTypeBaseServices.GetContentTypeOf(contentItem);
|
||||
var ids = contentType.AllowedContentTypes.Select(x => x.Id.Value).ToArray();
|
||||
|
||||
if (ids.Any() == false) return Enumerable.Empty<ContentTypeBasic>();
|
||||
|
||||
@@ -14,6 +14,7 @@ using System.Reflection;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
@@ -605,8 +606,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
}
|
||||
|
||||
[HttpQueryStringFilter("queryStrings")]
|
||||
public IEnumerable<EntityBasic> GetAncestors(int id, UmbracoEntityTypes type, FormDataCollection queryStrings)
|
||||
public IEnumerable<EntityBasic> GetAncestors(int id, UmbracoEntityTypes type, [ModelBinder(typeof(HttpQueryStringModelBinder))]FormDataCollection queryStrings)
|
||||
{
|
||||
return GetResultForAncestors(id, type, queryStrings);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.Filters;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
@@ -17,21 +14,23 @@ namespace Umbraco.Web.Editors.Filters
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUmbracoContextAccessor _umbracoContextAccessor;
|
||||
private readonly IMemberTypeService _memberTypeService;
|
||||
|
||||
public MemberSaveValidationAttribute() : this(Current.Logger, Current.UmbracoContextAccessor)
|
||||
{
|
||||
}
|
||||
public MemberSaveValidationAttribute()
|
||||
: this(Current.Logger, Current.UmbracoContextAccessor, Current.Services.MemberTypeService)
|
||||
{ }
|
||||
|
||||
public MemberSaveValidationAttribute(ILogger logger, IUmbracoContextAccessor umbracoContextAccessor)
|
||||
public MemberSaveValidationAttribute(ILogger logger, IUmbracoContextAccessor umbracoContextAccessor, IMemberTypeService memberTypeService)
|
||||
{
|
||||
_logger = logger;
|
||||
_umbracoContextAccessor = umbracoContextAccessor;
|
||||
_memberTypeService = memberTypeService;
|
||||
}
|
||||
|
||||
public override void OnActionExecuting(HttpActionContext actionContext)
|
||||
{
|
||||
var model = (MemberSave)actionContext.ActionArguments["contentItem"];
|
||||
var contentItemValidator = new MemberValidationHelper(_logger, _umbracoContextAccessor);
|
||||
var contentItemValidator = new MemberValidationHelper(_logger, _umbracoContextAccessor, _memberTypeService);
|
||||
//now do each validation step
|
||||
if (contentItemValidator.ValidateExistingContent(model, actionContext))
|
||||
if (contentItemValidator.ValidateProperties(model, model, actionContext))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user