Fix build after merge

This commit is contained in:
Stephan
2016-07-20 12:44:15 +02:00
parent 5df967355a
commit f9fd8b67b1
15 changed files with 98 additions and 153 deletions

View File

@@ -6,7 +6,6 @@ using Umbraco.Core.Logging;
namespace Umbraco.Core.ObjectResolution
{
/// <summary>
/// A lazy many objects resolver that uses IoC
/// </summary>
@@ -18,12 +17,12 @@ namespace Umbraco.Core.ObjectResolution
{
protected IServiceContainer Container;
private object _locker = new object();
private bool _isInitialized = false;
private bool _isInitialized;
internal ContainerLazyManyObjectsResolver(IServiceContainer container, ILogger logger, Func<IEnumerable<Type>> typeListProducerList, ObjectLifetimeScope scope = ObjectLifetimeScope.Application)
: base(logger, typeListProducerList, scope)
{
if (container == null) throw new ArgumentNullException("container");
if (container == null) throw new ArgumentNullException(nameof(container));
Container = container;
//Register ourselves in the case that a resolver instance should be injected someplace
@@ -43,14 +42,9 @@ namespace Umbraco.Core.ObjectResolution
LazyInitializer.EnsureInitialized(ref Container, ref _isInitialized, ref _locker, () =>
{
foreach (var type in InstanceTypes)
{
Container.Register(type, GetLifetime(LifetimeScope));
}
if (afterRegistered != null)
{
afterRegistered(Container);
}
afterRegistered?.Invoke(Container);
return Container;
});
@@ -82,7 +76,7 @@ namespace Umbraco.Core.ObjectResolution
return new PerRequestLifeTime();
case ObjectLifetimeScope.Application:
return new PerContainerLifetime();
case ObjectLifetimeScope.Transient:
//case ObjectLifetimeScope.Transient:
default:
return null;
}

View File

@@ -64,7 +64,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var domainCache = new DomainCache(ServiceContext.DomainService);
var facade = new Facade(
new PublishedContentCache(xmlStore, domainCache, cacheProvider, ContentTypesCache, null, null),
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, cacheProvider, ContentTypesCache),
new PublishedMediaCache(xmlStore, ServiceContext.MediaService, ServiceContext.UserService, cacheProvider, ContentTypesCache),
new PublishedMemberCache(null, cacheProvider, ApplicationContext.Services.MemberService, ContentTypesCache),
domainCache);
var facadeService = new Mock<IFacadeService>();

View File

@@ -49,7 +49,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var mChild2 = global::umbraco.cms.businesslogic.media.Media.MakeNew("Child2", mType, user, mRoot2.Id);
var ctx = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(new XmlStore((XmlDocument) null), ServiceContext.MediaService, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(new XmlStore((XmlDocument) null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
var roots = cache.GetAtRoot();
Assert.AreEqual(2, roots.Count());
Assert.IsTrue(roots.Select(x => x.Id).ContainsAll(new[] {mRoot1.Id, mRoot2.Id}));
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
//var publishedMedia = PublishedMediaTests.GetNode(mRoot.Id, GetUmbracoContext("/test", 1234));
var umbracoContext = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null), umbracoContext.Application.Services.MediaService, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null), umbracoContext.Application.Services.MediaService, umbracoContext.Application.Services.UserService, new StaticCacheProvider(), ContentTypesCache);
var publishedMedia = cache.GetById(mRoot.Id);
Assert.IsNotNull(publishedMedia);
@@ -179,7 +179,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
result.Fields.Add("creatorID", "0");
result.Fields.Add("creatorName", "Shannon");
var store = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, new StaticCacheProvider(), ContentTypesCache);
var store = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
var doc = store.CreateFromCacheValues(store.ConvertFromSearchResult(result));
DoAssert(doc, 1234, key, 0, 0, "/media/test.jpg", "Image", 0, "Shannon", "Shannon", 0, 0, "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2);
@@ -195,7 +195,7 @@ namespace Umbraco.Tests.Cache.PublishedCache
var xmlDoc = GetMediaXml();
((XmlElement)xmlDoc.DocumentElement.FirstChild).SetAttribute("key", key.ToString());
var navigator = xmlDoc.SelectSingleNode("/root/Image").CreateNavigator();
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
var doc = cache.CreateFromCacheValues(cache.ConvertFromXPathNavigator(navigator, true));
DoAssert(doc, 2000, key, 0, 2, "image1", "Image", 2044, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1);

View File

@@ -62,7 +62,7 @@ namespace Umbraco.Tests.PublishedContent
/// <returns></returns>
internal IPublishedContent GetNode(int id, UmbracoContext umbracoContext)
{
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null), umbracoContext.Application.Services.MediaService, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(new XmlStore((XmlDocument)null), umbracoContext.Application.Services.MediaService, umbracoContext.Application.Services.UserService, new StaticCacheProvider(), ContentTypesCache);
var doc = cache.GetById(id);
Assert.IsNotNull(doc);
return doc;
@@ -116,7 +116,7 @@ namespace Umbraco.Tests.PublishedContent
var searcher = indexer.GetSearcher();
var ctx = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(1111);
@@ -148,7 +148,7 @@ namespace Umbraco.Tests.PublishedContent
var searcher = indexer.GetSearcher();
var ctx = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//ensure it is found
var publishedMedia = cache.GetById(3113);
@@ -192,7 +192,7 @@ namespace Umbraco.Tests.PublishedContent
var searcher = indexer.GetSearcher();
var ctx = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(1111);
@@ -217,7 +217,7 @@ namespace Umbraco.Tests.PublishedContent
var searcher = indexer.GetSearcher();
var ctx = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(1111);
@@ -242,7 +242,7 @@ namespace Umbraco.Tests.PublishedContent
var searcher = indexer.GetSearcher();
var ctx = GetUmbracoContext("/test", 1234);
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(1111);
@@ -267,7 +267,7 @@ namespace Umbraco.Tests.PublishedContent
var ctx = GetUmbracoContext("/test", 1234);
var searcher = indexer.GetSearcher();
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(3113);
@@ -289,7 +289,7 @@ namespace Umbraco.Tests.PublishedContent
var ctx = GetUmbracoContext("/test", 1234);
var searcher = indexer.GetSearcher();
var cache = new PublishedMediaCache(ServiceContext.MediaService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
var cache = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);
//we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
var publishedMedia = cache.GetById(3113);
@@ -462,7 +462,7 @@ namespace Umbraco.Tests.PublishedContent
</Image>");
var node = xml.DescendantsAndSelf("Image").Single(x => (int)x.Attribute("id") == nodeId);
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, new StaticCacheProvider(), ContentTypesCache);
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
var nav = node.CreateNavigator();
@@ -482,7 +482,7 @@ namespace Umbraco.Tests.PublishedContent
var errorXml = new XElement("error", string.Format("No media is maching '{0}'", 1234));
var nav = errorXml.CreateNavigator();
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, new StaticCacheProvider(), ContentTypesCache);
var publishedMedia = new PublishedMediaCache(new XmlStore((XmlDocument)null), ServiceContext.MediaService, ServiceContext.UserService, new StaticCacheProvider(), ContentTypesCache);
var converted = publishedMedia.ConvertFromXPathNodeIterator(nav.Select("/"), 1234);
Assert.IsNull(converted);

