WIP - new IEntityXmlSerializer, IPackageCreation, PackageActionRunner, large refactor of entity serialization, no more IPackagingService.Export methods, ports legacy package creation code to new IPackageCreation, more more ExportEventArgs (makes no sense)
This commit is contained in:
@@ -17,6 +17,7 @@ using Umbraco.Core.Xml;
|
||||
using Umbraco.Examine;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Services.Implement;
|
||||
using Umbraco.Web.Composing;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
@@ -37,14 +38,14 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
// method GetExamineManagerSafe().
|
||||
//
|
||||
private readonly ISearcher _searchProvider;
|
||||
private readonly IIndex _indexProvider;
|
||||
private readonly XmlStore _xmlStore;
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
private readonly IEntityXmlSerializer _entitySerializer;
|
||||
|
||||
// must be specified by the ctor
|
||||
private readonly ICacheProvider _cacheProvider;
|
||||
|
||||
public PublishedMediaCache(XmlStore xmlStore, IMediaService mediaService, IUserService userService, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
public PublishedMediaCache(XmlStore xmlStore, IMediaService mediaService, IUserService userService, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache, IEntityXmlSerializer entitySerializer)
|
||||
: base(false)
|
||||
{
|
||||
_mediaService = mediaService ?? throw new ArgumentNullException(nameof(mediaService));
|
||||
@@ -53,6 +54,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_cacheProvider = cacheProvider;
|
||||
_xmlStore = xmlStore;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
_entitySerializer = entitySerializer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -61,18 +63,18 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
/// <param name="mediaService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <param name="searchProvider"></param>
|
||||
/// <param name="indexProvider"></param>
|
||||
/// <param name="cacheProvider"></param>
|
||||
/// <param name="contentTypeCache"></param>
|
||||
internal PublishedMediaCache(IMediaService mediaService, IUserService userService, ISearcher searchProvider, BaseIndexProvider indexProvider, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
/// <param name="entitySerializer"></param>
|
||||
internal PublishedMediaCache(IMediaService mediaService, IUserService userService, ISearcher searchProvider, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache, IEntityXmlSerializer entitySerializer)
|
||||
: base(false)
|
||||
{
|
||||
_mediaService = mediaService ?? throw new ArgumentNullException(nameof(mediaService));
|
||||
_userService = userService ?? throw new ArgumentNullException(nameof(userService));
|
||||
_searchProvider = searchProvider ?? throw new ArgumentNullException(nameof(searchProvider));
|
||||
_indexProvider = indexProvider ?? throw new ArgumentNullException(nameof(indexProvider));
|
||||
_cacheProvider = cacheProvider;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
_entitySerializer = entitySerializer;
|
||||
}
|
||||
|
||||
static PublishedMediaCache()
|
||||
@@ -555,14 +557,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
return Enumerable.Empty<IPublishedContent>();
|
||||
}
|
||||
|
||||
var serialized = EntityXmlSerializer.Serialize(
|
||||
Current.Services.MediaService,
|
||||
Current.Services.DataTypeService,
|
||||
Current.Services.UserService,
|
||||
Current.Services.LocalizationService,
|
||||
Current.UrlSegmentProviders,
|
||||
media,
|
||||
true);
|
||||
var serialized = _entitySerializer.Serialize(media, true);
|
||||
|
||||
var mediaIterator = serialized.CreateNavigator().Select("/");
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IDefaultCultureAccessor _defaultCultureAccessor;
|
||||
private readonly ISiteDomainHelper _siteDomainHelper;
|
||||
private readonly IEntityXmlSerializer _entitySerializer;
|
||||
|
||||
#region Constructors
|
||||
|
||||
@@ -42,20 +43,20 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
IPublishedContentTypeFactory publishedContentTypeFactory,
|
||||
IScopeProvider scopeProvider,
|
||||
ICacheProvider requestCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
IEntityXmlSerializer entitySerializer,
|
||||
MainDom mainDom,
|
||||
bool testing = false, bool enableRepositoryEvents = true)
|
||||
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache, segmentProviders,
|
||||
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache,
|
||||
publishedSnapshotAccessor, variationContextAccessor,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
defaultCultureAccessor,
|
||||
logger, globalSettings, siteDomainHelper, null, mainDom, testing, enableRepositoryEvents)
|
||||
logger, globalSettings, siteDomainHelper, entitySerializer, null, mainDom, testing, enableRepositoryEvents)
|
||||
{ }
|
||||
|
||||
// used in some tests
|
||||
@@ -69,27 +70,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents)
|
||||
: this(serviceContext, publishedContentTypeFactory, scopeProvider, requestCache, Enumerable.Empty<IUrlSegmentProvider>(),
|
||||
publishedSnapshotAccessor, variationContextAccessor,
|
||||
documentRepository, mediaRepository, memberRepository,
|
||||
defaultCultureAccessor,
|
||||
logger, globalSettings, siteDomainHelper, contentTypeCache, mainDom, testing, enableRepositoryEvents)
|
||||
{ }
|
||||
|
||||
private PublishedSnapshotService(ServiceContext serviceContext,
|
||||
IPublishedContentTypeFactory publishedContentTypeFactory,
|
||||
IScopeProvider scopeProvider,
|
||||
ICacheProvider requestCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor,
|
||||
IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository,
|
||||
IDefaultCultureAccessor defaultCultureAccessor,
|
||||
ILogger logger,
|
||||
IGlobalSettings globalSettings,
|
||||
ISiteDomainHelper siteDomainHelper,
|
||||
IEntityXmlSerializer entitySerializer,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents)
|
||||
@@ -100,9 +81,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_contentTypeCache = contentTypeCache
|
||||
?? new PublishedContentTypeCache(serviceContext.ContentTypeService, serviceContext.MediaTypeService, serviceContext.MemberTypeService, publishedContentTypeFactory, logger);
|
||||
|
||||
_xmlStore = new XmlStore(serviceContext, scopeProvider, _routesCache,
|
||||
_contentTypeCache, segmentProviders, publishedSnapshotAccessor, mainDom, testing, enableRepositoryEvents,
|
||||
documentRepository, mediaRepository, memberRepository, globalSettings);
|
||||
_xmlStore = new XmlStore(serviceContext.ContentTypeService, serviceContext.ContentService, scopeProvider, _routesCache,
|
||||
_contentTypeCache, publishedSnapshotAccessor, mainDom, testing, enableRepositoryEvents,
|
||||
documentRepository, mediaRepository, memberRepository, globalSettings, entitySerializer);
|
||||
|
||||
_domainService = serviceContext.DomainService;
|
||||
_memberService = serviceContext.MemberService;
|
||||
@@ -113,6 +94,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_requestCache = requestCache;
|
||||
_globalSettings = globalSettings;
|
||||
_siteDomainHelper = siteDomainHelper;
|
||||
_entitySerializer = entitySerializer;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
@@ -157,7 +139,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
return new PublishedSnapshot(
|
||||
new PublishedContentCache(_xmlStore, domainCache, _requestCache, _globalSettings, _siteDomainHelper, _contentTypeCache, _routesCache, previewToken),
|
||||
new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache),
|
||||
new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache, _entitySerializer),
|
||||
new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache),
|
||||
domainCache);
|
||||
}
|
||||
|
||||
@@ -44,15 +44,16 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
private readonly IMediaRepository _mediaRepository;
|
||||
private readonly IMemberRepository _memberRepository;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly IEntityXmlSerializer _entitySerializer;
|
||||
private XmlStoreFilePersister _persisterTask;
|
||||
private volatile bool _released;
|
||||
private bool _withRepositoryEvents;
|
||||
|
||||
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
private readonly IEnumerable<IUrlSegmentProvider> _segmentProviders;
|
||||
private readonly RoutesCache _routesCache;
|
||||
private readonly ServiceContext _serviceContext; // fixme WHY
|
||||
private readonly IContentTypeService _contentTypeService;
|
||||
private readonly IContentService _contentService;
|
||||
private readonly IScopeProvider _scopeProvider;
|
||||
|
||||
#region Constructors
|
||||
@@ -61,22 +62,23 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
/// Initializes a new instance of the <see cref="XmlStore"/> class.
|
||||
/// </summary>
|
||||
/// <remarks>The default constructor will boot the cache, load data from file or database, /// wire events in order to manage changes, etc.</remarks>
|
||||
public XmlStore(ServiceContext serviceContext, IScopeProvider scopeProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders, IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings)
|
||||
: this(serviceContext, scopeProvider, routesCache, contentTypeCache, segmentProviders, publishedSnapshotAccessor, mainDom, false, false, documentRepository, mediaRepository, memberRepository, globalSettings)
|
||||
public XmlStore(IContentTypeService contentTypeService, IContentService contentService, IScopeProvider scopeProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings, IEntityXmlSerializer entitySerializer)
|
||||
: this(contentTypeService, contentService, scopeProvider, routesCache, contentTypeCache, publishedSnapshotAccessor, mainDom, false, false, documentRepository, mediaRepository, memberRepository, globalSettings, entitySerializer)
|
||||
{ }
|
||||
|
||||
// internal for unit tests
|
||||
// no file nor db, no config check
|
||||
// fixme - er, we DO have a DB?
|
||||
internal XmlStore(ServiceContext serviceContext, IScopeProvider scopeProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders, IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings)
|
||||
internal XmlStore(IContentTypeService contentTypeService, IContentService contentService, IScopeProvider scopeProvider, RoutesCache routesCache, PublishedContentTypeCache contentTypeCache,
|
||||
IPublishedSnapshotAccessor publishedSnapshotAccessor, MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents, IDocumentRepository documentRepository, IMediaRepository mediaRepository, IMemberRepository memberRepository, IGlobalSettings globalSettings, IEntityXmlSerializer entitySerializer)
|
||||
{
|
||||
if (testing == false)
|
||||
EnsureConfigurationIsValid();
|
||||
|
||||
_serviceContext = serviceContext;
|
||||
_contentTypeService = contentTypeService;
|
||||
_contentService = contentService;
|
||||
_scopeProvider = scopeProvider;
|
||||
_routesCache = routesCache;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
@@ -85,8 +87,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_mediaRepository = mediaRepository;
|
||||
_memberRepository = memberRepository;
|
||||
_globalSettings = globalSettings;
|
||||
_entitySerializer = entitySerializer;
|
||||
_xmlFileName = IOHelper.MapPath(SystemFiles.GetContentCacheXml(_globalSettings));
|
||||
_segmentProviders = segmentProviders;
|
||||
|
||||
if (testing)
|
||||
{
|
||||
@@ -399,7 +401,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
try
|
||||
{
|
||||
var dtdInner = new StringBuilder();
|
||||
var contentTypes = _serviceContext.ContentTypeService.GetAll();
|
||||
var contentTypes = _contentTypeService.GetAll();
|
||||
// though aliases should be safe and non null already?
|
||||
var aliases = contentTypes.Select(x => x.Alias.ToSafeAlias()).WhereNotNull();
|
||||
foreach (var alias in aliases)
|
||||
@@ -556,7 +558,7 @@ AND (umbracoNode.id=@id)";
|
||||
|
||||
public XmlDocument GetPreviewXml(int contentId, bool includeSubs)
|
||||
{
|
||||
var content = _serviceContext.ContentService.GetById(contentId);
|
||||
var content = _contentService.GetById(contentId);
|
||||
|
||||
var doc = (XmlDocument)Xml.Clone();
|
||||
if (content == null) return doc;
|
||||
@@ -1065,7 +1067,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
|
||||
continue;
|
||||
}
|
||||
|
||||
var content = _serviceContext.ContentService.GetById(payload.Id);
|
||||
var content = _contentService.GetById(payload.Id);
|
||||
var current = safeXml.Xml.GetElementById(payload.Id.ToInvariantString());
|
||||
|
||||
if (content == null || content.Published == false || content.Trashed)
|
||||
@@ -1536,7 +1538,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
|
||||
var entity = args.Entity;
|
||||
|
||||
// serialize edit values for preview
|
||||
var editXml = EntityXmlSerializer.Serialize(_serviceContext.ContentService, _serviceContext.DataTypeService, _serviceContext.UserService, _serviceContext.LocalizationService, _segmentProviders, entity, false).ToDataString();
|
||||
var editXml = _entitySerializer.Serialize(entity, false).ToDataString();
|
||||
|
||||
// change below to write only one row - not one per version
|
||||
var dto1 = new PreviewXmlDto
|
||||
@@ -1565,7 +1567,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
|
||||
return;
|
||||
|
||||
// serialize published values for content cache
|
||||
var publishedXml = EntityXmlSerializer.Serialize(_serviceContext.ContentService, _serviceContext.DataTypeService, _serviceContext.UserService, _serviceContext.LocalizationService, _segmentProviders, entity, true).ToDataString();
|
||||
var publishedXml = _entitySerializer.Serialize(entity, true).ToDataString();
|
||||
var dto2 = new ContentXmlDto { NodeId = entity.Id, Xml = publishedXml };
|
||||
OnRepositoryRefreshed(db, dto2);
|
||||
|
||||
@@ -1581,7 +1583,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
|
||||
if (entity.Trashed)
|
||||
db.Execute("DELETE FROM cmsContentXml WHERE nodeId=@id", new { id = entity.Id });
|
||||
|
||||
var xml = EntityXmlSerializer.Serialize(_serviceContext.MediaService, _serviceContext.DataTypeService, _serviceContext.UserService, _serviceContext.LocalizationService, _segmentProviders, entity).ToDataString();
|
||||
var xml = _entitySerializer.Serialize(entity).ToDataString();
|
||||
|
||||
var dto1 = new ContentXmlDto { NodeId = entity.Id, Xml = xml };
|
||||
OnRepositoryRefreshed(db, dto1);
|
||||
@@ -1592,7 +1594,7 @@ ORDER BY umbracoNode.level, umbracoNode.sortOrder";
|
||||
var db = args.Scope.Database;
|
||||
var entity = args.Entity;
|
||||
|
||||
var xml = EntityXmlSerializer.Serialize(_serviceContext.DataTypeService, _serviceContext.LocalizationService, entity).ToDataString();
|
||||
var xml = _entitySerializer.Serialize(entity).ToDataString();
|
||||
|
||||
var dto1 = new ContentXmlDto { NodeId = entity.Id, Xml = xml };
|
||||
OnRepositoryRefreshed(db, dto1);
|
||||
@@ -1749,7 +1751,7 @@ WHERE cmsContentXml.nodeId IN (
|
||||
var descendants = _documentRepository.GetPage(query, pageIndex++, groupSize, out total, null, Ordering.By("Path"));
|
||||
const bool published = true; // contentXml contains published content!
|
||||
var items = descendants.Select(c => new ContentXmlDto { NodeId = c.Id, Xml =
|
||||
EntityXmlSerializer.Serialize(_serviceContext.ContentService, _serviceContext.DataTypeService, _serviceContext.UserService, _serviceContext.LocalizationService, _segmentProviders, c, published).ToDataString() }).ToArray();
|
||||
_entitySerializer.Serialize(c, published).ToDataString() }).ToArray();
|
||||
db.BulkInsertRecords(items);
|
||||
processed += items.Length;
|
||||
} while (processed < total);
|
||||
@@ -1824,7 +1826,7 @@ WHERE cmsPreviewXml.nodeId IN (
|
||||
var items = descendants.Select(c => new PreviewXmlDto
|
||||
{
|
||||
NodeId = c.Id,
|
||||
Xml = EntityXmlSerializer.Serialize(_serviceContext.ContentService, _serviceContext.DataTypeService, _serviceContext.UserService, _serviceContext.LocalizationService, _segmentProviders, c, published).ToDataString()
|
||||
Xml = _entitySerializer.Serialize(c, published).ToDataString()
|
||||
}).ToArray();
|
||||
db.BulkInsertRecords(items);
|
||||
processed += items.Length;
|
||||
@@ -1894,7 +1896,7 @@ WHERE cmsContentXml.nodeId IN (
|
||||
{
|
||||
var descendants = _mediaRepository.GetPage(query, pageIndex++, groupSize, out total, null, Ordering.By("Path"));
|
||||
var items = descendants.Select(m => new ContentXmlDto { NodeId = m.Id, Xml =
|
||||
EntityXmlSerializer.Serialize(_serviceContext.MediaService, _serviceContext.DataTypeService, _serviceContext.UserService, _serviceContext.LocalizationService, _segmentProviders, m).ToDataString() }).ToArray();
|
||||
_entitySerializer.Serialize(m).ToDataString() }).ToArray();
|
||||
db.BulkInsertRecords(items);
|
||||
processed += items.Length;
|
||||
} while (processed < total);
|
||||
@@ -1962,7 +1964,7 @@ WHERE cmsContentXml.nodeId IN (
|
||||
do
|
||||
{
|
||||
var descendants = _memberRepository.GetPage(query, pageIndex++, groupSize, out total, null, Ordering.By("Path"));
|
||||
var items = descendants.Select(m => new ContentXmlDto { NodeId = m.Id, Xml = EntityXmlSerializer.Serialize(_serviceContext.DataTypeService, _serviceContext.LocalizationService, m).ToDataString() }).ToArray();
|
||||
var items = descendants.Select(m => new ContentXmlDto { NodeId = m.Id, Xml = _entitySerializer.Serialize(m).ToDataString() }).ToArray();
|
||||
db.BulkInsertRecords(items);
|
||||
processed += items.Length;
|
||||
} while (processed < total);
|
||||
|
||||
Reference in New Issue
Block a user