Merge branch '7.2.0' of https://github.com/umbraco/Umbraco-CMS into 7.2.0
This commit is contained in:
@@ -526,6 +526,7 @@ namespace Umbraco.Core.Models
|
||||
#endregion
|
||||
|
||||
#region User/Profile methods
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this media item.
|
||||
/// </summary>
|
||||
@@ -534,6 +535,14 @@ namespace Umbraco.Core.Models
|
||||
return ApplicationContext.Current.Services.UserService.GetProfileById(media.CreatorId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this media item.
|
||||
/// </summary>
|
||||
public static IProfile GetCreatorProfile(this IMedia media, IUserService userService)
|
||||
{
|
||||
return userService.GetProfileById(media.CreatorId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this content item.
|
||||
/// </summary>
|
||||
@@ -542,6 +551,14 @@ namespace Umbraco.Core.Models
|
||||
return ApplicationContext.Current.Services.UserService.GetProfileById(content.CreatorId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Creator of this content item.
|
||||
/// </summary>
|
||||
public static IProfile GetCreatorProfile(this IContentBase content, IUserService userService)
|
||||
{
|
||||
return userService.GetProfileById(content.CreatorId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Writer of this content.
|
||||
/// </summary>
|
||||
@@ -549,6 +566,15 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
return ApplicationContext.Current.Services.UserService.GetProfileById(content.WriterId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IProfile"/> for the Writer of this content.
|
||||
/// </summary>
|
||||
public static IProfile GetWriterProfile(this IContent content, IUserService userService)
|
||||
{
|
||||
return userService.GetProfileById(content.WriterId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,11 +19,12 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
|
||||
private static readonly Dictionary<int, Type> OrderedTables = new Dictionary<int, Type>
|
||||
{
|
||||
{0, typeof (NodeDto)},
|
||||
{1, typeof (TemplateDto)},
|
||||
{2, typeof (ContentDto)},
|
||||
{3, typeof (ContentVersionDto)},
|
||||
{4, typeof (DocumentDto)},
|
||||
{5, typeof (ContentTypeDto)},
|
||||
{1, typeof (ContentTypeDto)},
|
||||
{2, typeof (TemplateDto)},
|
||||
{3, typeof (ContentDto)},
|
||||
{4, typeof (ContentVersionDto)},
|
||||
{5, typeof (DocumentDto)},
|
||||
|
||||
{6, typeof (DocumentTypeDto)},
|
||||
{7, typeof (DataTypeDto)},
|
||||
{8, typeof (DataTypePreValueDto)},
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenTwoZero
|
||||
{
|
||||
[Migration("7.2.0", 2, GlobalSettings.UmbracoMigrationName)]
|
||||
public class RemoveCmsDocumentAliasColumn : MigrationBase
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
Delete.Column("alias").FromTable("cmsDocument");
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ namespace Umbraco.Core.Services
|
||||
private readonly RepositoryFactory _repositoryFactory;
|
||||
private readonly EntityXmlSerializer _entitySerializer = new EntityXmlSerializer();
|
||||
private readonly IDataTypeService _dataTypeService;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
//Support recursive locks because some of the methods that require locking call other methods that require locking.
|
||||
//for example, the Move method needs to be locked but this calls the Save method which also needs to be locked.
|
||||
@@ -61,9 +62,10 @@ namespace Umbraco.Core.Services
|
||||
_publishingStrategy = publishingStrategy;
|
||||
_repositoryFactory = repositoryFactory;
|
||||
_dataTypeService = new DataTypeService(provider, repositoryFactory);
|
||||
_userService = new UserService(provider, repositoryFactory);
|
||||
}
|
||||
|
||||
public ContentService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IPublishingStrategy publishingStrategy, IDataTypeService dataTypeService)
|
||||
public ContentService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IPublishingStrategy publishingStrategy, IDataTypeService dataTypeService, IUserService userService)
|
||||
{
|
||||
if (provider == null) throw new ArgumentNullException("provider");
|
||||
if (repositoryFactory == null) throw new ArgumentNullException("repositoryFactory");
|
||||
@@ -72,6 +74,7 @@ namespace Umbraco.Core.Services
|
||||
_publishingStrategy = publishingStrategy;
|
||||
_repositoryFactory = repositoryFactory;
|
||||
_dataTypeService = dataTypeService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
public int Count(string contentTypeAlias = null)
|
||||
@@ -253,7 +256,7 @@ namespace Umbraco.Core.Services
|
||||
content.WriterId = userId;
|
||||
repository.AddOrUpdate(content);
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
@@ -305,7 +308,7 @@ namespace Umbraco.Core.Services
|
||||
content.WriterId = userId;
|
||||
repository.AddOrUpdate(content);
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
@@ -927,7 +930,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
repository.AddOrUpdate(content);
|
||||
//add or update preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -937,7 +940,7 @@ namespace Umbraco.Core.Services
|
||||
content.WriterId = userId;
|
||||
repository.AddOrUpdate(content);
|
||||
//add or update preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,7 +1278,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
repository.AddOrUpdate(copy);
|
||||
//add or update a preview
|
||||
repository.AddOrUpdatePreviewXml(copy, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(copy, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
uow.Commit();
|
||||
|
||||
|
||||
@@ -1366,7 +1369,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
repository.AddOrUpdate(content);
|
||||
//add or update a preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
@@ -1432,13 +1435,13 @@ namespace Umbraco.Core.Services
|
||||
|
||||
repository.AddOrUpdate(content);
|
||||
//add or update a preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
}
|
||||
|
||||
foreach (var content in shouldBePublished)
|
||||
{
|
||||
//Create and Save ContentXml DTO
|
||||
repository.AddOrUpdateContentXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdateContentXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
@@ -1525,7 +1528,7 @@ namespace Umbraco.Core.Services
|
||||
// change how this method calls "Save" as it needs to save using an internal method
|
||||
using (var uow = _uowProvider.GetUnitOfWork())
|
||||
{
|
||||
var xml = _entitySerializer.Serialize(this, _dataTypeService, content);
|
||||
var xml = _entitySerializer.Serialize(this, _dataTypeService, _userService, content);
|
||||
|
||||
var poco = new ContentXmlDto { NodeId = content.Id, Xml = xml.ToString(SaveOptions.None) };
|
||||
var exists =
|
||||
@@ -1586,7 +1589,7 @@ namespace Umbraco.Core.Services
|
||||
var xmlItems = new List<ContentXmlDto>();
|
||||
foreach (var c in list)
|
||||
{
|
||||
var xml = _entitySerializer.Serialize(this, _dataTypeService, c);
|
||||
var xml = _entitySerializer.Serialize(this, _dataTypeService, _userService, c);
|
||||
xmlItems.Add(new ContentXmlDto { NodeId = c.Id, Xml = xml.ToString(SaveOptions.None) });
|
||||
}
|
||||
|
||||
@@ -1704,9 +1707,9 @@ namespace Umbraco.Core.Services
|
||||
item.Result.ContentItem.WriterId = userId;
|
||||
repository.AddOrUpdate(item.Result.ContentItem);
|
||||
//add or update a preview
|
||||
repository.AddOrUpdatePreviewXml(item.Result.ContentItem, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(item.Result.ContentItem, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
//add or update the published xml
|
||||
repository.AddOrUpdateContentXml(item.Result.ContentItem, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdateContentXml(item.Result.ContentItem, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
updated.Add(item.Result.ContentItem);
|
||||
}
|
||||
|
||||
@@ -1813,12 +1816,12 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdate(content);
|
||||
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
|
||||
if (published)
|
||||
{
|
||||
//Content Xml
|
||||
repository.AddOrUpdateContentXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdateContentXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
@@ -1880,7 +1883,7 @@ namespace Umbraco.Core.Services
|
||||
repository.AddOrUpdate(content);
|
||||
|
||||
//Generate a new preview
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, c));
|
||||
repository.AddOrUpdatePreviewXml(content, c => _entitySerializer.Serialize(this, _dataTypeService, _userService, c));
|
||||
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
@@ -23,18 +23,19 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="contentService"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="content">Content to export</param>
|
||||
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
|
||||
/// <returns><see cref="XElement"/> containing the xml representation of the Content object</returns>
|
||||
public XElement Serialize(IContentService contentService, IDataTypeService dataTypeService, IContent content, bool deep = false)
|
||||
public XElement Serialize(IContentService contentService, IDataTypeService dataTypeService, IUserService userService, IContent content, bool deep = false)
|
||||
{
|
||||
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
|
||||
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
|
||||
|
||||
var xml = Serialize(dataTypeService, content, nodeName);
|
||||
xml.Add(new XAttribute("nodeType", content.ContentType.Id));
|
||||
xml.Add(new XAttribute("creatorName", content.GetCreatorProfile().Name));
|
||||
xml.Add(new XAttribute("writerName", content.GetWriterProfile().Name));
|
||||
xml.Add(new XAttribute("creatorName", content.GetCreatorProfile(userService).Name));
|
||||
xml.Add(new XAttribute("writerName", content.GetWriterProfile(userService).Name));
|
||||
xml.Add(new XAttribute("writerID", content.WriterId));
|
||||
xml.Add(new XAttribute("template", content.Template == null ? "0" : content.Template.Id.ToString(CultureInfo.InvariantCulture)));
|
||||
xml.Add(new XAttribute("nodeTypeAlias", content.ContentType.Alias));
|
||||
@@ -43,7 +44,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var descendants = contentService.GetDescendants(content).ToArray();
|
||||
var currentChildren = descendants.Where(x => x.ParentId == content.Id);
|
||||
AddChildXml(contentService, dataTypeService, descendants, currentChildren, xml);
|
||||
AddChildXml(contentService, dataTypeService, userService, descendants, currentChildren, xml);
|
||||
}
|
||||
|
||||
return xml;
|
||||
@@ -54,17 +55,18 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="mediaService"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="media">Media to export</param>
|
||||
/// <param name="deep">Optional parameter indicating whether to include descendents</param>
|
||||
/// <returns><see cref="XElement"/> containing the xml representation of the Media object</returns>
|
||||
public XElement Serialize(IMediaService mediaService, IDataTypeService dataTypeService, IMedia media, bool deep = false)
|
||||
public XElement Serialize(IMediaService mediaService, IDataTypeService dataTypeService, IUserService userService, IMedia media, bool deep = false)
|
||||
{
|
||||
//nodeName should match Casing.SafeAliasWithForcingCheck(content.ContentType.Alias);
|
||||
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();
|
||||
|
||||
var xml = Serialize(dataTypeService, media, nodeName);
|
||||
xml.Add(new XAttribute("nodeType", media.ContentType.Id));
|
||||
xml.Add(new XAttribute("writerName", media.GetCreatorProfile().Name));
|
||||
xml.Add(new XAttribute("writerName", media.GetCreatorProfile(userService).Name));
|
||||
xml.Add(new XAttribute("writerID", media.CreatorId));
|
||||
xml.Add(new XAttribute("version", media.Version));
|
||||
xml.Add(new XAttribute("template", 0));
|
||||
@@ -74,7 +76,7 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
var descendants = mediaService.GetDescendants(media).ToArray();
|
||||
var currentChildren = descendants.Where(x => x.ParentId == media.Id);
|
||||
AddChildXml(mediaService, dataTypeService, descendants, currentChildren, xml);
|
||||
AddChildXml(mediaService, dataTypeService, userService, descendants, currentChildren, xml);
|
||||
}
|
||||
|
||||
return xml;
|
||||
@@ -370,22 +372,23 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="mediaService"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="originalDescendants"></param>
|
||||
/// <param name="currentChildren"></param>
|
||||
/// <param name="currentXml"></param>
|
||||
private void AddChildXml(IMediaService mediaService, IDataTypeService dataTypeService, IMedia[] originalDescendants, IEnumerable<IMedia> currentChildren, XElement currentXml)
|
||||
private void AddChildXml(IMediaService mediaService, IDataTypeService dataTypeService, IUserService userService, IMedia[] originalDescendants, IEnumerable<IMedia> currentChildren, XElement currentXml)
|
||||
{
|
||||
foreach (var child in currentChildren)
|
||||
{
|
||||
//add the child's xml
|
||||
var childXml = Serialize(mediaService, dataTypeService, child);
|
||||
var childXml = Serialize(mediaService, dataTypeService, userService, child);
|
||||
currentXml.Add(childXml);
|
||||
//copy local (out of closure)
|
||||
var c = child;
|
||||
//get this item's children
|
||||
var children = originalDescendants.Where(x => x.ParentId == c.Id);
|
||||
//recurse and add it's children to the child xml element
|
||||
AddChildXml(mediaService, dataTypeService, originalDescendants, children, childXml);
|
||||
AddChildXml(mediaService, dataTypeService, userService, originalDescendants, children, childXml);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -427,22 +430,23 @@ namespace Umbraco.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="contentService"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="originalDescendants"></param>
|
||||
/// <param name="currentChildren"></param>
|
||||
/// <param name="currentXml"></param>
|
||||
private void AddChildXml(IContentService contentService, IDataTypeService dataTypeService, IContent[] originalDescendants, IEnumerable<IContent> currentChildren, XElement currentXml)
|
||||
private void AddChildXml(IContentService contentService, IDataTypeService dataTypeService, IUserService userService, IContent[] originalDescendants, IEnumerable<IContent> currentChildren, XElement currentXml)
|
||||
{
|
||||
foreach (var child in currentChildren)
|
||||
{
|
||||
//add the child's xml
|
||||
var childXml = Serialize(contentService, dataTypeService, child);
|
||||
var childXml = Serialize(contentService, dataTypeService, userService, child);
|
||||
currentXml.Add(childXml);
|
||||
//copy local (out of closure)
|
||||
var c = child;
|
||||
//get this item's children
|
||||
var children = originalDescendants.Where(x => x.ParentId == c.Id);
|
||||
//recurse and add it's children to the child xml element
|
||||
AddChildXml(contentService, dataTypeService, originalDescendants, children, childXml);
|
||||
AddChildXml(contentService, dataTypeService, userService, originalDescendants, children, childXml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
private readonly EntityXmlSerializer _entitySerializer = new EntityXmlSerializer();
|
||||
private readonly IDataTypeService _dataTypeService;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public MediaService(RepositoryFactory repositoryFactory)
|
||||
: this(new PetaPocoUnitOfWorkProvider(), repositoryFactory)
|
||||
@@ -44,13 +45,15 @@ namespace Umbraco.Core.Services
|
||||
_uowProvider = provider;
|
||||
_repositoryFactory = repositoryFactory;
|
||||
_dataTypeService = new DataTypeService(provider, repositoryFactory);
|
||||
_userService = new UserService(provider, repositoryFactory);
|
||||
}
|
||||
|
||||
public MediaService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IDataTypeService dataTypeService)
|
||||
public MediaService(IDatabaseUnitOfWorkProvider provider, RepositoryFactory repositoryFactory, IDataTypeService dataTypeService, IUserService userService)
|
||||
{
|
||||
_uowProvider = provider;
|
||||
_repositoryFactory = repositoryFactory;
|
||||
_dataTypeService = dataTypeService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -158,11 +161,11 @@ namespace Umbraco.Core.Services
|
||||
media.CreatorId = userId;
|
||||
repository.AddOrUpdate(media);
|
||||
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
// generate preview for blame history?
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.GlobalPreviewStorageEnabled)
|
||||
{
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
@@ -214,11 +217,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
media.CreatorId = userId;
|
||||
repository.AddOrUpdate(media);
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
// generate preview for blame history?
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.GlobalPreviewStorageEnabled)
|
||||
{
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
@@ -921,11 +924,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
media.CreatorId = userId;
|
||||
repository.AddOrUpdate(media);
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
// generate preview for blame history?
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.GlobalPreviewStorageEnabled)
|
||||
{
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
}
|
||||
|
||||
uow.Commit();
|
||||
@@ -960,11 +963,11 @@ namespace Umbraco.Core.Services
|
||||
{
|
||||
media.CreatorId = userId;
|
||||
repository.AddOrUpdate(media);
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
// generate preview for blame history?
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.GlobalPreviewStorageEnabled)
|
||||
{
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1015,11 +1018,11 @@ namespace Umbraco.Core.Services
|
||||
i++;
|
||||
|
||||
repository.AddOrUpdate(media);
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdateContentXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
// generate preview for blame history?
|
||||
if (UmbracoConfig.For.UmbracoSettings().Content.GlobalPreviewStorageEnabled)
|
||||
{
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, m));
|
||||
repository.AddOrUpdatePreviewXml(media, m => _entitySerializer.Serialize(this, _dataTypeService, _userService, m));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,7 +1076,7 @@ namespace Umbraco.Core.Services
|
||||
var xmlItems = new List<ContentXmlDto>();
|
||||
foreach (var c in list)
|
||||
{
|
||||
var xml = _entitySerializer.Serialize(this, _dataTypeService, c);
|
||||
var xml = _entitySerializer.Serialize(this, _dataTypeService, _userService, c);
|
||||
xmlItems.Add(new ContentXmlDto { NodeId = c.Id, Xml = xml.ToString(SaveOptions.None) });
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ namespace Umbraco.Core.Services
|
||||
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
|
||||
private Dictionary<string, IContentType> _importedContentTypes;
|
||||
private IPackageInstallation _packageInstallation;
|
||||
private readonly IUserService userService;
|
||||
|
||||
|
||||
public PackagingService(IContentService contentService,
|
||||
@@ -46,6 +47,7 @@ namespace Umbraco.Core.Services
|
||||
IDataTypeService dataTypeService,
|
||||
IFileService fileService,
|
||||
ILocalizationService localizationService,
|
||||
IUserService userService,
|
||||
RepositoryFactory repositoryFactory,
|
||||
IDatabaseUnitOfWorkProvider uowProvider)
|
||||
{
|
||||
@@ -82,7 +84,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
var exporter = new EntityXmlSerializer();
|
||||
var xml = exporter.Serialize(_contentService, _dataTypeService, content, deep);
|
||||
var xml = exporter.Serialize(_contentService, _dataTypeService, userService, content, deep);
|
||||
|
||||
if(raiseEvents)
|
||||
ExportedContent.RaiseEvent(new ExportEventArgs<IContent>(content, xml, false), this);
|
||||
@@ -1218,7 +1220,7 @@ namespace Umbraco.Core.Services
|
||||
}
|
||||
|
||||
var exporter = new EntityXmlSerializer();
|
||||
var xml = exporter.Serialize(_mediaService, _dataTypeService, media, deep);
|
||||
var xml = exporter.Serialize(_mediaService, _dataTypeService, userService, media, deep);
|
||||
|
||||
if(raiseEvents)
|
||||
ExportedMedia.RaiseEvent(new ExportEventArgs<IMedia>(media, xml, false), this);
|
||||
|
||||
@@ -132,10 +132,10 @@ namespace Umbraco.Core.Services
|
||||
_memberService = new Lazy<IMemberService>(() => new MemberService(provider, repositoryFactory.Value, _memberGroupService.Value, _dataTypeService.Value));
|
||||
|
||||
if (_contentService == null)
|
||||
_contentService = new Lazy<IContentService>(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy, _dataTypeService.Value));
|
||||
_contentService = new Lazy<IContentService>(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy, _dataTypeService.Value, _userService.Value));
|
||||
|
||||
if (_mediaService == null)
|
||||
_mediaService = new Lazy<IMediaService>(() => new MediaService(provider, repositoryFactory.Value, _dataTypeService.Value));
|
||||
_mediaService = new Lazy<IMediaService>(() => new MediaService(provider, repositoryFactory.Value, _dataTypeService.Value, _userService.Value));
|
||||
|
||||
if (_contentTypeService == null)
|
||||
_contentTypeService = new Lazy<IContentTypeService>(() => new ContentTypeService(provider, repositoryFactory.Value, _contentService.Value, _mediaService.Value));
|
||||
@@ -150,7 +150,7 @@ namespace Umbraco.Core.Services
|
||||
_localizationService = new Lazy<ILocalizationService>(() => new LocalizationService(provider, repositoryFactory.Value));
|
||||
|
||||
if (_packagingService == null)
|
||||
_packagingService = new Lazy<IPackagingService>(() => new PackagingService(_contentService.Value, _contentTypeService.Value, _mediaService.Value, _macroService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, repositoryFactory.Value, provider));
|
||||
_packagingService = new Lazy<IPackagingService>(() => new PackagingService(_contentService.Value, _contentTypeService.Value, _mediaService.Value, _macroService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, _userService.Value, repositoryFactory.Value, provider));
|
||||
|
||||
if (_entityService == null)
|
||||
_entityService = new Lazy<IEntityService>(() => new EntityService(
|
||||
|
||||
@@ -392,6 +392,7 @@
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AddMissingForeignKeyForContentType.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\AlterDataTypePreValueTable.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenOneZero\AssignMissingPrimaryForMySqlKeys.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenTwoZero\RemoveCmsDocumentAliasColumn.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\AssignMissingPrimaryForMySqlKeys.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\AssignMissingPrimaryForMySqlKeys2.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSixTwoZero\ChangePasswordColumn.cs" />
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace Umbraco.Tests
|
||||
new Mock<IDataTypeService>().Object,
|
||||
new Mock<IFileService>().Object,
|
||||
new Mock<ILocalizationService>().Object,
|
||||
new Mock<IUserService>().Object,
|
||||
new RepositoryFactory(true),
|
||||
new Mock<IDatabaseUnitOfWorkProvider>().Object),
|
||||
new Mock<IEntityService>().Object,
|
||||
@@ -87,6 +88,7 @@ namespace Umbraco.Tests
|
||||
new Mock<IDataTypeService>().Object,
|
||||
new Mock<IFileService>().Object,
|
||||
new Mock<ILocalizationService>().Object,
|
||||
new Mock<IUserService>().Object,
|
||||
new RepositoryFactory(true),
|
||||
new Mock<IDatabaseUnitOfWorkProvider>().Object),
|
||||
new Mock<IEntityService>().Object,
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Xml.XPath;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.Config;
|
||||
using Examine.LuceneEngine.Providers;
|
||||
using Lucene.Net.Analysis;
|
||||
using Lucene.Net.Analysis.Standard;
|
||||
using Moq;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Services;
|
||||
using UmbracoExamine;
|
||||
using UmbracoExamine.Config;
|
||||
@@ -29,8 +33,8 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
Umbraco.Core.Services.IContentService contentService = null,
|
||||
Umbraco.Core.Services.IMediaService mediaService = null,
|
||||
IDataTypeService dataTypeService = null,
|
||||
IContentTypeService contentTypeService = null,
|
||||
IMemberService memberService = null)
|
||||
IMemberService memberService = null,
|
||||
IUserService userService = null)
|
||||
{
|
||||
if (dataService == null)
|
||||
{
|
||||
@@ -40,18 +44,46 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
{
|
||||
contentService = Mock.Of<Umbraco.Core.Services.IContentService>();
|
||||
}
|
||||
if (userService == null)
|
||||
{
|
||||
userService = Mock.Of<IUserService>(x => x.GetProfileById(It.IsAny<int>()) == Mock.Of<IProfile>(p => p.Id == (object)0 && p.Name == "admin"));
|
||||
}
|
||||
if (mediaService == null)
|
||||
{
|
||||
mediaService = Mock.Of<Umbraco.Core.Services.IMediaService>();
|
||||
int totalRecs;
|
||||
|
||||
var allRecs = dataService.MediaService.GetLatestMediaByXpath("//node")
|
||||
.Root
|
||||
.Elements()
|
||||
.Select(x => Mock.Of<IMedia>(
|
||||
m =>
|
||||
m.Id == (int) x.Attribute("id") &&
|
||||
m.ParentId == (int) x.Attribute("parentID") &&
|
||||
m.Level == (int) x.Attribute("level") &&
|
||||
m.CreatorId == 0 &&
|
||||
m.SortOrder == (int) x.Attribute("sortOrder") &&
|
||||
m.CreateDate == (DateTime) x.Attribute("createDate") &&
|
||||
m.UpdateDate == (DateTime) x.Attribute("updateDate") &&
|
||||
m.Name == (string) x.Attribute("nodeName") &&
|
||||
m.Path == (string) x.Attribute("path") &&
|
||||
m.Properties == new PropertyCollection() &&
|
||||
m.ContentType == Mock.Of<IMediaType>(mt =>
|
||||
mt.Alias == (string) x.Attribute("nodeTypeAlias") &&
|
||||
mt.Id == (int) x.Attribute("nodeType"))))
|
||||
.ToArray();
|
||||
|
||||
|
||||
mediaService = Mock.Of<Umbraco.Core.Services.IMediaService>(
|
||||
x => x.GetPagedDescendants(
|
||||
It.IsAny<int>(), It.IsAny<int>(), It.IsAny<int>(), out totalRecs, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<string>())
|
||||
==
|
||||
allRecs);
|
||||
}
|
||||
if (dataTypeService == null)
|
||||
{
|
||||
dataTypeService = Mock.Of<IDataTypeService>();
|
||||
}
|
||||
if (contentTypeService == null)
|
||||
{
|
||||
contentTypeService = Mock.Of<IContentTypeService>();
|
||||
}
|
||||
|
||||
if (memberService == null)
|
||||
{
|
||||
memberService = Mock.Of<IMemberService>();
|
||||
@@ -71,7 +103,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
contentService,
|
||||
mediaService,
|
||||
dataTypeService,
|
||||
contentTypeService,
|
||||
userService,
|
||||
analyzer,
|
||||
false);
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ namespace UmbracoExamine
|
||||
/// </summary>
|
||||
public class UmbracoContentIndexer : BaseUmbracoIndexer
|
||||
{
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
private readonly IContentService _contentService;
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly IDataTypeService _dataTypeService;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
#region Constructors
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace UmbracoExamine
|
||||
_contentService = ApplicationContext.Current.Services.ContentService;
|
||||
_mediaService = ApplicationContext.Current.Services.MediaService;
|
||||
_dataTypeService = ApplicationContext.Current.Services.DataTypeService;
|
||||
_contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
_userService = ApplicationContext.Current.Services.UserService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,7 +69,7 @@ namespace UmbracoExamine
|
||||
_contentService = ApplicationContext.Current.Services.ContentService;
|
||||
_mediaService = ApplicationContext.Current.Services.MediaService;
|
||||
_dataTypeService = ApplicationContext.Current.Services.DataTypeService;
|
||||
_contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
_userService = ApplicationContext.Current.Services.UserService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -87,7 +87,7 @@ namespace UmbracoExamine
|
||||
_contentService = ApplicationContext.Current.Services.ContentService;
|
||||
_mediaService = ApplicationContext.Current.Services.MediaService;
|
||||
_dataTypeService = ApplicationContext.Current.Services.DataTypeService;
|
||||
_contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
|
||||
_userService = ApplicationContext.Current.Services.UserService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,21 +99,21 @@ namespace UmbracoExamine
|
||||
/// <param name="contentService"></param>
|
||||
/// <param name="mediaService"></param>
|
||||
/// <param name="dataTypeService"></param>
|
||||
/// <param name="contentTypeService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="analyzer"></param>
|
||||
/// <param name="async"></param>
|
||||
public UmbracoContentIndexer(IIndexCriteria indexerData, Lucene.Net.Store.Directory luceneDirectory, IDataService dataService,
|
||||
IContentService contentService,
|
||||
IMediaService mediaService,
|
||||
IDataTypeService dataTypeService,
|
||||
IContentTypeService contentTypeService,
|
||||
IUserService userService,
|
||||
Analyzer analyzer, bool async)
|
||||
: base(indexerData, luceneDirectory, dataService, analyzer, async)
|
||||
{
|
||||
_contentService = contentService;
|
||||
_mediaService = mediaService;
|
||||
_dataTypeService = dataTypeService;
|
||||
_contentTypeService = contentTypeService;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -180,7 +180,7 @@ namespace UmbracoExamine
|
||||
/// An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"/> on a provider after the provider has already been initialized.
|
||||
/// </exception>
|
||||
|
||||
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
|
||||
public override void Initialize(string name, NameValueCollection config)
|
||||
{
|
||||
|
||||
//check if there's a flag specifying to support unpublished content,
|
||||
@@ -255,7 +255,7 @@ namespace UmbracoExamine
|
||||
|
||||
protected override void OnNodeIndexed(IndexedNodeEventArgs e)
|
||||
{
|
||||
DataService.LogService.AddVerboseLog(e.NodeId, string.Format("Index created for node"));
|
||||
DataService.LogService.AddVerboseLog(e.NodeId, string.Format("Index created for node {0}", e.NodeId));
|
||||
base.OnNodeIndexed(e);
|
||||
}
|
||||
|
||||
@@ -420,6 +420,7 @@ namespace UmbracoExamine
|
||||
yield return serializer.Serialize(
|
||||
_mediaService,
|
||||
_dataTypeService,
|
||||
_userService,
|
||||
m);
|
||||
}
|
||||
}
|
||||
@@ -432,6 +433,7 @@ namespace UmbracoExamine
|
||||
yield return serializer.Serialize(
|
||||
_contentService,
|
||||
_dataTypeService,
|
||||
_userService,
|
||||
c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user