Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/AB10074-fix-createmember-and-createcontent
# Conflicts: # src/Umbraco.Infrastructure/Services/Implement/MemberService.cs
This commit is contained in:
@@ -3,17 +3,19 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Exceptions;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Core.Services.Changes;
|
||||
using Umbraco.Core.Strings;
|
||||
using Umbraco.Cms.Core.Events;
|
||||
using Umbraco.Cms.Core.Exceptions;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Models.Membership;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Core.Persistence.Repositories;
|
||||
using Umbraco.Cms.Core.Scoping;
|
||||
using Umbraco.Cms.Core.Services.Changes;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
using Umbraco.Cms.Infrastructure.Persistence.Querying;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Core.Services.Implement
|
||||
namespace Umbraco.Cms.Core.Services.Implement
|
||||
{
|
||||
/// <summary>
|
||||
/// Implements the content service.
|
||||
@@ -67,7 +69,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.CountPublished(contentTypeAlias);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +78,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.Count(contentTypeAlias);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +87,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.CountChildren(parentId, contentTypeAlias);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +96,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.CountDescendants(parentId, contentTypeAlias);
|
||||
}
|
||||
}
|
||||
@@ -112,7 +114,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
_documentRepository.ReplaceContentPermissions(permissionSet);
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -128,7 +130,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
_documentRepository.AssignEntityPermission(entity, permission, groupIds);
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -143,7 +145,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetPermissionsForEntity(content.Id);
|
||||
}
|
||||
}
|
||||
@@ -166,7 +168,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 = Constants.Security.SuperUserId)
|
||||
public IContent Create(string name, Guid parentId, string contentTypeAlias, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -186,7 +188,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 = Constants.Security.SuperUserId)
|
||||
public IContent Create(string name, int parentId, string contentTypeAlias, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -214,7 +216,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 = Constants.Security.SuperUserId)
|
||||
public IContent Create(string name, IContent parent, string contentTypeAlias, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -238,14 +240,14 @@ 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 = Constants.Security.SuperUserId)
|
||||
public IContent CreateAndSave(string name, int parentId, string contentTypeAlias, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete:true))
|
||||
{
|
||||
// locking the content tree secures content types too
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var contentType = GetContentType(contentTypeAlias); // + locks
|
||||
if (contentType == null)
|
||||
@@ -272,7 +274,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 = Constants.Security.SuperUserId)
|
||||
public IContent CreateAndSave(string name, IContent parent, string contentTypeAlias, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
// TODO: what about culture?
|
||||
|
||||
@@ -281,7 +283,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete:true))
|
||||
{
|
||||
// locking the content tree secures content types too
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var contentType = GetContentType(contentTypeAlias); // + locks
|
||||
if (contentType == null)
|
||||
@@ -308,7 +310,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.Get(id);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +327,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var items = _documentRepository.GetMany(idsA);
|
||||
|
||||
var index = items.ToDictionary(x => x.Id, x => x);
|
||||
@@ -343,7 +345,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.Get(key);
|
||||
}
|
||||
}
|
||||
@@ -370,7 +372,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var items = _documentRepository.GetMany(idsA);
|
||||
|
||||
var index = items.ToDictionary(x => x.Key, x => x);
|
||||
@@ -391,7 +393,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetPage(
|
||||
Query<IContent>().Where(x => x.ContentTypeId == contentTypeId),
|
||||
pageIndex, pageSize, out totalRecords, filter, ordering);
|
||||
@@ -409,7 +411,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetPage(
|
||||
Query<IContent>().Where(x => contentTypeIds.Contains(x.ContentTypeId)),
|
||||
pageIndex, pageSize, out totalRecords, filter, ordering);
|
||||
@@ -426,7 +428,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var query = Query<IContent>().Where(x => x.Level == level && x.Trashed == false);
|
||||
return _documentRepository.Get(query);
|
||||
}
|
||||
@@ -441,7 +443,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetVersion(versionId);
|
||||
}
|
||||
}
|
||||
@@ -455,7 +457,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetAllVersions(id);
|
||||
}
|
||||
}
|
||||
@@ -468,7 +470,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetAllVersionsSlim(id, skip, take);
|
||||
}
|
||||
}
|
||||
@@ -509,7 +511,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
//null check otherwise we get exceptions
|
||||
if (content.Path.IsNullOrWhiteSpace()) return Enumerable.Empty<IContent>();
|
||||
|
||||
var rootId = Constants.System.RootString;
|
||||
var rootId = Cms.Core.Constants.System.RootString;
|
||||
var ids = content.Path.Split(',')
|
||||
.Where(x => x != rootId && x != content.Id.ToString(CultureInfo.InvariantCulture)).Select(int.Parse).ToArray();
|
||||
if (ids.Any() == false)
|
||||
@@ -517,7 +519,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetMany(ids);
|
||||
}
|
||||
}
|
||||
@@ -531,7 +533,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var query = Query<IContent>().Where(x => x.ParentId == id && x.Published);
|
||||
return _documentRepository.Get(query).OrderBy(x => x.SortOrder);
|
||||
}
|
||||
@@ -549,7 +551,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var query = Query<IContent>().Where(x => x.ParentId == id);
|
||||
return _documentRepository.GetPage(query, pageIndex, pageSize, out totalChildren, filter, ordering);
|
||||
@@ -565,12 +567,12 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
//if the id is System Root, then just get all
|
||||
if (id != Constants.System.Root)
|
||||
if (id != Cms.Core.Constants.System.Root)
|
||||
{
|
||||
var contentPath = _entityRepository.GetAllPaths(Constants.ObjectTypes.Document, id).ToArray();
|
||||
var contentPath = _entityRepository.GetAllPaths(Cms.Core.Constants.ObjectTypes.Document, id).ToArray();
|
||||
if (contentPath.Length == 0)
|
||||
{
|
||||
totalChildren = 0;
|
||||
@@ -619,7 +621,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <returns>Parent <see cref="IContent"/> object</returns>
|
||||
public IContent GetParent(IContent content)
|
||||
{
|
||||
if (content.ParentId == Constants.System.Root || content.ParentId == Constants.System.RecycleBinContent)
|
||||
if (content.ParentId == Cms.Core.Constants.System.Root || content.ParentId == Cms.Core.Constants.System.RecycleBinContent)
|
||||
return null;
|
||||
|
||||
return GetById(content.ParentId);
|
||||
@@ -633,8 +635,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
var query = Query<IContent>().Where(x => x.ParentId == Constants.System.Root);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var query = Query<IContent>().Where(x => x.ParentId == Cms.Core.Constants.System.Root);
|
||||
return _documentRepository.Get(query);
|
||||
}
|
||||
}
|
||||
@@ -647,7 +649,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.Get(QueryNotTrashed);
|
||||
}
|
||||
}
|
||||
@@ -657,7 +659,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetContentForExpiration(date);
|
||||
}
|
||||
}
|
||||
@@ -667,7 +669,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.GetContentForRelease(date);
|
||||
}
|
||||
}
|
||||
@@ -684,8 +686,8 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (ordering == null)
|
||||
ordering = Ordering.By("Path");
|
||||
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
var query = Query<IContent>().Where(x => x.Path.StartsWith(Constants.System.RecycleBinContentPathPrefix));
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var query = Query<IContent>().Where(x => x.Path.StartsWith(Cms.Core.Constants.System.RecycleBinContentPathPrefix));
|
||||
return _documentRepository.GetPage(query, pageIndex, pageSize, out totalRecords, filter, ordering);
|
||||
}
|
||||
}
|
||||
@@ -708,7 +710,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
public bool IsPathPublishable(IContent content)
|
||||
{
|
||||
// fast
|
||||
if (content.ParentId == Constants.System.Root) return true; // root content is always publishable
|
||||
if (content.ParentId == Cms.Core.Constants.System.Root) return true; // root content is always publishable
|
||||
if (content.Trashed) return false; // trashed content is never publishable
|
||||
|
||||
// not trashed and has a parent: publishable if the parent is path-published
|
||||
@@ -720,7 +722,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return _documentRepository.IsPathPublished(content);
|
||||
}
|
||||
}
|
||||
@@ -730,7 +732,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
#region Save, Publish, Unpublish
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationResult Save(IContent content, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
public OperationResult Save(IContent content, int userId = Cms.Core.Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var publishedState = content.PublishedState;
|
||||
if (publishedState != PublishedState.Published && publishedState != PublishedState.Unpublished)
|
||||
@@ -752,7 +754,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
return OperationResult.Cancel(evtMsgs);
|
||||
}
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
if (content.HasIdentity == false)
|
||||
content.CreatorId = userId;
|
||||
@@ -793,7 +795,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationResult Save(IEnumerable<IContent> contents, int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
public OperationResult Save(IEnumerable<IContent> contents, int userId = Cms.Core.Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
var contentsA = contents.ToArray();
|
||||
@@ -809,7 +811,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
var treeChanges = contentsA.Select(x => new TreeChange<IContent>(x, TreeChangeTypes.RefreshNode));
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
foreach (var content in contentsA)
|
||||
{
|
||||
if (content.HasIdentity == false)
|
||||
@@ -824,7 +826,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
scope.Events.Dispatch(Saved, this, saveEventArgs.ToContentSavedEventArgs(), nameof(Saved));
|
||||
}
|
||||
scope.Events.Dispatch(TreeChanged, this, treeChanges.ToEventArgs());
|
||||
Audit(AuditType.Save, userId == -1 ? 0 : userId, Constants.System.Root, "Saved multiple content");
|
||||
Audit(AuditType.Save, userId == -1 ? 0 : userId, Cms.Core.Constants.System.Root, "Saved multiple content");
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -833,7 +835,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public PublishResult SaveAndPublish(IContent content, string culture = "*", int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
public PublishResult SaveAndPublish(IContent content, string culture = "*", int userId = Cms.Core.Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -861,7 +863,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var allLangs = _languageRepository.GetMany().ToList();
|
||||
|
||||
@@ -898,7 +900,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var allLangs = _languageRepository.GetMany().ToList();
|
||||
|
||||
@@ -932,7 +934,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public PublishResult Unpublish(IContent content, string culture = "*", int userId = Constants.Security.SuperUserId)
|
||||
public PublishResult Unpublish(IContent content, string culture = "*", int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
if (content == null) throw new ArgumentNullException(nameof(content));
|
||||
|
||||
@@ -963,7 +965,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var allLangs = _languageRepository.GetMany().ToList();
|
||||
|
||||
@@ -1029,13 +1031,13 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <para>The document is *always* saved, even when publishing fails.</para>
|
||||
/// </remarks>
|
||||
internal PublishResult CommitDocumentChanges(IContent content,
|
||||
int userId = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
int userId = Cms.Core.Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var saveEventArgs = new ContentSavingEventArgs(content, evtMsgs);
|
||||
if (raiseEvents && scope.Events.DispatchCancelable(Saving, this, saveEventArgs, nameof(Saving)))
|
||||
@@ -1068,7 +1070,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// </remarks>
|
||||
private PublishResult CommitDocumentChangesInternal(IScope scope, IContent content,
|
||||
ContentSavingEventArgs saveEventArgs, IReadOnlyCollection<ILanguage> allLangs,
|
||||
int userId = Constants.Security.SuperUserId,
|
||||
int userId = Cms.Core.Constants.Security.SuperUserId,
|
||||
bool raiseEvents = true, bool branchOne = false, bool branchRoot = false)
|
||||
{
|
||||
if (scope == null) throw new ArgumentNullException(nameof(scope));
|
||||
@@ -1358,7 +1360,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (_documentRepository.HasContentForExpiration(date))
|
||||
{
|
||||
// now take a write lock since we'll be updating
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
foreach (var d in _documentRepository.GetContentForExpiration(date))
|
||||
{
|
||||
@@ -1419,7 +1421,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (_documentRepository.HasContentForRelease(date))
|
||||
{
|
||||
// now take a write lock since we'll be updating
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
foreach (var d in _documentRepository.GetContentForRelease(date))
|
||||
{
|
||||
@@ -1538,7 +1540,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string culture = "*", int userId = Constants.Security.SuperUserId)
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string culture = "*", int userId = Cms.Core.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
|
||||
@@ -1580,7 +1582,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string[] cultures, int userId = Constants.Security.SuperUserId)
|
||||
public IEnumerable<PublishResult> SaveAndPublishBranch(IContent content, bool force, string[] cultures, int userId = Cms.Core.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
|
||||
@@ -1619,7 +1621,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
internal IEnumerable<PublishResult> SaveAndPublishBranch(IContent document, bool force,
|
||||
Func<IContent, HashSet<string>> shouldPublish,
|
||||
Func<IContent, HashSet<string>, IReadOnlyCollection<ILanguage>, bool> publishCultures,
|
||||
int userId = Constants.Security.SuperUserId)
|
||||
int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
if (shouldPublish == null) throw new ArgumentNullException(nameof(shouldPublish));
|
||||
if (publishCultures == null) throw new ArgumentNullException(nameof(publishCultures));
|
||||
@@ -1630,7 +1632,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var allLangs = _languageRepository.GetMany().ToList();
|
||||
|
||||
@@ -1738,7 +1740,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
#region Delete
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationResult Delete(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
public OperationResult Delete(IContent content, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -1751,7 +1753,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
return OperationResult.Cancel(evtMsgs);
|
||||
}
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
// if it's not trashed yet, and published, we should unpublish
|
||||
// but... Unpublishing event makes no sense (not going to cancel?) and no need to save
|
||||
@@ -1805,7 +1807,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 = Constants.Security.SuperUserId)
|
||||
public void DeleteVersions(int id, DateTime versionDate, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -1816,12 +1818,12 @@ namespace Umbraco.Core.Services.Implement
|
||||
return;
|
||||
}
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
_documentRepository.DeleteVersions(id, versionDate);
|
||||
|
||||
deleteRevisionsEventArgs.CanCancel = false;
|
||||
scope.Events.Dispatch(DeletedVersions, this, deleteRevisionsEventArgs);
|
||||
Audit(AuditType.Delete, userId, Constants.System.Root, "Delete (by version date)");
|
||||
Audit(AuditType.Delete, userId, Cms.Core.Constants.System.Root, "Delete (by version date)");
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -1835,7 +1837,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 = Constants.Security.SuperUserId)
|
||||
public void DeleteVersion(int id, int versionId, bool deletePriorVersions, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -1851,13 +1853,13 @@ namespace Umbraco.Core.Services.Implement
|
||||
DeleteVersions(id, content.UpdateDate, userId);
|
||||
}
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var c = _documentRepository.Get(id);
|
||||
if (c.VersionId != versionId && c.PublishedVersionId != versionId) // don't delete the current or published version
|
||||
_documentRepository.DeleteVersion(versionId);
|
||||
|
||||
scope.Events.Dispatch(DeletedVersions, this, new DeleteRevisionsEventArgs(id, false,/* specificVersion:*/ versionId));
|
||||
Audit(AuditType.Delete, userId, Constants.System.Root, "Delete (by version)");
|
||||
Audit(AuditType.Delete, userId, Cms.Core.Constants.System.Root, "Delete (by version)");
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -1868,17 +1870,17 @@ namespace Umbraco.Core.Services.Implement
|
||||
#region Move, RecycleBin
|
||||
|
||||
/// <inheritdoc />
|
||||
public OperationResult MoveToRecycleBin(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
public OperationResult MoveToRecycleBin(IContent content, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
var moves = new List<(IContent, string)>();
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var originalPath = content.Path;
|
||||
var moveEventInfo = new MoveEventInfo<IContent>(content, originalPath, Constants.System.RecycleBinContent);
|
||||
var moveEventInfo = new MoveEventInfo<IContent>(content, originalPath, Cms.Core.Constants.System.RecycleBinContent);
|
||||
var moveEventArgs = new MoveEventArgs<IContent>(evtMsgs, moveEventInfo);
|
||||
if (scope.Events.DispatchCancelable(Trashing, this, moveEventArgs, nameof(Trashing)))
|
||||
{
|
||||
@@ -1892,7 +1894,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
//if (content.HasPublishedVersion)
|
||||
//{ }
|
||||
|
||||
PerformMoveLocked(content, Constants.System.RecycleBinContent, null, userId, moves, true);
|
||||
PerformMoveLocked(content, Cms.Core.Constants.System.RecycleBinContent, null, userId, moves, true);
|
||||
scope.Events.Dispatch(TreeChanged, this, new TreeChange<IContent>(content, TreeChangeTypes.RefreshBranch).ToEventArgs());
|
||||
|
||||
var moveInfo = moves
|
||||
@@ -1921,10 +1923,10 @@ 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 = Constants.Security.SuperUserId)
|
||||
public void Move(IContent content, int parentId, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
// if moving to the recycle bin then use the proper method
|
||||
if (parentId == Constants.System.RecycleBinContent)
|
||||
if (parentId == Cms.Core.Constants.System.RecycleBinContent)
|
||||
{
|
||||
MoveToRecycleBin(content, userId);
|
||||
return;
|
||||
@@ -1934,10 +1936,10 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var parent = parentId == Constants.System.Root ? null : GetById(parentId);
|
||||
if (parentId != Constants.System.Root && (parent == null || parent.Trashed))
|
||||
var parent = parentId == Cms.Core.Constants.System.Root ? null : GetById(parentId);
|
||||
if (parentId != Cms.Core.Constants.System.Root && (parent == null || parent.Trashed))
|
||||
throw new InvalidOperationException("Parent does not exist or is trashed."); // causes rollback
|
||||
|
||||
var moveEventInfo = new MoveEventInfo<IContent>(content, content.Path, parentId);
|
||||
@@ -2009,7 +2011,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
// if uow is not immediate, content.Path will be updated only when the UOW commits,
|
||||
// and because we want it now, we have to calculate it by ourselves
|
||||
//paths[content.Id] = content.Path;
|
||||
paths[content.Id] = (parent == null ? (parentId == Constants.System.RecycleBinContent ? "-1,-20" : Constants.System.RootString) : parent.Path) + "," + content.Id;
|
||||
paths[content.Id] = (parent == null ? (parentId == Cms.Core.Constants.System.RecycleBinContent ? "-1,-20" : Cms.Core.Constants.System.RootString) : parent.Path) + "," + content.Id;
|
||||
|
||||
const int pageSize = 500;
|
||||
var query = GetPagedDescendantQuery(originalPath);
|
||||
@@ -2043,15 +2045,15 @@ namespace Umbraco.Core.Services.Implement
|
||||
/// <summary>
|
||||
/// Empties the Recycle Bin by deleting all <see cref="IContent"/> that resides in the bin
|
||||
/// </summary>
|
||||
public OperationResult EmptyRecycleBin(int userId = Constants.Security.SuperUserId)
|
||||
public OperationResult EmptyRecycleBin(int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
var nodeObjectType = Constants.ObjectTypes.Document;
|
||||
var nodeObjectType = Cms.Core.Constants.ObjectTypes.Document;
|
||||
var deleted = new List<IContent>();
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
// v7 EmptyingRecycleBin and EmptiedRecycleBin events are greatly simplified since
|
||||
// each deleted items will have its own deleting/deleted events. so, files and such
|
||||
@@ -2066,7 +2068,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
|
||||
// emptying the recycle bin means deleting whatever is in there - do it properly!
|
||||
var query = Query<IContent>().Where(x => x.ParentId == Constants.System.RecycleBinContent);
|
||||
var query = Query<IContent>().Where(x => x.ParentId == Cms.Core.Constants.System.RecycleBinContent);
|
||||
var contents = _documentRepository.Get(query).ToArray();
|
||||
foreach (var content in contents)
|
||||
{
|
||||
@@ -2078,7 +2080,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
recycleBinEventArgs.RecycleBinEmptiedSuccessfully = true; // oh my?!
|
||||
scope.Events.Dispatch(EmptiedRecycleBin, this, recycleBinEventArgs);
|
||||
scope.Events.Dispatch(TreeChanged, this, deleted.Select(x => new TreeChange<IContent>(x, TreeChangeTypes.Remove)).ToEventArgs());
|
||||
Audit(AuditType.Delete, userId, Constants.System.RecycleBinContent, "Recycle bin emptied");
|
||||
Audit(AuditType.Delete, userId, Cms.Core.Constants.System.RecycleBinContent, "Recycle bin emptied");
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -2099,7 +2101,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 = Constants.Security.SuperUserId)
|
||||
public IContent Copy(IContent content, int parentId, bool relateToOriginal, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
return Copy(content, parentId, relateToOriginal, true, userId);
|
||||
}
|
||||
@@ -2114,7 +2116,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 = Constants.Security.SuperUserId)
|
||||
public IContent Copy(IContent content, int parentId, bool relateToOriginal, bool recursive, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
var copy = content.DeepCloneWithResetIdentities();
|
||||
copy.ParentId = parentId;
|
||||
@@ -2134,7 +2136,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
var copies = new List<Tuple<IContent, IContent>>();
|
||||
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
// a copy is not published (but not really unpublishing either)
|
||||
// update the create author and last edit author
|
||||
@@ -2217,7 +2219,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 = Constants.Security.SuperUserId)
|
||||
public bool SendToPublication(IContent content, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
@@ -2271,7 +2273,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 = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
public OperationResult Sort(IEnumerable<IContent> items, int userId = Cms.Core.Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -2280,7 +2282,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var ret = Sort(scope, itemsA, userId, evtMsgs, raiseEvents);
|
||||
scope.Complete();
|
||||
@@ -2300,7 +2302,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 = Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
public OperationResult Sort(IEnumerable<int> ids, int userId = Cms.Core.Constants.Security.SuperUserId, bool raiseEvents = true)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
@@ -2309,7 +2311,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var itemsA = GetByIds(idsA).ToArray();
|
||||
|
||||
var ret = Sort(scope, itemsA, userId, evtMsgs, raiseEvents);
|
||||
@@ -2381,7 +2383,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var report = _documentRepository.CheckDataIntegrity(options);
|
||||
|
||||
@@ -2409,7 +2411,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
return GetPublishedDescendantsLocked(content).ToArray(); // ToArray important in uow!
|
||||
}
|
||||
}
|
||||
@@ -2696,7 +2698,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
// check if the content can be path-published
|
||||
// root content can be published
|
||||
// else check ancestors - we know we are not trashed
|
||||
var pathIsOk = content.ParentId == Constants.System.Root || IsPathPublished(GetParent(content));
|
||||
var pathIsOk = content.ParentId == Cms.Core.Constants.System.Root || IsPathPublished(GetParent(content));
|
||||
if (!pathIsOk)
|
||||
{
|
||||
_logger.LogInformation("Document {ContentName} (id={ContentId}) cannot be published: {Reason}", content.Name, content.Id, "parent is not published");
|
||||
@@ -2823,7 +2825,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 = Constants.Security.SuperUserId)
|
||||
public void DeleteOfTypes(IEnumerable<int> contentTypeIds, int userId = Cms.Core.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.
|
||||
@@ -2842,7 +2844,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
//
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var query = Query<IContent>().WhereIn(x => x.ContentTypeId, contentTypeIdsA);
|
||||
var contents = _documentRepository.Get(query).ToArray();
|
||||
@@ -2870,7 +2872,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
foreach (var child in children)
|
||||
{
|
||||
// see MoveToRecycleBin
|
||||
PerformMoveLocked(child, Constants.System.RecycleBinContent, null, userId, moves, true);
|
||||
PerformMoveLocked(child, Cms.Core.Constants.System.RecycleBinContent, null, userId, moves, true);
|
||||
changes.Add(new TreeChange<IContent>(content, TreeChangeTypes.RefreshBranch));
|
||||
}
|
||||
|
||||
@@ -2887,7 +2889,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
scope.Events.Dispatch(Trashed, this, new MoveEventArgs<IContent>(false, moveInfos), nameof(Trashed));
|
||||
scope.Events.Dispatch(TreeChanged, this, changes.ToEventArgs());
|
||||
|
||||
Audit(AuditType.Delete, userId, Constants.System.Root, $"Delete content of type {string.Join(",", contentTypeIdsA)}");
|
||||
Audit(AuditType.Delete, userId, Cms.Core.Constants.System.Root, $"Delete content of type {string.Join(",", contentTypeIdsA)}");
|
||||
|
||||
scope.Complete();
|
||||
}
|
||||
@@ -2899,7 +2901,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 = Constants.Security.SuperUserId)
|
||||
public void DeleteOfType(int contentTypeId, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
DeleteOfTypes(new[] { contentTypeId }, userId);
|
||||
}
|
||||
@@ -2909,7 +2911,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
if (contentTypeAlias == null) throw new ArgumentNullException(nameof(contentTypeAlias));
|
||||
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(contentTypeAlias));
|
||||
|
||||
scope.ReadLock(Constants.Locks.ContentTypes);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTypes);
|
||||
|
||||
var query = Query<IContentType>().Where(x => x.Alias == contentTypeAlias);
|
||||
var contentType = _contentTypeRepository.Get(query).FirstOrDefault();
|
||||
@@ -2939,7 +2941,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var blueprint = _documentBlueprintRepository.Get(id);
|
||||
if (blueprint != null)
|
||||
blueprint.Blueprint = true;
|
||||
@@ -2951,7 +2953,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
|
||||
{
|
||||
scope.ReadLock(Constants.Locks.ContentTree);
|
||||
scope.ReadLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
var blueprint = _documentBlueprintRepository.Get(id);
|
||||
if (blueprint != null)
|
||||
blueprint.Blueprint = true;
|
||||
@@ -2959,7 +2961,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveBlueprint(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
public void SaveBlueprint(IContent content, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
//always ensure the blueprint is at the root
|
||||
if (content.ParentId != -1)
|
||||
@@ -2969,7 +2971,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
if (content.HasIdentity == false)
|
||||
{
|
||||
@@ -2979,7 +2981,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
_documentBlueprintRepository.Save(content);
|
||||
|
||||
Audit(AuditType.Save, Constants.Security.SuperUserId, content.Id, $"Saved content template: {content.Name}");
|
||||
Audit(AuditType.Save, Cms.Core.Constants.Security.SuperUserId, content.Id, $"Saved content template: {content.Name}");
|
||||
|
||||
scope.Events.Dispatch(SavedBlueprint, this, new SaveEventArgs<IContent>(content), "SavedBlueprint");
|
||||
|
||||
@@ -2987,11 +2989,11 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlueprint(IContent content, int userId = Constants.Security.SuperUserId)
|
||||
public void DeleteBlueprint(IContent content, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
_documentBlueprintRepository.Delete(content);
|
||||
scope.Events.Dispatch(DeletedBlueprint, this, new DeleteEventArgs<IContent>(content), nameof(DeletedBlueprint));
|
||||
scope.Complete();
|
||||
@@ -3000,7 +3002,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
private static readonly string[] ArrayOfOneNullString = { null };
|
||||
|
||||
public IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = Constants.Security.SuperUserId)
|
||||
public IContent CreateContentFromBlueprint(IContent blueprint, string name, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
if (blueprint == null) throw new ArgumentNullException(nameof(blueprint));
|
||||
|
||||
@@ -3061,11 +3063,11 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = Constants.Security.SuperUserId)
|
||||
public void DeleteBlueprintsOfTypes(IEnumerable<int> contentTypeIds, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
scope.WriteLock(Constants.Locks.ContentTree);
|
||||
scope.WriteLock(Cms.Core.Constants.Locks.ContentTree);
|
||||
|
||||
var contentTypeIdsA = contentTypeIds.ToArray();
|
||||
var query = Query<IContent>();
|
||||
@@ -3088,7 +3090,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBlueprintsOfType(int contentTypeId, int userId = Constants.Security.SuperUserId)
|
||||
public void DeleteBlueprintsOfType(int contentTypeId, int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
DeleteBlueprintsOfTypes(new[] { contentTypeId }, userId);
|
||||
}
|
||||
@@ -3097,7 +3099,7 @@ namespace Umbraco.Core.Services.Implement
|
||||
|
||||
#region Rollback
|
||||
|
||||
public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Constants.Security.SuperUserId)
|
||||
public OperationResult Rollback(int id, int versionId, string culture = "*", int userId = Cms.Core.Constants.Security.SuperUserId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user