U4-4847 Refactor ContentService (#1266)

* U4-4748 - refactor Content-, Media- and MemberTypeRepository

* Cleanup Attempt

* Cleanup OperationStatus

* U4-4748 - refactor Content-, Media- and MemberTypeService

* U4-4748 - cleanup locking

* U4-4748 - refactor Content-, Media- and MemberRepository

* U4-4748 - refactor ContentService (in progress)

* U4-4748 - all unit of work must be completed

* U4-4748 - refactor locks, fix tests

* U4-4748 - deal with fixmes

* U4-4748 - lock table migration

* Update UmbracoVersion

* Fix AuthorizeUpgrade

* U4-4748 - cleanup+bugfix lock objects

* U4-4748 - bugfix

* updates a string interpolation
This commit is contained in:
Stephan
2016-05-18 10:55:19 +02:00
committed by Shannon Deminick
parent 12f4873c90
commit ddf38407d8
139 changed files with 7539 additions and 6981 deletions

View File

@@ -17,12 +17,14 @@ namespace Umbraco.Core.Models
private IContentType _contentType;
private ITemplate _template;
private bool _published;
private bool? _publishedOriginal;
private string _language;
private DateTime? _releaseDate;
private DateTime? _expireDate;
private int _writer;
private string _nodeName;//NOTE Once localization is introduced this will be the non-localized Node Name.
private bool _permissionsChanged;
/// <summary>
/// Constructor for creating a Content object
/// </summary>
@@ -31,8 +33,7 @@ namespace Umbraco.Core.Models
/// <param name="contentType">ContentType for the current Content object</param>
public Content(string name, IContent parent, IContentType contentType)
: this(name, parent, contentType, new PropertyCollection())
{
}
{ }
/// <summary>
/// Constructor for creating a Content object
@@ -47,6 +48,7 @@ namespace Umbraco.Core.Models
Mandate.ParameterNotNull(contentType, "contentType");
_contentType = contentType;
PublishedState = PublishedState.Unpublished;
}
/// <summary>
@@ -57,8 +59,7 @@ namespace Umbraco.Core.Models
/// <param name="contentType">ContentType for the current Content object</param>
public Content(string name, int parentId, IContentType contentType)
: this(name, parentId, contentType, new PropertyCollection())
{
}
{ }
/// <summary>
/// Constructor for creating a Content object
@@ -73,6 +74,7 @@ namespace Umbraco.Core.Models
Mandate.ParameterNotNull(contentType, "contentType");
_contentType = contentType;
PublishedState = PublishedState.Unpublished;
}
private static readonly PropertyInfo TemplateSelector = ExpressionHelper.GetPropertyInfo<Content, ITemplate>(x => x.Template);
@@ -95,7 +97,13 @@ namespace Umbraco.Core.Models
[DataMember]
public virtual ITemplate Template
{
get { return _template; }
get
{
if (_template == null)
return _contentType.DefaultTemplate;
return _template;
}
set
{
SetPropertyValueAndDetectChanges(o =>
@@ -146,11 +154,19 @@ namespace Umbraco.Core.Models
SetPropertyValueAndDetectChanges(o =>
{
_published = value;
_publishedOriginal = _publishedOriginal ?? _published;
PublishedState = _published ? PublishedState.Published : PublishedState.Unpublished;
return _published;
}, _published, PublishedSelector);
}
}
[IgnoreDataMember]
public bool PublishedOriginal
{
get { return _publishedOriginal ?? false; }
}
/// <summary>
/// Language of the data contained within this Content object.
/// </summary>
@@ -305,12 +321,14 @@ namespace Umbraco.Core.Models
/// </summary>
public void ChangePublishedState(PublishedState state)
{
Published = state == PublishedState.Published;
if (state == PublishedState.Published || state == PublishedState.Unpublished)
throw new ArgumentException("Invalid state.");
Published = state == PublishedState.Publishing;
PublishedState = state;
}
[DataMember]
internal PublishedState PublishedState { get; set; }
internal PublishedState PublishedState { get; private set; }
/// <summary>
/// Gets or sets the unique identifier of the published version, if any.
@@ -322,24 +340,26 @@ namespace Umbraco.Core.Models
/// Gets a value indicating whether the content has a published version.
/// </summary>
public bool HasPublishedVersion { get { return PublishedVersionGuid != default(Guid); } }
/// <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 override void ChangeTrashedState(bool isTrashed, int parentId = -20)
{
Trashed = isTrashed;
ParentId = parentId;
//If the content is trashed and is published it should be marked as unpublished
if (isTrashed && Published)
{
ChangePublishedState(PublishedState.Unpublished);
}
}
public override void ResetDirtyProperties(bool rememberPreviouslyChangedProperties)
{
base.ResetDirtyProperties(rememberPreviouslyChangedProperties);
// take care of the published state
switch (PublishedState)
{
case PublishedState.Saving:
case PublishedState.Unpublishing:
PublishedState = PublishedState.Unpublished;
break;
case PublishedState.Publishing:
PublishedState = PublishedState.Published;
break;
}
_publishedOriginal = _published;
}
/// <summary>
/// Method to call when Entity is being updated
/// </summary>
@@ -377,6 +397,8 @@ namespace Umbraco.Core.Models
property.Version = clone.Version;
}
clone.PublishedVersionGuid = Guid.Empty;
return clone;
}