View File

@@ -1327,9 +1327,9 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="configurationServiceNodeNotFound"><![CDATA[Unable to find <strong>'%0%'</strong> in config file <strong>'%1%'</strong>.]]></key>
<key alias="configurationServiceError">There was an error, check log for full error: %0%.</key>
<key alias="xmlDataIntegrityCheckMembers">Total XML: %0%, Total: %1%</key>
<key alias="xmlDataIntegrityCheckMedia">Total XML: %0%, Total: %1%</key>
<key alias="xmlDataIntegrityCheckContent">Total XML: %0%, Total published: %1%</key>
<key alias="xmlDataIntegrityCheckMembers">Members: %0%</key>
<key alias="xmlDataIntegrityCheckMedia">Media: %0%</key>
<key alias="xmlDataIntegrityCheckContent">Content: %0%</key>
<key alias="httpsCheckInvalidCertificate">Certificate validation error: '%0%'</key>
<key alias="httpsCheckInvalidUrl">Error pinging the URL %0% - '%1%'</key>

View File

@@ -1331,9 +1331,9 @@ To manage your website, simply open the Umbraco back office and start adding con
<key alias="configurationServiceNodeNotFound"><![CDATA[Unable to find <strong>'%0%'</strong> in config file <strong>'%1%'</strong>.]]></key>
<key alias="configurationServiceError">There was an error, check log for full error: %0%.</key>
<key alias="xmlDataIntegrityCheckMembers">Total XML: %0%, Total: %1%</key>
<key alias="xmlDataIntegrityCheckMedia">Total XML: %0%, Total: %1%</key>
<key alias="xmlDataIntegrityCheckContent">Total XML: %0%, Total published: %1%</key>
<key alias="xmlDataIntegrityCheckMembers">Members: %0%</key>
<key alias="xmlDataIntegrityCheckMedia">Media: %0%</key>
<key alias="xmlDataIntegrityCheckContent">Content: %0%</key>
<key alias="httpsCheckInvalidCertificate">Certificate validation error: '%0%'</key>
<key alias="httpsCheckInvalidUrl">Error pinging the URL %0% - '%1%'</key>

