Normalize cr/lf/tab
This commit is contained in:
@@ -17,20 +17,20 @@ namespace Umbraco.Web.PublishedCache
|
||||
/* Various places (such as Node) want to access the XML content, today as an XmlDocument
|
||||
* but to migrate to a new cache, they're migrating to an XPathNavigator. Still, they need
|
||||
* to find out how to get that navigator.
|
||||
*
|
||||
*
|
||||
* Because a cache such as the DrippingCache is contextual ie it has a "snapshot" nothing
|
||||
* and remains consistent over the snapshot, the navigator should come from the "current"
|
||||
* snapshot.
|
||||
*
|
||||
*
|
||||
* The service creates those snapshots in IPublishedCaches objects.
|
||||
*
|
||||
*
|
||||
* Places such as Node need to be able to find the "current" one so the factory has a
|
||||
* notion of what is "current". In most cases, the IPublishedCaches object is created
|
||||
* and registered against an UmbracoContext, and that context is then used as "current".
|
||||
*
|
||||
*
|
||||
* But for tests we need to have a way to specify what's the "current" object & preview.
|
||||
* Which is defined in PublishedCachesServiceBase.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
@@ -60,10 +60,10 @@ namespace Umbraco.Web.PublishedCache
|
||||
* the content only, or the content's branch, or the whole tree + it could be possible
|
||||
* to register filters against the factory to filter out which nodes should be preview
|
||||
* vs non preview.
|
||||
*
|
||||
*
|
||||
* EnterPreview() returns the previewToken. It is up to callers to store that token
|
||||
* wherever they want, most probably in a cookie.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
* and the order-of-execution of the handlers cannot be guaranteed, which means that some
|
||||
* user code may run before Umbraco is finished updating itself. Instead, the cache refreshers
|
||||
* explicitely notify the service of changes.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
@@ -164,7 +164,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
/// <param name="sourceValue">The source value.</param>
|
||||
/// <returns>A fragment property.</returns>
|
||||
IPublishedProperty CreateFragmentProperty(PublishedPropertyType propertyType, Guid itemKey, bool previewing, PropertyCacheLevel referenceCacheLevel, object sourceValue = null);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
Node = this,
|
||||
ContentTypeId = ContentType.Id,
|
||||
|
||||
|
||||
DraftData = ((PublishedContent) Draft)?._contentData,
|
||||
PublishedData = ((PublishedContent) Published)?._contentData
|
||||
};
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
{
|
||||
EnsureProvider();
|
||||
var member = _memberService.GetById(memberId);
|
||||
return member == null
|
||||
? null
|
||||
return member == null
|
||||
? null
|
||||
: PublishedMember.Create(member, GetContentType(member.ContentTypeId), _previewDefault, _facadeAccessor);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.Navigable
|
||||
|
||||
// called by the conditional weak table -- must be public
|
||||
// ReSharper disable EmptyConstructor
|
||||
public NavigableContentType()
|
||||
public NavigableContentType()
|
||||
// ReSharper restore EmptyConstructor
|
||||
{ }
|
||||
|
||||
@@ -34,16 +34,16 @@ namespace Umbraco.Web.PublishedCache.NuCache.Navigable
|
||||
{
|
||||
BuiltinProperties = new INavigableFieldType[]
|
||||
{
|
||||
new NavigablePropertyType("nodeName"),
|
||||
new NavigablePropertyType("parentId"),
|
||||
new NavigablePropertyType("nodeName"),
|
||||
new NavigablePropertyType("parentId"),
|
||||
new NavigablePropertyType("createDate", v => XmlConvert.ToString((DateTime)v, "yyyy-MM-ddTHH:mm:ss")),
|
||||
new NavigablePropertyType("updateDate", v => XmlConvert.ToString((DateTime)v, "yyyy-MM-ddTHH:mm:ss")),
|
||||
new NavigablePropertyType("isDoc", v => XmlConvert.ToString((bool)v)),
|
||||
new NavigablePropertyType("sortOrder"),
|
||||
new NavigablePropertyType("level"),
|
||||
new NavigablePropertyType("templateId"),
|
||||
new NavigablePropertyType("writerId"),
|
||||
new NavigablePropertyType("creatorId"),
|
||||
new NavigablePropertyType("updateDate", v => XmlConvert.ToString((DateTime)v, "yyyy-MM-ddTHH:mm:ss")),
|
||||
new NavigablePropertyType("isDoc", v => XmlConvert.ToString((bool)v)),
|
||||
new NavigablePropertyType("sortOrder"),
|
||||
new NavigablePropertyType("level"),
|
||||
new NavigablePropertyType("templateId"),
|
||||
new NavigablePropertyType("writerId"),
|
||||
new NavigablePropertyType("creatorId"),
|
||||
new NavigablePropertyType("urlName"),
|
||||
new NavigablePropertyType("isDraft", v => XmlConvert.ToString((bool)v))
|
||||
};
|
||||
|
||||
@@ -162,4 +162,4 @@ namespace Umbraco.Web.PublishedCache
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
|
||||
@@ -46,4 +46,4 @@ namespace Umbraco.Web.PublishedCache
|
||||
_xpathValue = new Lazy<object>(() => PropertyType.ConvertInterToXPath(PropertyCacheLevel.Unknown, _sourceValue.Value, _isPreviewing));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ namespace Umbraco.Web.PublishedCache
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
// used in WebBootManager + tests
|
||||
public FacadeService(ServiceContext serviceContext,
|
||||
IScopeProvider scopeProvider,
|
||||
IScopeUnitOfWorkProvider uowProvider,
|
||||
ICacheProvider requestCache,
|
||||
IScopeUnitOfWorkProvider uowProvider,
|
||||
ICacheProvider requestCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders,
|
||||
IFacadeAccessor facadeAccessor,
|
||||
ILogger logger,
|
||||
@@ -49,11 +49,11 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
// used in some tests
|
||||
internal FacadeService(ServiceContext serviceContext,
|
||||
IScopeProvider scopeProvider,
|
||||
IScopeUnitOfWorkProvider uowProvider,
|
||||
IScopeUnitOfWorkProvider uowProvider,
|
||||
ICacheProvider requestCache,
|
||||
IFacadeAccessor facadeAccessor,
|
||||
ILogger logger,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents)
|
||||
: this(serviceContext, scopeProvider, uowProvider, requestCache, Enumerable.Empty<IUrlSegmentProvider>(), facadeAccessor, logger, contentTypeCache, mainDom, testing, enableRepositoryEvents)
|
||||
@@ -61,12 +61,12 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
private FacadeService(ServiceContext serviceContext,
|
||||
IScopeProvider scopeProvider,
|
||||
IScopeUnitOfWorkProvider uowProvider,
|
||||
IScopeUnitOfWorkProvider uowProvider,
|
||||
ICacheProvider requestCache,
|
||||
IEnumerable<IUrlSegmentProvider> segmentProviders,
|
||||
IFacadeAccessor facadeAccessor,
|
||||
ILogger logger,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
PublishedContentTypeCache contentTypeCache,
|
||||
MainDom mainDom,
|
||||
bool testing, bool enableRepositoryEvents)
|
||||
: base(facadeAccessor)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
@@ -310,9 +310,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
#region Converters
|
||||
|
||||
private IPublishedContent ConvertToDocument(XmlNode xmlNode, bool isPreviewing)
|
||||
{
|
||||
{
|
||||
return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, _cacheProvider, _contentTypeCache);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<IPublishedContent> ConvertToDocuments(XmlNodeList xmlNodes, bool isPreviewing)
|
||||
{
|
||||
@@ -325,9 +325,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
#region Getters
|
||||
|
||||
public override IPublishedContent GetById(bool preview, int nodeId)
|
||||
{
|
||||
return ConvertToDocument(GetXml(preview).GetElementById(nodeId.ToString(CultureInfo.InvariantCulture)), preview);
|
||||
}
|
||||
{
|
||||
return ConvertToDocument(GetXml(preview).GetElementById(nodeId.ToString(CultureInfo.InvariantCulture)), preview);
|
||||
}
|
||||
|
||||
public override IPublishedContent GetById(bool preview, Guid nodeId)
|
||||
{
|
||||
@@ -380,7 +380,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
public override IEnumerable<IPublishedContent> GetAtRoot(bool preview)
|
||||
{
|
||||
return ConvertToDocuments(GetXml(preview).SelectNodes(XPathStrings.RootDocuments), preview);
|
||||
}
|
||||
}
|
||||
|
||||
public override IPublishedContent GetSingleByXPath(bool preview, string xpath, XPathVariable[] vars)
|
||||
{
|
||||
@@ -430,9 +430,9 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public override bool HasContent(bool preview)
|
||||
{
|
||||
var xml = GetXml(preview);
|
||||
var xml = GetXml(preview);
|
||||
var node = xml?.SelectSingleNode(XPathStrings.RootDocuments);
|
||||
return node != null;
|
||||
return node != null;
|
||||
}
|
||||
|
||||
public override XPathNavigator CreateNavigator(bool preview)
|
||||
@@ -539,4 +539,4 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Configuration;
|
||||
@@ -34,55 +34,55 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
internal class PublishedMediaCache : PublishedCacheBase, IPublishedMediaCache
|
||||
{
|
||||
private readonly IMediaService _mediaService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
// by default these are null unless specified by the ctor dedicated to tests
|
||||
// when they are null the cache derives them from the ExamineManager, see
|
||||
// method GetExamineManagerSafe().
|
||||
//
|
||||
private readonly ILuceneSearcher _searchProvider;
|
||||
private readonly ILuceneSearcher _searchProvider;
|
||||
private readonly BaseIndexProvider _indexProvider;
|
||||
private readonly XmlStore _xmlStore;
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
|
||||
// must be specified by the ctor
|
||||
private readonly ICacheProvider _cacheProvider;
|
||||
private readonly ICacheProvider _cacheProvider;
|
||||
|
||||
public PublishedMediaCache(XmlStore xmlStore, IMediaService mediaService, IUserService userService, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
: base(false)
|
||||
{
|
||||
public PublishedMediaCache(XmlStore xmlStore, IMediaService mediaService, IUserService userService, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
: base(false)
|
||||
{
|
||||
if (mediaService == null) throw new ArgumentNullException(nameof(mediaService));
|
||||
if (userService == null) throw new ArgumentNullException(nameof(userService));
|
||||
_mediaService = mediaService;
|
||||
_userService = userService;
|
||||
|
||||
_cacheProvider = cacheProvider;
|
||||
_xmlStore = xmlStore;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
}
|
||||
_xmlStore = xmlStore;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generally used for unit testing to use an explicit examine searcher
|
||||
/// </summary>
|
||||
/// <param name="mediaService"></param>
|
||||
/// <param name="userService"></param>
|
||||
/// <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, ILuceneSearcher searchProvider, BaseIndexProvider indexProvider, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
/// <param name="cacheProvider"></param>
|
||||
/// <param name="contentTypeCache"></param>
|
||||
internal PublishedMediaCache(IMediaService mediaService, IUserService userService, ILuceneSearcher searchProvider, BaseIndexProvider indexProvider, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
: base(false)
|
||||
{
|
||||
if (mediaService == null) throw new ArgumentNullException(nameof(mediaService));
|
||||
if (userService == null) throw new ArgumentNullException(nameof(userService));
|
||||
if (searchProvider == null) throw new ArgumentNullException(nameof(searchProvider));
|
||||
if (indexProvider == null) throw new ArgumentNullException(nameof(indexProvider));
|
||||
if (indexProvider == null) throw new ArgumentNullException(nameof(indexProvider));
|
||||
|
||||
_mediaService = mediaService;
|
||||
_userService = userService;
|
||||
_searchProvider = searchProvider;
|
||||
_indexProvider = indexProvider;
|
||||
_cacheProvider = cacheProvider;
|
||||
_cacheProvider = cacheProvider;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
}
|
||||
|
||||
@@ -102,15 +102,15 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
}
|
||||
|
||||
public override bool HasById(bool preview, int contentId)
|
||||
{
|
||||
{
|
||||
return GetUmbracoMedia(contentId) != null;
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetAtRoot(bool preview)
|
||||
public override IEnumerable<IPublishedContent> GetAtRoot(bool preview)
|
||||
{
|
||||
//TODO: We should be able to look these ids first in Examine!
|
||||
|
||||
var rootMedia = _mediaService.GetRootMedia();
|
||||
var rootMedia = _mediaService.GetRootMedia();
|
||||
return rootMedia.Select(m => GetUmbracoMedia(m.Id));
|
||||
}
|
||||
|
||||
@@ -210,49 +210,49 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
return _indexProvider;
|
||||
|
||||
var eMgr = GetExamineManagerSafe();
|
||||
if (eMgr == null) return null;
|
||||
if (eMgr == null) return null;
|
||||
|
||||
try
|
||||
{
|
||||
//by default use the InternalSearcher
|
||||
try
|
||||
{
|
||||
//by default use the InternalSearcher
|
||||
var indexer = eMgr.IndexProviderCollection[Constants.Examine.InternalIndexer];
|
||||
if (indexer.IndexerData.IncludeNodeTypes.Any() || indexer.IndexerData.ExcludeNodeTypes.Any())
|
||||
{
|
||||
Current.Logger.Warn<PublishedMediaCache>("The InternalIndexer for examine is configured incorrectly, it should not list any include/exclude node types or field names, it should simply be configured as: " + "<IndexSet SetName=\"InternalIndexSet\" IndexPath=\"~/App_Data/TEMP/ExamineIndexes/Internal/\" />");
|
||||
}
|
||||
return indexer;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Current.Logger.Error<PublishedMediaCache>("Could not retrieve the InternalIndexer", ex);
|
||||
//something didn't work, continue returning null.
|
||||
}
|
||||
return null;
|
||||
if (indexer.IndexerData.IncludeNodeTypes.Any() || indexer.IndexerData.ExcludeNodeTypes.Any())
|
||||
{
|
||||
Current.Logger.Warn<PublishedMediaCache>("The InternalIndexer for examine is configured incorrectly, it should not list any include/exclude node types or field names, it should simply be configured as: " + "<IndexSet SetName=\"InternalIndexSet\" IndexPath=\"~/App_Data/TEMP/ExamineIndexes/Internal/\" />");
|
||||
}
|
||||
return indexer;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Current.Logger.Error<PublishedMediaCache>("Could not retrieve the InternalIndexer", ex);
|
||||
//something didn't work, continue returning null.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private ILuceneSearcher GetSearchProviderSafe()
|
||||
private ILuceneSearcher GetSearchProviderSafe()
|
||||
{
|
||||
if (_searchProvider != null)
|
||||
return _searchProvider;
|
||||
|
||||
var eMgr = GetExamineManagerSafe();
|
||||
if (eMgr == null) return null;
|
||||
if (eMgr == null) return null;
|
||||
|
||||
try
|
||||
{
|
||||
//by default use the InternalSearcher
|
||||
return eMgr.GetSearcher(Constants.Examine.InternalIndexer);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
//Currently examine is throwing FileNotFound exceptions when we have a loadbalanced filestore and a node is published in umbraco
|
||||
//See this thread: http://examine.cdodeplex.com/discussions/264341
|
||||
//Catch the exception here for the time being, and just fallback to GetMedia
|
||||
//TODO: Need to fix examine in LB scenarios!
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
//This will occur when the search provider cannot be initialized. In newer examine versions the initialization is lazy and therefore
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
//Currently examine is throwing FileNotFound exceptions when we have a loadbalanced filestore and a node is published in umbraco
|
||||
//See this thread: http://examine.cdodeplex.com/discussions/264341
|
||||
//Catch the exception here for the time being, and just fallback to GetMedia
|
||||
//TODO: Need to fix examine in LB scenarios!
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
//This will occur when the search provider cannot be initialized. In newer examine versions the initialization is lazy and therefore
|
||||
// the manager will return the singleton without throwing initialization errors, however if examine isn't configured correctly a null
|
||||
// reference error will occur because the examine settings are null.
|
||||
}
|
||||
@@ -335,7 +335,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
() => ExamineIndexMissMax);
|
||||
|
||||
return ConvertFromIMedia(media);
|
||||
}
|
||||
}
|
||||
|
||||
private const int ExamineIndexMissMax = 10;
|
||||
private int _examineIndexMiss;
|
||||
@@ -359,7 +359,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
internal CacheValues ConvertFromSearchResult(SearchResult searchResult)
|
||||
{
|
||||
// note: fixing fields in 7.x, removed by Shan for 8.0
|
||||
var values = new Dictionary<string, string>(searchResult.Fields);
|
||||
var values = new Dictionary<string, string>(searchResult.Fields);
|
||||
|
||||
return new CacheValues
|
||||
{
|
||||
@@ -370,7 +370,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
internal CacheValues ConvertFromXPathNavigator(XPathNavigator xpath, bool forceNav = false)
|
||||
{
|
||||
if (xpath == null) throw new ArgumentNullException(nameof(xpath));
|
||||
if (xpath == null) throw new ArgumentNullException(nameof(xpath));
|
||||
|
||||
var values = new Dictionary<string, string> { { "nodeName", xpath.GetAttribute("nodeName", "") } };
|
||||
values["nodeTypeAlias"] = xpath.Name;
|
||||
@@ -420,8 +420,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
{
|
||||
Values = values,
|
||||
XPath = forceNav ? xpath : null // outside of tests we do NOT want to cache the navigator!
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
internal CacheValues ConvertFromIMedia(IMedia media)
|
||||
{
|
||||
@@ -533,10 +533,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
}
|
||||
|
||||
//if there's no result then return null. Previously we defaulted back to library.GetMedia below
|
||||
//but this will always get called for when we are getting descendents since many items won't have
|
||||
//children and then we are hitting the database again!
|
||||
//So instead we're going to rely on Examine to have the correct results like it should.
|
||||
return Enumerable.Empty<IPublishedContent>();
|
||||
//but this will always get called for when we are getting descendents since many items won't have
|
||||
//children and then we are hitting the database again!
|
||||
//So instead we're going to rely on Examine to have the correct results like it should.
|
||||
return Enumerable.Empty<IPublishedContent>();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
@@ -634,14 +634,14 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
XPathNavigator nav,
|
||||
bool fromExamine)
|
||||
{
|
||||
if (valueDictionary == null) throw new ArgumentNullException(nameof(valueDictionary));
|
||||
if (getParent == null) throw new ArgumentNullException(nameof(getParent));
|
||||
if (getProperty == null) throw new ArgumentNullException(nameof(getProperty));
|
||||
if (valueDictionary == null) throw new ArgumentNullException(nameof(valueDictionary));
|
||||
if (getParent == null) throw new ArgumentNullException(nameof(getParent));
|
||||
if (getProperty == null) throw new ArgumentNullException(nameof(getProperty));
|
||||
|
||||
_getParent = new Lazy<IPublishedContent>(() => getParent(ParentId));
|
||||
_getChildren = new Lazy<IEnumerable<IPublishedContent>>(() => getChildren(Id, nav));
|
||||
_getProperty = getProperty;
|
||||
_cacheProvider = cacheProvider;
|
||||
_cacheProvider = cacheProvider;
|
||||
|
||||
LoadedFromExamine = fromExamine;
|
||||
|
||||
@@ -651,11 +651,11 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
ValidateAndSetProperty(valueDictionary, val => _sortOrder = int.Parse(val), "sortOrder");
|
||||
ValidateAndSetProperty(valueDictionary, val => _name = val, "nodeName", "__nodeName");
|
||||
ValidateAndSetProperty(valueDictionary, val => _urlName = val, "urlName");
|
||||
ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", LuceneIndexer.NodeTypeAliasFieldName);
|
||||
ValidateAndSetProperty(valueDictionary, val => _documentTypeAlias = val, "nodeTypeAlias", LuceneIndexer.NodeTypeAliasFieldName);
|
||||
ValidateAndSetProperty(valueDictionary, val => _documentTypeId = int.Parse(val), "nodeType");
|
||||
//ValidateAndSetProperty(valueDictionary, val => _writerName = val, "writerName");
|
||||
//ValidateAndSetProperty(valueDictionary, val => _writerName = val, "writerName");
|
||||
ValidateAndSetProperty(valueDictionary, val => _creatorName = val, "creatorName", "writerName"); //this is a bit of a hack fix for: U4-1132
|
||||
//ValidateAndSetProperty(valueDictionary, val => _writerId = int.Parse(val), "writerID");
|
||||
//ValidateAndSetProperty(valueDictionary, val => _writerId = int.Parse(val), "writerID");
|
||||
ValidateAndSetProperty(valueDictionary, val => _creatorId = int.Parse(val), "creatorID", "writerID"); //this is a bit of a hack fix for: U4-1132
|
||||
ValidateAndSetProperty(valueDictionary, val => _path = val, "path", "__Path");
|
||||
ValidateAndSetProperty(valueDictionary, val => _createDate = ParseDateTimeValue(val), "createDate");
|
||||
@@ -671,7 +671,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
}
|
||||
}, "parentID");
|
||||
|
||||
_contentType = contentTypeCache.Get(PublishedItemType.Media, _documentTypeAlias);
|
||||
_contentType = contentTypeCache.Get(PublishedItemType.Media, _documentTypeAlias);
|
||||
_properties = new Collection<IPublishedProperty>();
|
||||
|
||||
//handle content type properties
|
||||
@@ -709,18 +709,18 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
private DateTime ParseDateTimeValue(string val)
|
||||
{
|
||||
if (LoadedFromExamine == false)
|
||||
if (LoadedFromExamine == false)
|
||||
return DateTime.Parse(val);
|
||||
|
||||
//we need to parse the date time using Lucene converters
|
||||
var ticks = long.Parse(val);
|
||||
return new DateTime(ticks);
|
||||
//we need to parse the date time using Lucene converters
|
||||
var ticks = long.Parse(val);
|
||||
return new DateTime(ticks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flag to get/set if this was laoded from examine cache
|
||||
/// </summary>
|
||||
internal bool LoadedFromExamine { get; }
|
||||
internal bool LoadedFromExamine { get; }
|
||||
|
||||
//private readonly Func<DictionaryPublishedContent, IPublishedContent> _getParent;
|
||||
private readonly Lazy<IPublishedContent> _getParent;
|
||||
@@ -732,51 +732,51 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
/// <summary>
|
||||
/// Returns 'Media' as the item type
|
||||
/// </summary>
|
||||
public override PublishedItemType ItemType => PublishedItemType.Media;
|
||||
public override PublishedItemType ItemType => PublishedItemType.Media;
|
||||
|
||||
public override IPublishedContent Parent => _getParent.Value;
|
||||
public override IPublishedContent Parent => _getParent.Value;
|
||||
|
||||
public int ParentId { get; private set; }
|
||||
|
||||
public override int Id => _id;
|
||||
public override int Id => _id;
|
||||
|
||||
public override Guid Key => _key;
|
||||
public override Guid Key => _key;
|
||||
|
||||
public override int TemplateId => 0;
|
||||
public override int TemplateId => 0;
|
||||
|
||||
public override int SortOrder => _sortOrder;
|
||||
public override int SortOrder => _sortOrder;
|
||||
|
||||
public override string Name => _name;
|
||||
public override string Name => _name;
|
||||
|
||||
public override string UrlName => _urlName;
|
||||
public override string UrlName => _urlName;
|
||||
|
||||
public override string DocumentTypeAlias => _documentTypeAlias;
|
||||
public override string DocumentTypeAlias => _documentTypeAlias;
|
||||
|
||||
public override int DocumentTypeId => _documentTypeId;
|
||||
public override int DocumentTypeId => _documentTypeId;
|
||||
|
||||
public override string WriterName => _creatorName;
|
||||
public override string WriterName => _creatorName;
|
||||
|
||||
public override string CreatorName => _creatorName;
|
||||
public override string CreatorName => _creatorName;
|
||||
|
||||
public override int WriterId => _creatorId;
|
||||
public override int WriterId => _creatorId;
|
||||
|
||||
public override int CreatorId => _creatorId;
|
||||
public override int CreatorId => _creatorId;
|
||||
|
||||
public override string Path => _path;
|
||||
public override string Path => _path;
|
||||
|
||||
public override DateTime CreateDate => _createDate;
|
||||
public override DateTime CreateDate => _createDate;
|
||||
|
||||
public override DateTime UpdateDate => _updateDate;
|
||||
public override DateTime UpdateDate => _updateDate;
|
||||
|
||||
public override Guid Version => Guid.Empty;
|
||||
public override Guid Version => Guid.Empty;
|
||||
|
||||
public override int Level => _level;
|
||||
public override int Level => _level;
|
||||
|
||||
public override bool IsDraft => false;
|
||||
public override bool IsDraft => false;
|
||||
|
||||
public override IEnumerable<IPublishedProperty> Properties => _properties;
|
||||
public override IEnumerable<IPublishedProperty> Properties => _properties;
|
||||
|
||||
public override IEnumerable<IPublishedContent> Children => _getChildren.Value;
|
||||
public override IEnumerable<IPublishedContent> Children => _getChildren.Value;
|
||||
|
||||
public override IPublishedProperty GetProperty(string alias)
|
||||
{
|
||||
@@ -785,7 +785,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public override PublishedContentType ContentType => _contentType;
|
||||
|
||||
// override to implement cache
|
||||
// override to implement cache
|
||||
// cache at context level, ie once for the whole request
|
||||
// but cache is not shared by requests because we wouldn't know how to clear it
|
||||
public override IPublishedProperty GetProperty(string alias, bool recurse)
|
||||
@@ -831,8 +831,8 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
}
|
||||
}
|
||||
|
||||
internal void Resync()
|
||||
{
|
||||
internal void Resync()
|
||||
{
|
||||
// clear recursive properties cached by XmlPublishedContent.GetProperty
|
||||
// assume that nothing else is going to cache IPublishedProperty items (else would need to do ByKeySearch)
|
||||
// NOTE all properties cleared when clearing the content cache (see content cache)
|
||||
@@ -852,12 +852,12 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
return _contentTypeCache.Get(PublishedItemType.Media, alias);
|
||||
}
|
||||
|
||||
public override IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public override IEnumerable<IPublishedContent> GetByContentType(PublishedContentType contentType)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
// REFACTORING
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Xml;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Scoping;
|
||||
@@ -141,4 +141,4 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
@@ -14,72 +14,72 @@ using Umbraco.Web.Models;
|
||||
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents an IPublishedContent which is created based on an Xml structure.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlType(Namespace = "http://umbraco.org/webservices/")]
|
||||
internal class XmlPublishedContent : PublishedContentBase
|
||||
{
|
||||
private XmlPublishedContent(XmlNode xmlNode, bool isPreviewing, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
{
|
||||
_xmlNode = xmlNode;
|
||||
_isPreviewing = isPreviewing;
|
||||
/// <summary>
|
||||
/// Represents an IPublishedContent which is created based on an Xml structure.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlType(Namespace = "http://umbraco.org/webservices/")]
|
||||
internal class XmlPublishedContent : PublishedContentBase
|
||||
{
|
||||
private XmlPublishedContent(XmlNode xmlNode, bool isPreviewing, ICacheProvider cacheProvider, PublishedContentTypeCache contentTypeCache)
|
||||
{
|
||||
_xmlNode = xmlNode;
|
||||
_isPreviewing = isPreviewing;
|
||||
|
||||
_cacheProvider = cacheProvider;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
}
|
||||
_cacheProvider = cacheProvider;
|
||||
_contentTypeCache = contentTypeCache;
|
||||
}
|
||||
|
||||
private readonly XmlNode _xmlNode;
|
||||
private readonly XmlNode _xmlNode;
|
||||
private readonly bool _isPreviewing;
|
||||
private readonly ICacheProvider _cacheProvider; // at facade/request level (see PublishedContentCache)
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
private readonly ICacheProvider _cacheProvider; // at facade/request level (see PublishedContentCache)
|
||||
private readonly PublishedContentTypeCache _contentTypeCache;
|
||||
|
||||
private bool _nodeInitialized;
|
||||
private bool _parentInitialized;
|
||||
private bool _childrenInitialized;
|
||||
private bool _parentInitialized;
|
||||
private bool _childrenInitialized;
|
||||
|
||||
private IEnumerable<IPublishedContent> _children = Enumerable.Empty<IPublishedContent>();
|
||||
private IPublishedContent _parent;
|
||||
private IEnumerable<IPublishedContent> _children = Enumerable.Empty<IPublishedContent>();
|
||||
private IPublishedContent _parent;
|
||||
|
||||
private PublishedContentType _contentType;
|
||||
private Dictionary<string, IPublishedProperty> _properties;
|
||||
|
||||
private int _id;
|
||||
private Guid _key;
|
||||
private int _template;
|
||||
private string _name;
|
||||
private string _docTypeAlias;
|
||||
private int _docTypeId;
|
||||
private string _writerName;
|
||||
private string _creatorName;
|
||||
private int _writerId;
|
||||
private int _creatorId;
|
||||
private string _urlName;
|
||||
private string _path;
|
||||
private DateTime _createDate;
|
||||
private DateTime _updateDate;
|
||||
private Guid _version;
|
||||
private int _sortOrder;
|
||||
private int _level;
|
||||
private bool _isDraft;
|
||||
private Guid _key;
|
||||
private int _template;
|
||||
private string _name;
|
||||
private string _docTypeAlias;
|
||||
private int _docTypeId;
|
||||
private string _writerName;
|
||||
private string _creatorName;
|
||||
private int _writerId;
|
||||
private int _creatorId;
|
||||
private string _urlName;
|
||||
private string _path;
|
||||
private DateTime _createDate;
|
||||
private DateTime _updateDate;
|
||||
private Guid _version;
|
||||
private int _sortOrder;
|
||||
private int _level;
|
||||
private bool _isDraft;
|
||||
|
||||
public override IEnumerable<IPublishedContent> Children
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
public override IEnumerable<IPublishedContent> Children
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
if (_childrenInitialized == false) InitializeChildren();
|
||||
return _children;
|
||||
}
|
||||
}
|
||||
return _children;
|
||||
}
|
||||
}
|
||||
|
||||
public override IPublishedProperty GetProperty(string alias)
|
||||
{
|
||||
public override IPublishedProperty GetProperty(string alias)
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
IPublishedProperty property;
|
||||
return _properties.TryGetValue(alias, out property) ? property : null;
|
||||
}
|
||||
return _properties.TryGetValue(alias, out property) ? property : null;
|
||||
}
|
||||
|
||||
// override to implement cache
|
||||
// cache at context level, ie once for the whole request
|
||||
@@ -95,188 +95,188 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
// note: cleared by PublishedContentCache.Resync - any change here must be applied there
|
||||
}
|
||||
|
||||
public override PublishedItemType ItemType => PublishedItemType.Content;
|
||||
public override PublishedItemType ItemType => PublishedItemType.Content;
|
||||
|
||||
public override IPublishedContent Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
public override IPublishedContent Parent
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
if (_parentInitialized == false) InitializeParent();
|
||||
return _parent;
|
||||
}
|
||||
}
|
||||
return _parent;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
|
||||
public override Guid Key
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _key;
|
||||
}
|
||||
}
|
||||
public override Guid Key
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _key;
|
||||
}
|
||||
}
|
||||
|
||||
public override int TemplateId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _template;
|
||||
}
|
||||
}
|
||||
public override int TemplateId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _template;
|
||||
}
|
||||
}
|
||||
|
||||
public override int SortOrder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _sortOrder;
|
||||
}
|
||||
}
|
||||
public override int SortOrder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _sortOrder;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
public override string DocumentTypeAlias
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _docTypeAlias;
|
||||
}
|
||||
}
|
||||
public override string DocumentTypeAlias
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _docTypeAlias;
|
||||
}
|
||||
}
|
||||
|
||||
public override int DocumentTypeId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _docTypeId;
|
||||
}
|
||||
}
|
||||
public override int DocumentTypeId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _docTypeId;
|
||||
}
|
||||
}
|
||||
|
||||
public override string WriterName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _writerName;
|
||||
}
|
||||
}
|
||||
public override string WriterName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _writerName;
|
||||
}
|
||||
}
|
||||
|
||||
public override string CreatorName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _creatorName;
|
||||
}
|
||||
}
|
||||
public override string CreatorName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _creatorName;
|
||||
}
|
||||
}
|
||||
|
||||
public override int WriterId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _writerId;
|
||||
}
|
||||
}
|
||||
public override int WriterId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _writerId;
|
||||
}
|
||||
}
|
||||
|
||||
public override int CreatorId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _creatorId;
|
||||
}
|
||||
}
|
||||
public override int CreatorId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _creatorId;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _path;
|
||||
}
|
||||
}
|
||||
public override string Path
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _path;
|
||||
}
|
||||
}
|
||||
|
||||
public override DateTime CreateDate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _createDate;
|
||||
}
|
||||
}
|
||||
public override DateTime CreateDate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _createDate;
|
||||
}
|
||||
}
|
||||
|
||||
public override DateTime UpdateDate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _updateDate;
|
||||
}
|
||||
}
|
||||
public override DateTime UpdateDate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _updateDate;
|
||||
}
|
||||
}
|
||||
|
||||
public override Guid Version
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _version;
|
||||
}
|
||||
}
|
||||
public override Guid Version
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _version;
|
||||
}
|
||||
}
|
||||
|
||||
public override string UrlName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _urlName;
|
||||
}
|
||||
}
|
||||
public override string UrlName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _urlName;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Level
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _level;
|
||||
}
|
||||
}
|
||||
public override int Level
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _level;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDraft
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _isDraft;
|
||||
}
|
||||
}
|
||||
public override bool IsDraft
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _isDraft;
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<IPublishedProperty> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _properties.Values;
|
||||
}
|
||||
}
|
||||
public override IEnumerable<IPublishedProperty> Properties
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_nodeInitialized == false) InitializeNode();
|
||||
return _properties.Values;
|
||||
}
|
||||
}
|
||||
|
||||
public override PublishedContentType ContentType
|
||||
{
|
||||
@@ -287,145 +287,145 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeParent()
|
||||
{
|
||||
var parent = _xmlNode?.ParentNode;
|
||||
private void InitializeParent()
|
||||
{
|
||||
var parent = _xmlNode?.ParentNode;
|
||||
if (parent == null) return;
|
||||
|
||||
if (parent.Attributes?.GetNamedItem("isDoc") != null)
|
||||
_parent = Get(parent, _isPreviewing, _cacheProvider, _contentTypeCache);
|
||||
if (parent.Attributes?.GetNamedItem("isDoc") != null)
|
||||
_parent = Get(parent, _isPreviewing, _cacheProvider, _contentTypeCache);
|
||||
|
||||
// warn: this is not thread-safe...
|
||||
_parentInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeNode()
|
||||
{
|
||||
InitializeNode(_xmlNode, _isPreviewing,
|
||||
out _id, out _key, out _template, out _sortOrder, out _name, out _writerName,
|
||||
out _urlName, out _creatorName, out _creatorId, out _writerId, out _docTypeAlias, out _docTypeId, out _path,
|
||||
out _version, out _createDate, out _updateDate, out _level, out _isDraft, out _contentType, out _properties,
|
||||
_contentTypeCache.Get);
|
||||
private void InitializeNode()
|
||||
{
|
||||
InitializeNode(_xmlNode, _isPreviewing,
|
||||
out _id, out _key, out _template, out _sortOrder, out _name, out _writerName,
|
||||
out _urlName, out _creatorName, out _creatorId, out _writerId, out _docTypeAlias, out _docTypeId, out _path,
|
||||
out _version, out _createDate, out _updateDate, out _level, out _isDraft, out _contentType, out _properties,
|
||||
_contentTypeCache.Get);
|
||||
|
||||
// warn: this is not thread-safe...
|
||||
_nodeInitialized = true;
|
||||
}
|
||||
// warn: this is not thread-safe...
|
||||
_nodeInitialized = true;
|
||||
}
|
||||
|
||||
internal static void InitializeNode(XmlNode xmlNode, bool isPreviewing,
|
||||
out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName,
|
||||
out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path,
|
||||
out Guid version, out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft,
|
||||
out PublishedContentType contentType, out Dictionary<string, IPublishedProperty> properties,
|
||||
Func<PublishedItemType, string, PublishedContentType> getPublishedContentType)
|
||||
{
|
||||
//initialize the out params with defaults:
|
||||
writerName = null;
|
||||
docTypeAlias = null;
|
||||
id = template = sortOrder = template = creatorId = writerId = docTypeId = level = default(int);
|
||||
key = version = default(Guid);
|
||||
name = writerName = urlName = creatorName = docTypeAlias = path = null;
|
||||
createDate = updateDate = default(DateTime);
|
||||
isDraft = false;
|
||||
contentType = null;
|
||||
properties = null;
|
||||
internal static void InitializeNode(XmlNode xmlNode, bool isPreviewing,
|
||||
out int id, out Guid key, out int template, out int sortOrder, out string name, out string writerName, out string urlName,
|
||||
out string creatorName, out int creatorId, out int writerId, out string docTypeAlias, out int docTypeId, out string path,
|
||||
out Guid version, out DateTime createDate, out DateTime updateDate, out int level, out bool isDraft,
|
||||
out PublishedContentType contentType, out Dictionary<string, IPublishedProperty> properties,
|
||||
Func<PublishedItemType, string, PublishedContentType> getPublishedContentType)
|
||||
{
|
||||
//initialize the out params with defaults:
|
||||
writerName = null;
|
||||
docTypeAlias = null;
|
||||
id = template = sortOrder = template = creatorId = writerId = docTypeId = level = default(int);
|
||||
key = version = default(Guid);
|
||||
name = writerName = urlName = creatorName = docTypeAlias = path = null;
|
||||
createDate = updateDate = default(DateTime);
|
||||
isDraft = false;
|
||||
contentType = null;
|
||||
properties = null;
|
||||
|
||||
if (xmlNode == null) return;
|
||||
|
||||
if (xmlNode.Attributes != null)
|
||||
{
|
||||
id = int.Parse(xmlNode.Attributes.GetNamedItem("id").Value);
|
||||
if (xmlNode.Attributes != null)
|
||||
{
|
||||
id = int.Parse(xmlNode.Attributes.GetNamedItem("id").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("key") != null) // because, migration
|
||||
key = Guid.Parse(xmlNode.Attributes.GetNamedItem("key").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("template") != null)
|
||||
template = int.Parse(xmlNode.Attributes.GetNamedItem("template").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("sortOrder") != null)
|
||||
sortOrder = int.Parse(xmlNode.Attributes.GetNamedItem("sortOrder").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("nodeName") != null)
|
||||
name = xmlNode.Attributes.GetNamedItem("nodeName").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("writerName") != null)
|
||||
writerName = xmlNode.Attributes.GetNamedItem("writerName").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("urlName") != null)
|
||||
urlName = xmlNode.Attributes.GetNamedItem("urlName").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("creatorName") != null)
|
||||
creatorName = xmlNode.Attributes.GetNamedItem("creatorName").Value;
|
||||
key = Guid.Parse(xmlNode.Attributes.GetNamedItem("key").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("template") != null)
|
||||
template = int.Parse(xmlNode.Attributes.GetNamedItem("template").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("sortOrder") != null)
|
||||
sortOrder = int.Parse(xmlNode.Attributes.GetNamedItem("sortOrder").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("nodeName") != null)
|
||||
name = xmlNode.Attributes.GetNamedItem("nodeName").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("writerName") != null)
|
||||
writerName = xmlNode.Attributes.GetNamedItem("writerName").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("urlName") != null)
|
||||
urlName = xmlNode.Attributes.GetNamedItem("urlName").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("creatorName") != null)
|
||||
creatorName = xmlNode.Attributes.GetNamedItem("creatorName").Value;
|
||||
|
||||
//Added the actual userID, as a user cannot be looked up via full name only...
|
||||
if (xmlNode.Attributes.GetNamedItem("creatorID") != null)
|
||||
creatorId = int.Parse(xmlNode.Attributes.GetNamedItem("creatorID").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("writerID") != null)
|
||||
writerId = int.Parse(xmlNode.Attributes.GetNamedItem("writerID").Value);
|
||||
//Added the actual userID, as a user cannot be looked up via full name only...
|
||||
if (xmlNode.Attributes.GetNamedItem("creatorID") != null)
|
||||
creatorId = int.Parse(xmlNode.Attributes.GetNamedItem("creatorID").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("writerID") != null)
|
||||
writerId = int.Parse(xmlNode.Attributes.GetNamedItem("writerID").Value);
|
||||
|
||||
docTypeAlias = xmlNode.Name;
|
||||
|
||||
if (xmlNode.Attributes.GetNamedItem("nodeType") != null)
|
||||
docTypeId = int.Parse(xmlNode.Attributes.GetNamedItem("nodeType").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("path") != null)
|
||||
path = xmlNode.Attributes.GetNamedItem("path").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("version") != null)
|
||||
version = new Guid(xmlNode.Attributes.GetNamedItem("version").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("createDate") != null)
|
||||
createDate = DateTime.Parse(xmlNode.Attributes.GetNamedItem("createDate").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("updateDate") != null)
|
||||
updateDate = DateTime.Parse(xmlNode.Attributes.GetNamedItem("updateDate").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("level") != null)
|
||||
level = int.Parse(xmlNode.Attributes.GetNamedItem("level").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("nodeType") != null)
|
||||
docTypeId = int.Parse(xmlNode.Attributes.GetNamedItem("nodeType").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("path") != null)
|
||||
path = xmlNode.Attributes.GetNamedItem("path").Value;
|
||||
if (xmlNode.Attributes.GetNamedItem("version") != null)
|
||||
version = new Guid(xmlNode.Attributes.GetNamedItem("version").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("createDate") != null)
|
||||
createDate = DateTime.Parse(xmlNode.Attributes.GetNamedItem("createDate").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("updateDate") != null)
|
||||
updateDate = DateTime.Parse(xmlNode.Attributes.GetNamedItem("updateDate").Value);
|
||||
if (xmlNode.Attributes.GetNamedItem("level") != null)
|
||||
level = int.Parse(xmlNode.Attributes.GetNamedItem("level").Value);
|
||||
|
||||
isDraft = xmlNode.Attributes.GetNamedItem("isDraft") != null;
|
||||
}
|
||||
|
||||
//dictionary to store the property node data
|
||||
var propertyNodes = new Dictionary<string, XmlNode>();
|
||||
//dictionary to store the property node data
|
||||
var propertyNodes = new Dictionary<string, XmlNode>();
|
||||
|
||||
foreach (XmlNode n in xmlNode.ChildNodes)
|
||||
{
|
||||
var e = n as XmlElement;
|
||||
if (e == null) continue;
|
||||
if (e.HasAttribute("isDoc") == false)
|
||||
{
|
||||
PopulatePropertyNodes(propertyNodes, e, false);
|
||||
}
|
||||
else break; //we are not longer on property elements
|
||||
}
|
||||
foreach (XmlNode n in xmlNode.ChildNodes)
|
||||
{
|
||||
var e = n as XmlElement;
|
||||
if (e == null) continue;
|
||||
if (e.HasAttribute("isDoc") == false)
|
||||
{
|
||||
PopulatePropertyNodes(propertyNodes, e, false);
|
||||
}
|
||||
else break; //we are not longer on property elements
|
||||
}
|
||||
|
||||
//lookup the content type and create the properties collection
|
||||
try
|
||||
{
|
||||
contentType = getPublishedContentType(PublishedItemType.Content, docTypeAlias);
|
||||
//lookup the content type and create the properties collection
|
||||
try
|
||||
{
|
||||
contentType = getPublishedContentType(PublishedItemType.Content, docTypeAlias);
|
||||
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
// fixme - enable!
|
||||
//content.Instance.RefreshContentFromDatabase();
|
||||
throw new InvalidOperationException($"{e.Message}. This usually indicates that the content cache is corrupt; the content cache has been rebuilt in an attempt to self-fix the issue.");
|
||||
}
|
||||
//content.Instance.RefreshContentFromDatabase();
|
||||
throw new InvalidOperationException($"{e.Message}. This usually indicates that the content cache is corrupt; the content cache has been rebuilt in an attempt to self-fix the issue.");
|
||||
}
|
||||
|
||||
//fill in the property collection
|
||||
properties = new Dictionary<string, IPublishedProperty>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var propertyType in contentType.PropertyTypes)
|
||||
{
|
||||
properties = new Dictionary<string, IPublishedProperty>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var propertyType in contentType.PropertyTypes)
|
||||
{
|
||||
var val = propertyNodes.TryGetValue(propertyType.PropertyTypeAlias.ToLowerInvariant(), out XmlNode n)
|
||||
? new XmlPublishedProperty(propertyType, isPreviewing, n)
|
||||
: new XmlPublishedProperty(propertyType, isPreviewing);
|
||||
|
||||
properties[propertyType.PropertyTypeAlias] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void PopulatePropertyNodes(IDictionary<string, XmlNode> propertyNodes, XmlNode n, bool legacy)
|
||||
{
|
||||
var attrs = n.Attributes;
|
||||
if (attrs == null) return;
|
||||
private static void PopulatePropertyNodes(IDictionary<string, XmlNode> propertyNodes, XmlNode n, bool legacy)
|
||||
{
|
||||
var attrs = n.Attributes;
|
||||
if (attrs == null) return;
|
||||
|
||||
var alias = legacy
|
||||
? attrs.GetNamedItem("alias").Value
|
||||
: n.Name;
|
||||
propertyNodes[alias.ToLowerInvariant()] = n;
|
||||
}
|
||||
var alias = legacy
|
||||
? attrs.GetNamedItem("alias").Value
|
||||
: n.Name;
|
||||
propertyNodes[alias.ToLowerInvariant()] = n;
|
||||
}
|
||||
|
||||
private void InitializeChildren()
|
||||
{
|
||||
if (_xmlNode == null) return;
|
||||
{
|
||||
if (_xmlNode == null) return;
|
||||
|
||||
// load children
|
||||
const string childXPath = "* [@isDoc]";
|
||||
@@ -441,7 +441,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
// warn: this is not thread-safe
|
||||
_childrenInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an IPublishedContent corresponding to an Xml cache node.
|
||||
@@ -465,11 +465,11 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
return (IPublishedContent) cacheProvider.GetCacheItem(key, () => (new XmlPublishedContent(node, isPreviewing, cacheProvider, contentTypeCache)).CreateModel());
|
||||
}
|
||||
|
||||
public static void ClearRequest()
|
||||
{
|
||||
Current.ApplicationCache.RequestCache.ClearCacheByKeySearch(CacheKeyPrefix);
|
||||
}
|
||||
public static void ClearRequest()
|
||||
{
|
||||
Current.ApplicationCache.RequestCache.ClearCacheByKeySearch(CacheKeyPrefix);
|
||||
}
|
||||
|
||||
private const string CacheKeyPrefix = "CONTENTCACHE_XMLPUBLISHEDCONTENT_";
|
||||
}
|
||||
}
|
||||
private const string CacheKeyPrefix = "CONTENTCACHE_XMLPUBLISHEDCONTENT_";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
@@ -8,14 +8,14 @@ using Umbraco.Core.Xml;
|
||||
namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents an IDocumentProperty which is created based on an Xml structure.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlType(Namespace = "http://umbraco.org/webservices/")]
|
||||
internal class XmlPublishedProperty : PublishedPropertyBase
|
||||
{
|
||||
private readonly string _sourceValue; // the raw, xml node value
|
||||
/// <summary>
|
||||
/// Represents an IDocumentProperty which is created based on an Xml structure.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[XmlType(Namespace = "http://umbraco.org/webservices/")]
|
||||
internal class XmlPublishedProperty : PublishedPropertyBase
|
||||
{
|
||||
private readonly string _sourceValue; // the raw, xml node value
|
||||
|
||||
// Xml cache not using XPath value... and as for the rest...
|
||||
// we're single threaded here, keep it simple
|
||||
@@ -28,14 +28,14 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
/// </summary>
|
||||
public override object SourceValue => _sourceValue;
|
||||
|
||||
// in the Xml cache, everything is a string, and to have a value
|
||||
// in the Xml cache, everything is a string, and to have a value
|
||||
// you want to have a non-null, non-empty string.
|
||||
public override bool HasValue => _sourceValue.Trim().Length > 0;
|
||||
public override bool HasValue => _sourceValue.Trim().Length > 0;
|
||||
|
||||
public override object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
public override object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
// NOT caching the source (intermediate) value since we'll never need it
|
||||
// everything in Xml cache is per-request anyways
|
||||
// also, properties should not be shared between requests and therefore
|
||||
@@ -54,10 +54,10 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
|
||||
public XmlPublishedProperty(PublishedPropertyType propertyType, bool isPreviewing, XmlNode propertyXmlData)
|
||||
: this(propertyType, isPreviewing)
|
||||
{
|
||||
if (propertyXmlData == null)
|
||||
throw new ArgumentNullException(nameof(propertyXmlData), "Property xml source is null");
|
||||
_sourceValue = XmlHelper.GetNodeValue(propertyXmlData);
|
||||
{
|
||||
if (propertyXmlData == null)
|
||||
throw new ArgumentNullException(nameof(propertyXmlData), "Property xml source is null");
|
||||
_sourceValue = XmlHelper.GetNodeValue(propertyXmlData);
|
||||
}
|
||||
|
||||
public XmlPublishedProperty(PublishedPropertyType propertyType, bool isPreviewing, string propertyData)
|
||||
@@ -74,5 +74,5 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_sourceValue = string.Empty;
|
||||
_isPreviewing = isPreviewing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,4 +179,4 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
|
||||
_timer.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user