#16911: Prevent YSOD when a gallery feed doesn't respond or responds unexpectedly.

--HG--
branch : dev
This commit is contained in:
Dave Reed
2010-12-06 13:37:11 -08:00
parent 948f0a26d0
commit 4741f33e28

View File

@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Hosting;
using System.Web.Mvc;
using System.Xml.Linq;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Packaging.Services;
using Orchard.Packaging.ViewModels;
using Orchard.Themes;
@@ -30,9 +32,11 @@ namespace Orchard.Packaging.Controllers {
_notifier = notifier;
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
}
public Localizer T { get; set; }
public ILogger Logger { get; set; }
public ActionResult Sources() {
return View(new PackagingSourcesViewModel {
@@ -99,8 +103,20 @@ namespace Orchard.Packaging.Controllers {
: _packagingSourceManager.GetSources()
;
IEnumerable<PackagingEntry> extensions = null;
foreach (var source in sources) {
try {
var sourceExtensions = _packagingSourceManager.GetModuleList(source).ToArray();
extensions = extensions == null ? sourceExtensions : extensions.Concat(sourceExtensions);
}
catch (Exception ex) {
Logger.Error(ex, "Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message);
_notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, ex.Message));
}
}
return View("Modules", new PackagingExtensionsViewModel {
Extensions = sources.SelectMany(source => _packagingSourceManager.GetModuleList(source)),
Extensions = extensions ?? new PackagingEntry[] {},
Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle),
SelectedSource = selectedSource
});