View File

@@ -89,7 +89,7 @@ namespace Umbraco.Web.Editors
if (pack == null) throw new ArgumentNullException("pack");
var refreshCache = false;
//Uninstall templates
foreach (var item in pack.Data.Templates.ToArray())
{
@@ -112,7 +112,7 @@ namespace Umbraco.Web.Editors
if (macro != null)
{
Services.MacroService.Delete(macro);
}
}
pack.Data.Macros.Remove(nId.ToString());
}
@@ -152,7 +152,7 @@ namespace Umbraco.Web.Editors
if (di != null)
{
Services.LocalizationService.Delete(di);
}
}
pack.Data.DictionaryItems.Remove(nId.ToString());
}
@@ -165,14 +165,14 @@ namespace Umbraco.Web.Editors
if (dtd != null)
{
Services.DataTypeService.Delete(dtd);
}
}
pack.Data.DataTypes.Remove(nId.ToString());
}
pack.Save();
// uninstall actions
//TODO: We should probably report errors to the UI!!
//TODO: We should probably report errors to the UI!!
// This never happened before though, but we should do something now
if (pack.Data.Actions.IsNullOrWhiteSpace() == false)
{
@@ -214,19 +214,14 @@ namespace Umbraco.Web.Editors
if (File.Exists(filePath))
{
File.Delete(filePath);
}
}
pack.Data.Files.Remove(file);
}
pack.Save();
pack.Delete(Security.GetUserId());
//TODO: Legacy - probably not needed
if (refreshCache)
{
library.RefreshContent();
}
TreeDefinitionCollection.Instance.ReRegisterTrees();
_Legacy.Actions.Action.ReRegisterActionsAndHandlers();
}
@@ -317,7 +312,7 @@ namespace Umbraco.Web.Editors
model.UmbracoVersion = ins.RequirementsType == RequirementsType.Strict
? string.Format("{0}.{1}.{2}", ins.RequirementsMajor, ins.RequirementsMinor, ins.RequirementsPatch)
: string.Empty;
//now we need to check for version comparison
model.IsCompatible = true;
if (ins.RequirementsType == RequirementsType.Strict)
@@ -397,7 +392,7 @@ namespace Umbraco.Web.Editors
{
//TODO: Currently it has to be here, it's not ideal but that's the way it is right now
var packageTempDir = IOHelper.MapPath(SystemDirectories.Data);
//ensure it's there
Directory.CreateDirectory(packageTempDir);
@@ -413,14 +408,14 @@ namespace Umbraco.Web.Editors
PopulateFromPackageData(model);
var validate = ValidateInstalledInternal(model.Name, model.Version);
if (validate == false)
{
//this package is already installed
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse(
Services.TextService.Localize("packager/packageAlreadyInstalled")));
Services.TextService.Localize("packager/packageAlreadyInstalled")));
}
}
else
{
@@ -429,7 +424,7 @@ namespace Umbraco.Web.Editors
Services.TextService.Localize("media/disallowedFileType"),
SpeechBubbleIcon.Warning));
}
}
return model;
@@ -451,7 +446,7 @@ namespace Umbraco.Web.Editors
//our repo guid
using (var our = Repository.getByGuid("65194810-1f85-11dd-bd0b-0800200c9a66"))
{
path = our.fetch(packageGuid, Security.CurrentUser.Id);
path = our.fetch(packageGuid, Security.CurrentUser.Id);
}
}

View File

