diff --git a/src/Umbraco.Core/Models/ContentExtensions.cs b/src/Umbraco.Core/Models/ContentExtensions.cs
index dceed0e259..20a1caf9b9 100644
--- a/src/Umbraco.Core/Models/ContentExtensions.cs
+++ b/src/Umbraco.Core/Models/ContentExtensions.cs
@@ -526,6 +526,7 @@ namespace Umbraco.Core.Models
#endregion
#region User/Profile methods
+
///
/// Gets the for the Creator of this media item.
///
@@ -534,6 +535,14 @@ namespace Umbraco.Core.Models
return ApplicationContext.Current.Services.UserService.GetProfileById(media.CreatorId);
}
+ ///
+ /// Gets the for the Creator of this media item.
+ ///
+ public static IProfile GetCreatorProfile(this IMedia media, IUserService userService)
+ {
+ return userService.GetProfileById(media.CreatorId);
+ }
+
///
/// Gets the for the Creator of this content item.
///
@@ -542,6 +551,14 @@ namespace Umbraco.Core.Models
return ApplicationContext.Current.Services.UserService.GetProfileById(content.CreatorId);
}
+ ///
+ /// Gets the for the Creator of this content item.
+ ///
+ public static IProfile GetCreatorProfile(this IContentBase content, IUserService userService)
+ {
+ return userService.GetProfileById(content.CreatorId);
+ }
+
///
/// Gets the for the Writer of this content.
///
@@ -549,6 +566,15 @@ namespace Umbraco.Core.Models
{
return ApplicationContext.Current.Services.UserService.GetProfileById(content.WriterId);
}
+
+ ///
+ /// Gets the for the Writer of this content.
+ ///
+ public static IProfile GetWriterProfile(this IContent content, IUserService userService)
+ {
+ return userService.GetProfileById(content.WriterId);
+ }
+
#endregion
///
diff --git a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs
index 58a0a47802..7b32b59564 100644
--- a/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs
+++ b/src/Umbraco.Core/Persistence/Migrations/Initial/DatabaseSchemaCreation.cs
@@ -19,11 +19,12 @@ namespace Umbraco.Core.Persistence.Migrations.Initial
private static readonly Dictionary OrderedTables = new Dictionary
{
{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)},
diff --git a/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenTwoZero/RemoveCmsDocumentAliasColumn.cs b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenTwoZero/RemoveCmsDocumentAliasColumn.cs
new file mode 100644
index 0000000000..defccb2df1
--- /dev/null
+++ b/src/Umbraco.Core/Persistence/Migrations/Upgrades/TargetVersionSevenTwoZero/RemoveCmsDocumentAliasColumn.cs
@@ -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()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Umbraco.Core/Services/ContentService.cs b/src/Umbraco.Core/Services/ContentService.cs
index 55c2d33546..bf2eff423a 100644
--- a/src/Umbraco.Core/Services/ContentService.cs
+++ b/src/Umbraco.Core/Services/ContentService.cs
@@ -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();
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();
}
diff --git a/src/Umbraco.Core/Services/EntityXmlSerializer.cs b/src/Umbraco.Core/Services/EntityXmlSerializer.cs
index c260b10418..a3adb82964 100644
--- a/src/Umbraco.Core/Services/EntityXmlSerializer.cs
+++ b/src/Umbraco.Core/Services/EntityXmlSerializer.cs
@@ -23,18 +23,19 @@ namespace Umbraco.Core.Services
///
///
///
+ ///
/// Content to export
/// Optional parameter indicating whether to include descendents
/// containing the xml representation of the Content object
- 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
///
///
///
+ ///
/// Media to export
/// Optional parameter indicating whether to include descendents
/// containing the xml representation of the Media object
- 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
///
///
///
+ ///
///
///
///
- private void AddChildXml(IMediaService mediaService, IDataTypeService dataTypeService, IMedia[] originalDescendants, IEnumerable currentChildren, XElement currentXml)
+ private void AddChildXml(IMediaService mediaService, IDataTypeService dataTypeService, IUserService userService, IMedia[] originalDescendants, IEnumerable 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
///
///
///
+ ///
///
///
///
- private void AddChildXml(IContentService contentService, IDataTypeService dataTypeService, IContent[] originalDescendants, IEnumerable currentChildren, XElement currentXml)
+ private void AddChildXml(IContentService contentService, IDataTypeService dataTypeService, IUserService userService, IContent[] originalDescendants, IEnumerable 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);
}
}
}
diff --git a/src/Umbraco.Core/Services/MediaService.cs b/src/Umbraco.Core/Services/MediaService.cs
index eb2aeedd21..9f88b2f01c 100644
--- a/src/Umbraco.Core/Services/MediaService.cs
+++ b/src/Umbraco.Core/Services/MediaService.cs
@@ -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;
}
///
@@ -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();
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) });
}
diff --git a/src/Umbraco.Core/Services/PackagingService.cs b/src/Umbraco.Core/Services/PackagingService.cs
index 47310ab1c3..a1ebd53280 100644
--- a/src/Umbraco.Core/Services/PackagingService.cs
+++ b/src/Umbraco.Core/Services/PackagingService.cs
@@ -37,6 +37,7 @@ namespace Umbraco.Core.Services
private readonly IDatabaseUnitOfWorkProvider _uowProvider;
private Dictionary _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(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(media, xml, false), this);
diff --git a/src/Umbraco.Core/Services/ServiceContext.cs b/src/Umbraco.Core/Services/ServiceContext.cs
index 5f253e65bc..8fd0740285 100644
--- a/src/Umbraco.Core/Services/ServiceContext.cs
+++ b/src/Umbraco.Core/Services/ServiceContext.cs
@@ -132,10 +132,10 @@ namespace Umbraco.Core.Services
_memberService = new Lazy(() => new MemberService(provider, repositoryFactory.Value, _memberGroupService.Value, _dataTypeService.Value));
if (_contentService == null)
- _contentService = new Lazy(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy, _dataTypeService.Value));
+ _contentService = new Lazy(() => new ContentService(provider, repositoryFactory.Value, publishingStrategy, _dataTypeService.Value, _userService.Value));
if (_mediaService == null)
- _mediaService = new Lazy(() => new MediaService(provider, repositoryFactory.Value, _dataTypeService.Value));
+ _mediaService = new Lazy(() => new MediaService(provider, repositoryFactory.Value, _dataTypeService.Value, _userService.Value));
if (_contentTypeService == null)
_contentTypeService = new Lazy(() => new ContentTypeService(provider, repositoryFactory.Value, _contentService.Value, _mediaService.Value));
@@ -150,7 +150,7 @@ namespace Umbraco.Core.Services
_localizationService = new Lazy(() => new LocalizationService(provider, repositoryFactory.Value));
if (_packagingService == null)
- _packagingService = new Lazy(() => new PackagingService(_contentService.Value, _contentTypeService.Value, _mediaService.Value, _macroService.Value, _dataTypeService.Value, _fileService.Value, _localizationService.Value, repositoryFactory.Value, provider));
+ _packagingService = new Lazy(() => 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(() => new EntityService(
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index e72d125405..db0f8196f9 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -392,6 +392,7 @@
+
diff --git a/src/Umbraco.Tests/MockTests.cs b/src/Umbraco.Tests/MockTests.cs
index f8810fe67f..30fedf2465 100644
--- a/src/Umbraco.Tests/MockTests.cs
+++ b/src/Umbraco.Tests/MockTests.cs
@@ -42,6 +42,7 @@ namespace Umbraco.Tests
new Mock().Object,
new Mock().Object,
new Mock().Object,
+ new Mock().Object,
new RepositoryFactory(true),
new Mock().Object),
new Mock().Object,
@@ -87,6 +88,7 @@ namespace Umbraco.Tests
new Mock().Object,
new Mock().Object,
new Mock().Object,
+ new Mock().Object,
new RepositoryFactory(true),
new Mock().Object),
new Mock().Object,
diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs
index e4995ff4e5..6c81bdb3fc 100644
--- a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs
+++ b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs
@@ -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();
}
+ if (userService == null)
+ {
+ userService = Mock.Of(x => x.GetProfileById(It.IsAny()) == Mock.Of(p => p.Id == (object)0 && p.Name == "admin"));
+ }
if (mediaService == null)
{
- mediaService = Mock.Of();
+ int totalRecs;
+
+ var allRecs = dataService.MediaService.GetLatestMediaByXpath("//node")
+ .Root
+ .Elements()
+ .Select(x => Mock.Of(
+ 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(mt =>
+ mt.Alias == (string) x.Attribute("nodeTypeAlias") &&
+ mt.Id == (int) x.Attribute("nodeType"))))
+ .ToArray();
+
+
+ mediaService = Mock.Of(
+ x => x.GetPagedDescendants(
+ It.IsAny(), It.IsAny(), It.IsAny(), out totalRecs, It.IsAny(), It.IsAny(), It.IsAny())
+ ==
+ allRecs);
}
if (dataTypeService == null)
{
dataTypeService = Mock.Of();
}
- if (contentTypeService == null)
- {
- contentTypeService = Mock.Of();
- }
+
if (memberService == null)
{
memberService = Mock.Of();
@@ -71,7 +103,7 @@ namespace Umbraco.Tests.UmbracoExamine
contentService,
mediaService,
dataTypeService,
- contentTypeService,
+ userService,
analyzer,
false);
diff --git a/src/UmbracoExamine/UmbracoContentIndexer.cs b/src/UmbracoExamine/UmbracoContentIndexer.cs
index ab54116e6e..43d53325e5 100644
--- a/src/UmbracoExamine/UmbracoContentIndexer.cs
+++ b/src/UmbracoExamine/UmbracoContentIndexer.cs
@@ -35,10 +35,10 @@ namespace UmbracoExamine
///
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;
}
///
@@ -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;
}
///
@@ -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;
}
///
@@ -99,21 +99,21 @@ namespace UmbracoExamine
///
///
///
- ///
+ ///
///
///
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 on a provider after the provider has already been initialized.
///
- 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);
}
}