From d4f28fcd851adf0e9c1600294c81b7867d4bf5e6 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 7 Jan 2015 10:39:00 +1100 Subject: [PATCH] fixes a couple of tests --- src/Umbraco.Core/Services/LocalizedTextService.cs | 13 +++++++++---- .../Services/LocalizedTextServiceFileSources.cs | 14 +++++++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Core/Services/LocalizedTextService.cs b/src/Umbraco.Core/Services/LocalizedTextService.cs index f5c2cc033a..c9d05f3a3b 100644 --- a/src/Umbraco.Core/Services/LocalizedTextService.cs +++ b/src/Umbraco.Core/Services/LocalizedTextService.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Xml; using System.Xml.Linq; using System.Xml.XPath; +using Umbraco.Core.Logging; namespace Umbraco.Core.Services { @@ -80,7 +81,8 @@ namespace Umbraco.Core.Services { if (_xmlSource.ContainsKey(culture) == false) { - throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service"); + LogHelper.Warn("The culture specified {0} was not found in any configured sources for this service", () => culture); + return result; } //convert all areas + keys to a single key with a '/' @@ -103,7 +105,8 @@ namespace Umbraco.Core.Services { if (_dictionarySource.ContainsKey(culture) == false) { - throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service"); + LogHelper.Warn("The culture specified {0} was not found in any configured sources for this service", () => culture); + return result; } //convert all areas + keys to a single key with a '/' @@ -137,7 +140,8 @@ namespace Umbraco.Core.Services { if (_dictionarySource.ContainsKey(culture) == false) { - throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service"); + LogHelper.Warn("The culture specified {0} was not found in any configured sources for this service", () => culture); + return "[" + key + "]"; } var cultureSource = _dictionarySource[culture]; @@ -174,7 +178,8 @@ namespace Umbraco.Core.Services { if (_xmlSource.ContainsKey(culture) == false) { - throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service"); + LogHelper.Warn("The culture specified {0} was not found in any configured sources for this service", () => culture); + return "[" + key + "]"; } var cultureSource = _xmlSource[culture].Value; diff --git a/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs b/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs index 147a3cda31..30e43a694c 100644 --- a/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs +++ b/src/Umbraco.Core/Services/LocalizedTextServiceFileSources.cs @@ -4,6 +4,7 @@ using System.Globalization; using System.IO; using System.Xml.Linq; using Umbraco.Core.Cache; +using Umbraco.Core.Logging; namespace Umbraco.Core.Services { @@ -20,7 +21,15 @@ namespace Umbraco.Core.Services if (cache == null) throw new ArgumentNullException("cache"); if (fileSourceFolder == null) throw new ArgumentNullException("fileSourceFolder"); _cache = cache; - _fileSourceFolder = fileSourceFolder; + + if (fileSourceFolder.Exists == false) + { + LogHelper.Warn("The folder does not exist: {0}, therefore no sources will be discovered", () => fileSourceFolder.FullName); + } + else + { + _fileSourceFolder = fileSourceFolder; + } } /// @@ -30,6 +39,9 @@ namespace Umbraco.Core.Services public IDictionary> GetXmlSources() { var result = new Dictionary>(); + + if (_fileSourceFolder == null) return result; + foreach (var fileInfo in _fileSourceFolder.GetFiles("*.xml")) { var localCopy = fileInfo;