@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using Umbraco.Core;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Services;
using Umbraco.Web.PublishedCache;
namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity
{
@@ -19,22 +16,21 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity
public class XmlDataIntegrityHealthCheck : HealthCheck
{
private readonly ILocalizedTextService _textService;
private readonly PublishedCache.XmlPublishedCache.FacadeService _facadeService;
private const string CheckContentXmlTableAction = "checkContentXmlTable";
private const string CheckMediaXmlTableAction = "checkMediaXmlTable";
private const string CheckMembersXmlTableAction = "checkMembersXmlTable";
public XmlDataIntegrityHealthCheck(HealthCheckContext healthCheckContext) : base(healthCheckContext)
public XmlDataIntegrityHealthCheck(HealthCheckContext healthCheckContext, IFacadeService facadeService)
: base(healthCheckContext)
{
_sqlSyntax = HealthCheckContext.ApplicationContext.DatabaseContext.SqlSyntax;
_services = HealthCheckContext.ApplicationContext.Services;
_database = HealthCheckContext.ApplicationContext.DatabaseContext.Database;
_textService = healthCheckContext.ApplicationContext.Services.TextService;
}
private readonly ISqlSyntaxProvider _sqlSyntax;
private readonly ServiceContext _services;
private readonly UmbracoDatabase _database;
_facadeService = facadeService as PublishedCache.XmlPublishedCache.FacadeService;
if (_facadeService == null)
throw new NotSupportedException("Unsupported IFacadeService, only the Xml one is supported.");
}
/// <summary>
/// Get the status for this health check
@@ -56,13 +52,13 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity
switch (action.Alias)
{
case CheckContentXmlTableAction:
_services.ContentService.RebuildXmlStructures();
_facadeService.RebuildContentAndPreviewXml();
return CheckContent();
case CheckMediaXmlTableAction:
_services.MediaService.RebuildXmlStructures();
_facadeService.RebuildMediaXml();
return CheckMedia();
case CheckMembersXmlTableAction:
_services.MemberService.RebuildXmlStructures();
_facadeService.RebuildMemberXml();
return CheckMembers();
default:
throw new ArgumentOutOfRangeException();
@@ -71,67 +67,28 @@ namespace Umbraco.Web.HealthCheck.Checks.DataIntegrity
private HealthCheckStatus CheckMembers()
{
var total = _services.MemberService.Count();
var memberObjectType = Guid.Parse(Constants.ObjectTypes.Member);
var subQuery = _database.Sql()
.Select("Count(*)")
.From<ContentXmlDto>()
.InnerJoin<NodeDto>()
.On<ContentXmlDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.Where<NodeDto>(dto => dto.NodeObjectType == memberObjectType);
var totalXml = _database.ExecuteScalar<int>(subQuery);
var actions = new List<HealthCheckAction>();
if (totalXml != total)
actions.Add(new HealthCheckAction(CheckMembersXmlTableAction, Id));
return new HealthCheckStatus(_textService.Localize("healthcheck/xmlDataIntegrityCheckMembers", new[] { totalXml.ToString(), total.ToString() }))
{
ResultType = totalXml == total ? StatusResultType.Success : StatusResultType.Error,
Actions = actions
};
return Check(_facadeService.VerifyMemberXml(), CheckMembersXmlTableAction, "healthcheck/xmlDataIntegrityCheckMembers");
}
private HealthCheckStatus CheckMedia()
{
var total = _services.MediaService.Count();
var mediaObjectType = Guid.Parse(Constants.ObjectTypes.Media);
var subQuery = _database.Sql()
.Select("Count(*)")
.From<ContentXmlDto>()
.InnerJoin<NodeDto>()
.On<ContentXmlDto, NodeDto>(left => left.NodeId, right => right.NodeId)
.Where<NodeDto>(dto => dto.NodeObjectType == mediaObjectType);
var totalXml = _database.ExecuteScalar<int>(subQuery);
var actions = new List<HealthCheckAction>();
if (totalXml != total)
actions.Add(new HealthCheckAction(CheckMediaXmlTableAction, Id));
return new HealthCheckStatus(_textService.Localize("healthcheck/xmlDataIntegrityCheckMedia", new[] { totalXml.ToString(), total.ToString() }))
{
ResultType = totalXml == total ? StatusResultType.Success : StatusResultType.Error,
Actions = actions
};
return Check(_facadeService.VerifyMediaXml(), CheckMediaXmlTableAction, "healthcheck/xmlDataIntegrityCheckMedia");
}
private HealthCheckStatus CheckContent()
{
var total = _services.ContentService.CountPublished();
var subQuery = _database.Sql()
.Select("DISTINCT cmsContentXml.nodeId")
.From<ContentXmlDto>()
.InnerJoin<DocumentDto>()
.On<DocumentDto, ContentXmlDto>(left => left.NodeId, right => right.NodeId);
var totalXml = _database.ExecuteScalar<int>("SELECT COUNT(*) FROM (" + subQuery.SQL + ") as tmp");
return Check(_facadeService.VerifyContentAndPreviewXml(), CheckContentXmlTableAction, "healthcheck/xmlDataIntegrityCheckContent");
}
private HealthCheckStatus Check(bool ok, string action, string text)
{
var actions = new List<HealthCheckAction>();
if (totalXml != total)
actions.Add(new HealthCheckAction(CheckContentXmlTableAction, Id));
if (ok == false)
actions.Add(new HealthCheckAction(action, Id));
return new HealthCheckStatus(_textService.Localize("healthcheck/xmlDataIntegrityCheckContent", new[] { totalXml.ToString(), total.ToString() }))
return new HealthCheckStatus(_textService.Localize(text, new[] { ok ? "ok" : "not ok" }))
{
ResultType = totalXml == total ? StatusResultType.Success : StatusResultType.Error,
ResultType = ok ? StatusResultType.Success : StatusResultType.Error,
Actions = actions
};
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using Umbraco.Web.Editors;
@@ -29,7 +30,8 @@ namespace Umbraco.Web.HealthCheck
/// <returns>Returns a collection of anonymous objects representing each group.</returns>
public object GetAllHealthChecks()
{
var groups = _healthCheckResolver.HealthChecks
var context = new HealthCheckContext(new HttpContextWrapper(HttpContext.Current), UmbracoContext.Current);
var groups = _healthCheckResolver.GetHealthChecks(context)
.GroupBy(x => x.Group)
.OrderBy(x => x.Key);
var healthCheckGroups = new List<HealthCheckGroup>();
@@ -50,7 +52,8 @@ namespace Umbraco.Web.HealthCheck
public object GetStatus(Guid id)
{
var check = _healthCheckResolver.HealthChecks.FirstOrDefault(x => x.Id == id);
var context = new HealthCheckContext(new HttpContextWrapper(HttpContext.Current), UmbracoContext.Current);
var check = _healthCheckResolver.GetHealthChecks(context).FirstOrDefault(x => x.Id == id);
if (check == null) throw new InvalidOperationException("No health check found with ID " + id);
return check.GetStatus();
@@ -59,7 +62,8 @@ namespace Umbraco.Web.HealthCheck
[HttpPost]
public HealthCheckStatus ExecuteAction(HealthCheckAction action)
{
var check = _healthCheckResolver.HealthChecks.FirstOrDefault(x => x.Id == action.HealthCheckId);
var context = new HealthCheckContext(new HttpContextWrapper(HttpContext.Current), UmbracoContext.Current);
var check = _healthCheckResolver.GetHealthChecks(context).FirstOrDefault(x => x.Id == action.HealthCheckId);
if (check == null) throw new InvalidOperationException("No health check found with id " + action.HealthCheckId);
return check.ExecuteAction(action);

View File

@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using LightInject;
using Umbraco.Core.Logging;
using Umbraco.Core.ObjectResolution;
@@ -12,41 +14,33 @@ namespace Umbraco.Web.HealthCheck
/// <remarks>
/// Each instance scoped to the lifespan of the http request
/// </remarks>
internal class HealthCheckResolver : LazyManyObjectsResolverBase<HealthCheckResolver, HealthCheck>, IHealthCheckResolver
internal class HealthCheckResolver : ContainerLazyManyObjectsResolver<HealthCheckResolver, HealthCheck>, IHealthCheckResolver
{
public HealthCheckResolver(ILogger logger, Func<IEnumerable<Type>> lazyTypeList)
: base(new HealthCheckServiceProvider(), logger, lazyTypeList, ObjectLifetimeScope.HttpRequest)
public HealthCheckResolver(IServiceContainer container, ILogger logger, Func<IEnumerable<Type>> types)
: base(container, logger, types, ObjectLifetimeScope.HttpRequest)
{ }
protected override IEnumerable<HealthCheck> CreateValues(ObjectLifetimeScope scope)
{
EnsureTypesRegisterred(scope, container =>
{
// resolve ctor dependency from GetInstance() runtimeArguments, if possible - 'factory' is
// the container, 'info' describes the ctor argument, and 'args' contains the args that
// were passed to GetInstance() - use first arg if it is the right type,
//
// for HealthCheckContext
container.RegisterConstructorDependency((factory, info, args) => args.Length > 0 ? args[0] as HealthCheckContext : null);
});
return InstanceTypes.Select(x => (HealthCheck) Container.GetInstance(x, new object[] { _healthCheckContext }));
}
/// <summary>
/// Returns all health check instances
/// </summary>
public IEnumerable<HealthCheck> HealthChecks => Values;
private HealthCheckContext _healthCheckContext;
/// <summary>
/// This will ctor the HealthCheck instances
/// </summary>
/// <remarks>
/// This is like a super crappy DI - in v8 we have real DI
/// </remarks>
private class HealthCheckServiceProvider : IServiceProvider
public IEnumerable<HealthCheck> GetHealthChecks(HealthCheckContext context)
{
public object GetService(Type serviceType)
{
var normalArgs = new[] { typeof(HealthCheckContext) };
var found = serviceType.GetConstructor(normalArgs);
if (found != null)
{
return found.Invoke(new object[]
{
new HealthCheckContext(new HttpContextWrapper(HttpContext.Current), UmbracoContext.Current)
});
}
//use normal ctor
return Activator.CreateInstance(serviceType);
}
_healthCheckContext = context;
return Values;
}
}
}

View File

@@ -4,6 +4,6 @@ namespace Umbraco.Web.HealthCheck
{
public interface IHealthCheckResolver
{
IEnumerable<HealthCheck> HealthChecks { get; }
IEnumerable<HealthCheck> GetHealthChecks(HealthCheckContext context);
}
}

View File

@@ -22,6 +22,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
private readonly IDomainService _domainService;
private readonly IMemberService _memberService;
private readonly IMediaService _mediaService;
private readonly IUserService _userService;
private readonly ICacheProvider _requestCache;
#region Constructors
@@ -60,6 +61,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
_domainService = serviceContext.DomainService;
_memberService = serviceContext.MemberService;
_mediaService = serviceContext.MediaService;
_userService = serviceContext.UserService;
_requestCache = requestCache;
}
@@ -84,7 +86,7 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
return new Facade(
new PublishedContentCache(_xmlStore, domainCache, _requestCache, _contentTypeCache, _routesCache, previewToken),
new PublishedMediaCache(_xmlStore, _mediaService, _requestCache, _contentTypeCache),
new PublishedMediaCache(_xmlStore, _mediaService, _userService, _requestCache, _contentTypeCache),
new PublishedMemberCache(_xmlStore, _requestCache, _memberService, _contentTypeCache),
domainCache);
}

View File

@@ -267,13 +267,13 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
private IPublishedContent ConvertToDocument(XmlNode xmlNode, bool isPreviewing, ICacheProvider cacheProvider)
{
return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing); // fixme cacheProvider, _contentTypeCache
return xmlNode == null ? null : XmlPublishedContent.Get(xmlNode, isPreviewing, cacheProvider, _contentTypeCache);
}
private IEnumerable<IPublishedContent> ConvertToDocuments(XmlNodeList xmlNodes, bool isPreviewing, ICacheProvider cacheProvider)
{
return xmlNodes.Cast<XmlNode>()
.Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing)); // fixme cacheProvider, _contentTypeCache
.Select(xmlNode => XmlPublishedContent.Get(xmlNode, isPreviewing, cacheProvider, _contentTypeCache));
}
#endregion

View File

@@ -517,8 +517,8 @@ namespace Umbraco.Web
CultureDictionaryFactoryResolver.Current = new CultureDictionaryFactoryResolver(Container, typeof(DefaultCultureDictionaryFactory));
HealthCheckResolver.Current = new HealthCheckResolver(ProfilingLogger.Logger,
() => PluginManager.ResolveTypes<HealthCheck.HealthCheck>());
HealthCheckResolver.Current = new HealthCheckResolver(Container, ProfilingLogger.Logger,
() => PluginManager.ResolveTypes<HealthCheck.HealthCheck>()); // fixme XML cache vs NuCache?!
}
/// <summary>

View File

@@ -21,7 +21,6 @@ namespace Umbraco.Web.WebServices
_facadeService = facadeService as FacadeService;
if (_facadeService == null)
throw new NotSupportedException("Unsupported IFacadeService, only the Xml one is supported.");
}
[HttpPost]