mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
IExceptionPolicy concept and default implementation.
Updating EventBus and UnhandledExceptionFilter to use the exception policy. Adding OrchardFatalException. Updating text on default error page. (Part II) Removing the unhandled "catch" from module controllers. If there are "expected" exceptions, move them closer to the APIs where they occur. Removing ControllerExtensions.Error and refactoring. --HG-- branch : 1.x extra : transplant_source : %5C9a%E2%9A%F4%ACI%A3F%3C%D2%5C%CC%5C%9A.%E1%EF%3C
This commit is contained in:
@@ -4,6 +4,7 @@ using Autofac;
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.Events;
|
using Orchard.Events;
|
||||||
using System;
|
using System;
|
||||||
|
using Orchard.Exceptions;
|
||||||
|
|
||||||
namespace Orchard.Tests.Events {
|
namespace Orchard.Tests.Events {
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -18,6 +19,7 @@ namespace Orchard.Tests.Events {
|
|||||||
|
|
||||||
var builder = new ContainerBuilder();
|
var builder = new ContainerBuilder();
|
||||||
builder.RegisterType<DefaultOrchardEventBus>().As<IEventBus>();
|
builder.RegisterType<DefaultOrchardEventBus>().As<IEventBus>();
|
||||||
|
builder.RegisterType<StubExceptionPolicy>().As<IExceptionPolicy>();
|
||||||
builder.RegisterType<StubEventHandler2>().As<IEventHandler>();
|
builder.RegisterType<StubEventHandler2>().As<IEventHandler>();
|
||||||
builder.RegisterInstance(_eventHandler).As<IEventHandler>();
|
builder.RegisterInstance(_eventHandler).As<IEventHandler>();
|
||||||
|
|
||||||
@@ -229,4 +231,10 @@ namespace Orchard.Tests.Events {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class StubExceptionPolicy : IExceptionPolicy {
|
||||||
|
public bool HandleException(object sender, Exception exception) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,52 +128,47 @@ namespace Orchard.Core.Contents.Controllers {
|
|||||||
[HttpPost, ActionName("List")]
|
[HttpPost, ActionName("List")]
|
||||||
[FormValueRequired("submit.BulkEdit")]
|
[FormValueRequired("submit.BulkEdit")]
|
||||||
public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds, string returnUrl) {
|
public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds, string returnUrl) {
|
||||||
try {
|
if (itemIds != null) {
|
||||||
if (itemIds != null) {
|
switch (options.BulkAction) {
|
||||||
switch (options.BulkAction) {
|
case ContentsBulkAction.None:
|
||||||
case ContentsBulkAction.None:
|
break;
|
||||||
break;
|
case ContentsBulkAction.PublishNow:
|
||||||
case ContentsBulkAction.PublishNow:
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content."))) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content."))) {
|
_transactionManager.Cancel();
|
||||||
_transactionManager.Cancel();
|
return new HttpUnauthorizedResult();
|
||||||
return new HttpUnauthorizedResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
_contentManager.Publish(item);
|
|
||||||
}
|
}
|
||||||
Services.Notifier.Information(T("Content successfully published."));
|
|
||||||
break;
|
|
||||||
case ContentsBulkAction.Unpublish:
|
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
|
||||||
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content."))) {
|
|
||||||
_transactionManager.Cancel();
|
|
||||||
return new HttpUnauthorizedResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
_contentManager.Unpublish(item);
|
_contentManager.Publish(item);
|
||||||
|
}
|
||||||
|
Services.Notifier.Information(T("Content successfully published."));
|
||||||
|
break;
|
||||||
|
case ContentsBulkAction.Unpublish:
|
||||||
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
|
if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content."))) {
|
||||||
|
_transactionManager.Cancel();
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
}
|
}
|
||||||
Services.Notifier.Information(T("Content successfully unpublished."));
|
|
||||||
break;
|
|
||||||
case ContentsBulkAction.Remove:
|
|
||||||
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
|
||||||
if (!Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content."))) {
|
|
||||||
_transactionManager.Cancel();
|
|
||||||
return new HttpUnauthorizedResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
_contentManager.Remove(item);
|
_contentManager.Unpublish(item);
|
||||||
|
}
|
||||||
|
Services.Notifier.Information(T("Content successfully unpublished."));
|
||||||
|
break;
|
||||||
|
case ContentsBulkAction.Remove:
|
||||||
|
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
|
||||||
|
if (!Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content."))) {
|
||||||
|
_transactionManager.Cancel();
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
}
|
}
|
||||||
Services.Notifier.Information(T("Content successfully removed."));
|
|
||||||
break;
|
_contentManager.Remove(item);
|
||||||
default:
|
}
|
||||||
throw new ArgumentOutOfRangeException();
|
Services.Notifier.Information(T("Content successfully removed."));
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
|
||||||
_transactionManager.Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("List"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("List"));
|
||||||
}
|
}
|
||||||
|
@@ -21,38 +21,32 @@ namespace Orchard.Core.HomePage.Controllers {
|
|||||||
|
|
||||||
[Themed]
|
[Themed]
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
try {
|
var homepage = _orchardServices.WorkContext.CurrentSite.HomePage;
|
||||||
var homepage = _orchardServices.WorkContext.CurrentSite.HomePage;
|
if (String.IsNullOrEmpty(homepage))
|
||||||
if (String.IsNullOrEmpty(homepage))
|
return View();
|
||||||
return View();
|
|
||||||
|
|
||||||
var homePageParameters = homepage.Split(';');
|
var homePageParameters = homepage.Split(';');
|
||||||
if (homePageParameters.Length != 2)
|
if (homePageParameters.Length != 2)
|
||||||
return View();
|
return View();
|
||||||
|
|
||||||
var providerName = homePageParameters[0];
|
var providerName = homePageParameters[0];
|
||||||
var item = Int32.Parse(homePageParameters[1]);
|
var item = Int32.Parse(homePageParameters[1]);
|
||||||
|
|
||||||
foreach (var provider in _homePageProviders) {
|
foreach (var provider in _homePageProviders) {
|
||||||
if (!string.Equals(provider.GetProviderName(), providerName))
|
if (!string.Equals(provider.GetProviderName(), providerName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var result = provider.GetHomePage(item);
|
var result = provider.GetHomePage(item);
|
||||||
if (result is ViewResultBase) {
|
if (result is ViewResultBase) {
|
||||||
var resultBase = result as ViewResultBase;
|
var resultBase = result as ViewResultBase;
|
||||||
ViewData.Model = resultBase.ViewData.Model;
|
ViewData.Model = resultBase.ViewData.Model;
|
||||||
resultBase.ViewData = ViewData;
|
resultBase.ViewData = ViewData;
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return View();
|
return result;
|
||||||
}
|
|
||||||
catch {
|
|
||||||
return View();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,8 +1,6 @@
|
|||||||
<div>
|
<div>
|
||||||
<h1 id="page-title">@Html.TitleForPage(T("Oops. Something went wrong ... sorry"))</h1>
|
<h1 id="page-title">@Html.TitleForPage(T("Oops. Something went wrong ... sorry"))</h1>
|
||||||
<div>
|
<div>
|
||||||
<p>@T("An unhandled exception has occurred. The exception message was : {0}", @Model.Message).Text</p>
|
<p>@T("An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back").Text</p>
|
||||||
<br />
|
|
||||||
<p>@T("Please refresh the page. If the error persists, go back.").Text</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -9,7 +9,6 @@ using Orchard.Media.Models;
|
|||||||
using Orchard.Media.Services;
|
using Orchard.Media.Services;
|
||||||
using Orchard.Media.ViewModels;
|
using Orchard.Media.ViewModels;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
using Orchard.Utility.Extensions;
|
|
||||||
|
|
||||||
namespace Orchard.Media.Controllers {
|
namespace Orchard.Media.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
@@ -197,7 +196,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
try {
|
try {
|
||||||
_mediaService.UploadMediaFile(viewModel.MediaPath, Request.Files[fileName], viewModel.ExtractZip);
|
_mediaService.UploadMediaFile(viewModel.MediaPath, Request.Files[fileName], viewModel.ExtractZip);
|
||||||
}
|
}
|
||||||
catch (ArgumentException argumentException) {
|
catch (ArgumentException) {
|
||||||
Services.Notifier.Error(T("Uploading media file failed:"));
|
Services.Notifier.Error(T("Uploading media file failed:"));
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
@@ -277,7 +276,7 @@ namespace Orchard.Media.Controllers {
|
|||||||
try {
|
try {
|
||||||
_mediaService.RenameFile(viewModel.MediaPath, viewModel.Name, input["NewName"]);
|
_mediaService.RenameFile(viewModel.MediaPath, viewModel.Name, input["NewName"]);
|
||||||
}
|
}
|
||||||
catch (ArgumentException argumentException) {
|
catch (ArgumentException) {
|
||||||
Services.Notifier.Error(T("Editing media file failed."));
|
Services.Notifier.Error(T("Editing media file failed."));
|
||||||
return EditMedia(viewModel);
|
return EditMedia(viewModel);
|
||||||
}
|
}
|
||||||
|
@@ -154,7 +154,7 @@ namespace Orchard.Modules.Controllers {
|
|||||||
_dataMigrationManager.Update(id);
|
_dataMigrationManager.Update(id);
|
||||||
Services.Notifier.Information(T("The feature {0} was updated successfully", id));
|
Services.Notifier.Information(T("The feature {0} was updated successfully", id));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
this.Error(exception, T("An error occured while updating the feature {0}: {1}", id, exception.Message), Logger, Services.Notifier);
|
Services.Notifier.Error(T("An error occured while updating the feature {0}: {1}", id, exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Features");
|
return RedirectToAction("Features");
|
||||||
|
@@ -8,6 +8,7 @@ using Orchard.Logging;
|
|||||||
using Orchard.MultiTenancy.Services;
|
using Orchard.MultiTenancy.Services;
|
||||||
using Orchard.MultiTenancy.ViewModels;
|
using Orchard.MultiTenancy.ViewModels;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
|
using Orchard.UI.Notify;
|
||||||
using Orchard.Utility.Extensions;
|
using Orchard.Utility.Extensions;
|
||||||
|
|
||||||
namespace Orchard.MultiTenancy.Controllers {
|
namespace Orchard.MultiTenancy.Controllers {
|
||||||
@@ -74,8 +75,8 @@ namespace Orchard.MultiTenancy.Controllers {
|
|||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (ArgumentException exception) {
|
||||||
this.Error(exception, T("Creating Tenant failed: {0}", exception.Message), Logger, Services.Notifier);
|
Services.Notifier.Error(T("Creating Tenant failed: {0}", exception.Message));
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +138,7 @@ namespace Orchard.MultiTenancy.Controllers {
|
|||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
this.Error(exception, T("Failed to edit tenant: {0} ", exception.Message), Logger, Services.Notifier);
|
Services.Notifier.Error(T("Failed to edit tenant: {0} ", exception.Message));
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -84,45 +84,39 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
if (!String.IsNullOrEmpty(url)) {
|
||||||
if (!String.IsNullOrEmpty(url)) {
|
if (!url.StartsWith("http")) {
|
||||||
if (!url.StartsWith("http")) {
|
ModelState.AddModelError("Url", T("The Url is not valid").Text);
|
||||||
ModelState.AddModelError("Url", T("The Url is not valid").Text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (String.IsNullOrWhiteSpace(url)) {
|
|
||||||
ModelState.AddModelError("Url", T("Url is required").Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
string title = null;
|
|
||||||
// try to load the feed
|
|
||||||
try {
|
|
||||||
|
|
||||||
XNamespace atomns = "http://www.w3.org/2005/Atom";
|
|
||||||
var feed = XDocument.Load(url, LoadOptions.PreserveWhitespace);
|
|
||||||
var titleNode = feed.Descendants(atomns + "title").FirstOrDefault();
|
|
||||||
if (titleNode != null)
|
|
||||||
title = titleNode.Value;
|
|
||||||
|
|
||||||
if (String.IsNullOrWhiteSpace(title)) {
|
|
||||||
ModelState.AddModelError("Url", T("The feed has no title.").Text);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
ModelState.AddModelError("Url", T("The url of the feed or its content is not valid.").Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
|
||||||
return View(new PackagingAddSourceViewModel { Url = url });
|
|
||||||
|
|
||||||
_packagingSourceManager.AddSource(title, url);
|
|
||||||
Services.Notifier.Information(T("The feed has been added successfully."));
|
|
||||||
|
|
||||||
return RedirectToAction("Sources");
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Adding feed failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
return View(new PackagingAddSourceViewModel { Url = url });
|
|
||||||
}
|
}
|
||||||
|
else if (String.IsNullOrWhiteSpace(url)) {
|
||||||
|
ModelState.AddModelError("Url", T("Url is required").Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
string title = null;
|
||||||
|
// try to load the feed
|
||||||
|
try {
|
||||||
|
XNamespace atomns = "http://www.w3.org/2005/Atom";
|
||||||
|
var feed = XDocument.Load(url, LoadOptions.PreserveWhitespace);
|
||||||
|
var titleNode = feed.Descendants(atomns + "title").FirstOrDefault();
|
||||||
|
if (titleNode != null)
|
||||||
|
title = titleNode.Value;
|
||||||
|
|
||||||
|
if (String.IsNullOrWhiteSpace(title)) {
|
||||||
|
ModelState.AddModelError("Url", T("The feed has no title.").Text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
ModelState.AddModelError("Url", T("The url of the feed or its content is not valid.").Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
return View(new PackagingAddSourceViewModel { Url = url });
|
||||||
|
|
||||||
|
_packagingSourceManager.AddSource(title, url);
|
||||||
|
Services.Notifier.Information(T("The feed has been added successfully."));
|
||||||
|
|
||||||
|
return RedirectToAction("Sources");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Modules(PackagingExtensionsOptions options, PagerParameters pagerParameters) {
|
public ActionResult Modules(PackagingExtensionsOptions options, PagerParameters pagerParameters) {
|
||||||
@@ -209,8 +203,9 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
extensions = extensions.Take(pager.PageSize);
|
extensions = extensions.Take(pager.PageSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception exception) {
|
}
|
||||||
this.Error(exception, T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, exception.Message), Logger, Services.Notifier);
|
catch (Exception exception) {
|
||||||
|
Services.Notifier.Error(T("Error loading extensions from gallery source '{0}'. {1}.", source.FeedTitle, exception.Message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -103,17 +103,18 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to add sources")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
||||||
var source = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
|
if (source == null) {
|
||||||
if (source == null) {
|
return HttpNotFound();
|
||||||
return HttpNotFound();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
try {
|
||||||
PackageInfo packageInfo = _packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
|
PackageInfo packageInfo = _packageManager.Install(packageId, version, source.FeedUrl, HostingEnvironment.MapPath("~/"));
|
||||||
|
|
||||||
if (DefaultExtensionTypes.IsTheme(packageInfo.ExtensionType)) {
|
if (DefaultExtensionTypes.IsTheme(packageInfo.ExtensionType)) {
|
||||||
Services.Notifier.Information(T("The theme has been successfully installed. It can be enabled in the \"Themes\" page accessible from the menu."));
|
Services.Notifier.Information(T("The theme has been successfully installed. It can be enabled in the \"Themes\" page accessible from the menu."));
|
||||||
} else if (DefaultExtensionTypes.IsModule(packageInfo.ExtensionType)) {
|
}
|
||||||
|
else if (DefaultExtensionTypes.IsModule(packageInfo.ExtensionType)) {
|
||||||
Services.Notifier.Information(T("The module has been successfully installed."));
|
Services.Notifier.Information(T("The module has been successfully installed."));
|
||||||
|
|
||||||
IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource(source.FeedUrl, "Default"));
|
IPackageRepository packageRepository = PackageRepositoryFactory.Default.CreateRepository(new PackageSource(source.FeedUrl, "Default"));
|
||||||
@@ -123,8 +124,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
return InstallPackageDetails(extensionDescriptor, redirectUrl);
|
return InstallPackageDetails(extensionDescriptor, redirectUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception) {
|
||||||
this.Error(exception, T("Package installation failed."), Logger, Services.Notifier);
|
Services.Notifier.Error(T("Package installation failed."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect(redirectUrl);
|
return Redirect(redirectUrl);
|
||||||
@@ -134,14 +135,13 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
|
if (_shellSettings.Name != ShellSettings.DefaultName || !Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to install packages")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
if (Request.Files == null ||
|
||||||
|
Request.Files.Count == 0 ||
|
||||||
|
string.IsNullOrWhiteSpace(Request.Files.Get(0).FileName)) {
|
||||||
|
|
||||||
|
throw new OrchardException(T("Select a file to upload."));
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (Request.Files == null ||
|
|
||||||
Request.Files.Count == 0 ||
|
|
||||||
string.IsNullOrWhiteSpace(Request.Files.Get(0).FileName)) {
|
|
||||||
|
|
||||||
throw new OrchardException(T("Select a file to upload."));
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpPostedFileBase file = Request.Files.Get(0);
|
HttpPostedFileBase file = Request.Files.Get(0);
|
||||||
string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, Path.GetFileName(file.FileName)).Replace(Path.DirectorySeparatorChar, '/');
|
string fullFileName = Path.Combine(_appDataFolderRoot.RootFolder, Path.GetFileName(file.FileName)).Replace(Path.DirectorySeparatorChar, '/');
|
||||||
file.SaveAs(fullFileName);
|
file.SaveAs(fullFileName);
|
||||||
@@ -158,8 +158,8 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
return InstallPackageDetails(extensionDescriptor, redirectUrl);
|
return InstallPackageDetails(extensionDescriptor, redirectUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception) {
|
||||||
this.Error(exception, T("Package uploading and installation failed."), Logger, Services.Notifier);
|
Services.Notifier.Error(T("Package uploading and installation failed."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect(redirectUrl);
|
return Redirect(redirectUrl);
|
||||||
@@ -210,7 +210,7 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
_recipeManager.Execute(recipe);
|
_recipeManager.Execute(recipe);
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Services.Notifier.Error(T("Recipes contains {0} unsuported module installation steps.", recipe.Name));
|
Services.Notifier.Error(T("Recipes contains {0} unsupported module installation steps.", recipe.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,15 +237,14 @@ namespace Orchard.Packaging.Controllers {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
|
_packageManager.Uninstall(id, HostingEnvironment.MapPath("~/"));
|
||||||
|
}
|
||||||
_notifier.Information(T("Uninstalled package \"{0}\"", id));
|
catch (Exception exception) {
|
||||||
|
Services.Notifier.Error(T("Uninstall failed: {0}", exception.Message));
|
||||||
return this.RedirectLocal(returnUrl, "~/");
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Uninstall failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
return Redirect(retryUrl);
|
return Redirect(retryUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Services.Notifier.Information(T("Uninstalled package \"{0}\"", id));
|
||||||
|
return this.RedirectLocal(returnUrl, "~/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -50,19 +50,13 @@ namespace Orchard.Roles.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
foreach (string key in Request.Form.Keys) {
|
||||||
foreach (string key in Request.Form.Keys) {
|
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
||||||
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
int roleId = Convert.ToInt32(key.Substring("Checkbox.".Length));
|
||||||
int roleId = Convert.ToInt32(key.Substring("Checkbox.".Length));
|
_roleService.DeleteRole(roleId);
|
||||||
_roleService.DeleteRole(roleId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return RedirectToAction("Index");
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Deleting Role failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
return View();
|
|
||||||
}
|
}
|
||||||
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Create() {
|
public ActionResult Create() {
|
||||||
@@ -79,29 +73,23 @@ namespace Orchard.Roles.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var viewModel = new RoleCreateViewModel();
|
var viewModel = new RoleCreateViewModel();
|
||||||
try {
|
UpdateModel(viewModel);
|
||||||
UpdateModel(viewModel);
|
|
||||||
|
|
||||||
//check if the role name already exists
|
|
||||||
if (!_roleService.VerifyRoleUnicity(viewModel.Name)) {
|
|
||||||
Services.Notifier.Error(T("Creating Role {0} failed: Role with same name already exists", viewModel.Name));
|
|
||||||
return RedirectToAction("Create");
|
|
||||||
}
|
|
||||||
|
|
||||||
_roleService.CreateRole(viewModel.Name);
|
|
||||||
foreach (string key in Request.Form.Keys) {
|
|
||||||
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
|
||||||
string permissionName = key.Substring("Checkbox.".Length);
|
|
||||||
_roleService.CreatePermissionForRole(viewModel.Name,
|
|
||||||
permissionName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Creating Role failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
|
//check if the role name already exists
|
||||||
|
if (!_roleService.VerifyRoleUnicity(viewModel.Name)) {
|
||||||
|
Services.Notifier.Error(T("Creating Role {0} failed: Role with same name already exists", viewModel.Name));
|
||||||
return RedirectToAction("Create");
|
return RedirectToAction("Create");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_roleService.CreateRole(viewModel.Name);
|
||||||
|
foreach (string key in Request.Form.Keys) {
|
||||||
|
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
||||||
|
string permissionName = key.Substring("Checkbox.".Length);
|
||||||
|
_roleService.CreatePermissionForRole(viewModel.Name,
|
||||||
|
permissionName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult Edit(int id) {
|
public ActionResult Edit(int id) {
|
||||||
@@ -135,25 +123,19 @@ namespace Orchard.Roles.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var viewModel = new RoleEditViewModel();
|
var viewModel = new RoleEditViewModel();
|
||||||
try {
|
UpdateModel(viewModel);
|
||||||
UpdateModel(viewModel);
|
// Save
|
||||||
// Save
|
List<string> rolePermissions = new List<string>();
|
||||||
List<string> rolePermissions = new List<string>();
|
foreach (string key in Request.Form.Keys) {
|
||||||
foreach (string key in Request.Form.Keys) {
|
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
||||||
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
|
string permissionName = key.Substring("Checkbox.".Length);
|
||||||
string permissionName = key.Substring("Checkbox.".Length);
|
rolePermissions.Add(permissionName);
|
||||||
rolePermissions.Add(permissionName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_roleService.UpdateRole(viewModel.Id, viewModel.Name, rolePermissions);
|
|
||||||
|
|
||||||
Services.Notifier.Information(T("Your Role has been saved."));
|
|
||||||
return RedirectToAction("Edit", new { id });
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Editing Role failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
return RedirectToAction("Edit", id);
|
|
||||||
}
|
}
|
||||||
|
_roleService.UpdateRole(viewModel.Id, viewModel.Name, rolePermissions);
|
||||||
|
|
||||||
|
Services.Notifier.Information(T("Your Role has been saved."));
|
||||||
|
return RedirectToAction("Edit", new { id });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Edit")]
|
[HttpPost, ActionName("Edit")]
|
||||||
@@ -167,17 +149,10 @@ namespace Orchard.Roles.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
|
if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage roles")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
_roleService.DeleteRole(id);
|
||||||
_roleService.DeleteRole(id);
|
Services.Notifier.Information(T("Role was successfully deleted."));
|
||||||
|
|
||||||
Services.Notifier.Information(T("Role was successfully deleted."));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Editing Role failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
return RedirectToAction("Edit", id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -57,7 +57,8 @@ namespace Orchard.Search.Controllers {
|
|||||||
searchFields,
|
searchFields,
|
||||||
searchHit => searchHit);
|
searchHit => searchHit);
|
||||||
} catch(Exception exception) {
|
} catch(Exception exception) {
|
||||||
this.Error(exception, T("Invalid search query: {0}", exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("Invalid search query: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Invalid search query: {0}", exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = Shape.List();
|
var list = Shape.List();
|
||||||
|
@@ -124,8 +124,9 @@ namespace Orchard.Setup.Controllers {
|
|||||||
|
|
||||||
// redirect to the welcome page.
|
// redirect to the welcome page.
|
||||||
return Redirect("~/");
|
return Redirect("~/");
|
||||||
} catch (Exception exception) {
|
} catch (Exception) {
|
||||||
this.Error(exception, T("Setup failed:"), Logger, _notifier);
|
Logger.Error(T("Setup failed:").Text);
|
||||||
|
_notifier.Error(T("Setup failed:"));
|
||||||
|
|
||||||
model.Recipes = recipes;
|
model.Recipes = recipes;
|
||||||
foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) {
|
foreach (var recipe in recipes.Where(recipe => recipe.Name == model.Recipe)) {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
@@ -221,7 +221,8 @@ namespace Orchard.Themes.Controllers {
|
|||||||
_dataMigrationManager.Update(themeId);
|
_dataMigrationManager.Update(themeId);
|
||||||
Services.Notifier.Information(T("The theme {0} was updated succesfuly", themeId));
|
Services.Notifier.Information(T("The theme {0} was updated succesfuly", themeId));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
this.Error(exception, T("An error occured while updating the theme {0}: {1}", themeId, exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("An error occured while updating the theme {0}: {1}", themeId, exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("An error occured while updating the theme {0}: {1}", themeId, exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
|
@@ -95,17 +95,12 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
if (!string.IsNullOrWhiteSpace(moveUp))
|
||||||
if (!string.IsNullOrWhiteSpace(moveUp))
|
_widgetsService.MoveWidgetUp(widgetId);
|
||||||
_widgetsService.MoveWidgetUp(widgetId);
|
else if (!string.IsNullOrWhiteSpace(moveDown))
|
||||||
else if (!string.IsNullOrWhiteSpace(moveDown))
|
_widgetsService.MoveWidgetDown(widgetId);
|
||||||
_widgetsService.MoveWidgetDown(widgetId);
|
else if (!string.IsNullOrWhiteSpace(moveHere))
|
||||||
else if (!string.IsNullOrWhiteSpace(moveHere))
|
_widgetsService.MoveWidgetToLayer(widgetId, layerId);
|
||||||
_widgetsService.MoveWidgetToLayer(widgetId, layerId);
|
|
||||||
}
|
|
||||||
catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Moving widget failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
}
|
}
|
||||||
@@ -147,11 +142,10 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
WidgetPart widgetPart = Services.ContentManager.New<WidgetPart>(widgetType);
|
||||||
|
if (widgetPart == null)
|
||||||
|
return HttpNotFound();
|
||||||
try {
|
try {
|
||||||
WidgetPart widgetPart = Services.ContentManager.New<WidgetPart>(widgetType);
|
|
||||||
if (widgetPart == null)
|
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
int widgetPosition = _widgetsService.GetWidgets().Where(widget => widget.Zone == widgetPart.Zone).Count() + 1;
|
int widgetPosition = _widgetsService.GetWidgets().Where(widget => widget.Zone == widgetPart.Zone).Count() + 1;
|
||||||
widgetPart.Position = widgetPosition.ToString();
|
widgetPart.Position = widgetPosition.ToString();
|
||||||
widgetPart.Zone = zone;
|
widgetPart.Zone = zone;
|
||||||
@@ -161,7 +155,8 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return View((object)model);
|
return View((object)model);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
this.Error(exception, T("Creating widget failed: {0}", exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("Creating widget failed: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Creating widget failed: {0}", exception.Message));
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,24 +166,27 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", "", "");
|
||||||
WidgetPart widgetPart = _widgetsService.CreateWidget(layerId, widgetType, "", "", "");
|
if (widgetPart == null)
|
||||||
if (widgetPart == null)
|
return HttpNotFound();
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
|
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
|
||||||
|
try {
|
||||||
// override the CommonPart's persisting of the current container
|
// override the CommonPart's persisting of the current container
|
||||||
widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
|
widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
|
||||||
if (!ModelState.IsValid) {
|
|
||||||
Services.TransactionManager.Cancel();
|
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
|
||||||
return View((object)model);
|
|
||||||
}
|
|
||||||
|
|
||||||
Services.Notifier.Information(T("Your {0} has been added.", widgetPart.TypeDefinition.DisplayName));
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Creating widget failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
}
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
Logger.Error(T("Creating widget failed: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Creating widget failed: {0}", exception.Message));
|
||||||
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
|
}
|
||||||
|
if (!ModelState.IsValid) {
|
||||||
|
Services.TransactionManager.Cancel();
|
||||||
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
|
return View((object)model);
|
||||||
|
}
|
||||||
|
|
||||||
|
Services.Notifier.Information(T("Your {0} has been added.", widgetPart.TypeDefinition.DisplayName));
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
}
|
}
|
||||||
@@ -197,27 +195,22 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
LayerPart layerPart = Services.ContentManager.New<LayerPart>("Layer");
|
||||||
LayerPart layerPart = Services.ContentManager.New<LayerPart>("Layer");
|
if (layerPart == null)
|
||||||
if (layerPart == null)
|
return HttpNotFound();
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
dynamic model = Services.ContentManager.BuildEditor(layerPart);
|
dynamic model = Services.ContentManager.BuildEditor(layerPart);
|
||||||
|
|
||||||
// only messing with the hints if they're given
|
// only messing with the hints if they're given
|
||||||
if (!string.IsNullOrWhiteSpace(name))
|
if (!string.IsNullOrWhiteSpace(name))
|
||||||
model.Name = name;
|
model.Name = name;
|
||||||
if (!string.IsNullOrWhiteSpace(description))
|
if (!string.IsNullOrWhiteSpace(description))
|
||||||
model.Description = description;
|
model.Description = description;
|
||||||
if (!string.IsNullOrWhiteSpace(layerRule))
|
if (!string.IsNullOrWhiteSpace(layerRule))
|
||||||
model.LayerRule = layerRule;
|
model.LayerRule = layerRule;
|
||||||
|
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)model);
|
return View((object)model);
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Creating layer failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("AddLayer")]
|
[HttpPost, ActionName("AddLayer")]
|
||||||
@@ -225,44 +218,33 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
LayerPart layerPart = _widgetsService.CreateLayer("", "", "");
|
||||||
LayerPart layerPart = _widgetsService.CreateLayer("", "", "");
|
if (layerPart == null)
|
||||||
if (layerPart == null)
|
return HttpNotFound();
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
var model = Services.ContentManager.UpdateEditor(layerPart, this);
|
var model = Services.ContentManager.UpdateEditor(layerPart, this);
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
Services.TransactionManager.Cancel();
|
Services.TransactionManager.Cancel();
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)model);
|
return View((object)model);
|
||||||
}
|
|
||||||
|
|
||||||
Services.Notifier.Information(T("Your {0} has been created.", layerPart.TypeDefinition.DisplayName));
|
|
||||||
return RedirectToAction("Index", "Admin", new { layerId = layerPart.Id });
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Creating layer failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Services.Notifier.Information(T("Your {0} has been created.", layerPart.TypeDefinition.DisplayName));
|
||||||
|
return RedirectToAction("Index", "Admin", new { layerId = layerPart.Id });
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult EditLayer(int id) {
|
public ActionResult EditLayer(int id) {
|
||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
LayerPart layerPart = _widgetsService.GetLayer(id);
|
||||||
LayerPart layerPart = _widgetsService.GetLayer(id);
|
if (layerPart == null)
|
||||||
if (layerPart == null)
|
return HttpNotFound();
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
dynamic model = Services.ContentManager.BuildEditor(layerPart);
|
dynamic model = Services.ContentManager.BuildEditor(layerPart);
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)model);
|
return View((object)model);
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Editing layer failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
|
|
||||||
return RedirectToAction("Index", "Admin");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("EditLayer")]
|
[HttpPost, ActionName("EditLayer")]
|
||||||
@@ -271,24 +253,20 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
if (!Services.Authorizer.Authorize(Permissions.ManageWidgets, T(NotAuthorizedManageWidgetsLabel)))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
try {
|
LayerPart layerPart = _widgetsService.GetLayer(id);
|
||||||
LayerPart layerPart = _widgetsService.GetLayer(id);
|
if (layerPart == null)
|
||||||
if (layerPart == null)
|
return HttpNotFound();
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
var model = Services.ContentManager.UpdateEditor(layerPart, this);
|
var model = Services.ContentManager.UpdateEditor(layerPart, this);
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
Services.TransactionManager.Cancel();
|
Services.TransactionManager.Cancel();
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)model);
|
return View((object)model);
|
||||||
}
|
|
||||||
|
|
||||||
Services.Notifier.Information(T("Your {0} has been saved.", layerPart.TypeDefinition.DisplayName));
|
|
||||||
} catch (Exception exception) {
|
|
||||||
this.Error(exception, T("Editing layer failed: {0}", exception.Message), Logger, Services.Notifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Services.Notifier.Information(T("Your {0} has been saved.", layerPart.TypeDefinition.DisplayName));
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +280,8 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
_widgetsService.DeleteLayer(id);
|
_widgetsService.DeleteLayer(id);
|
||||||
Services.Notifier.Information(T("Layer was successfully deleted"));
|
Services.Notifier.Information(T("Layer was successfully deleted"));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
this.Error(exception, T("Removing Layer failed: {0}", exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("Removing Layer failed: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Removing Layer failed: {0}", exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return RedirectToAction("Index", "Admin");
|
return RedirectToAction("Index", "Admin");
|
||||||
@@ -313,19 +292,19 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = null;
|
WidgetPart widgetPart = null;
|
||||||
|
widgetPart = _widgetsService.GetWidget(id);
|
||||||
|
if (widgetPart == null) {
|
||||||
|
Services.Notifier.Error(T("Widget not found: {0}", id));
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
widgetPart = _widgetsService.GetWidget(id);
|
|
||||||
if (widgetPart == null) {
|
|
||||||
Services.Notifier.Error(T("Widget not found: {0}", id));
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
}
|
|
||||||
|
|
||||||
dynamic model = Services.ContentManager.BuildEditor(widgetPart);
|
dynamic model = Services.ContentManager.BuildEditor(widgetPart);
|
||||||
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
// Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
|
||||||
return View((object)model);
|
return View((object)model);
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
this.Error(exception, T("Editing widget failed: {0}", exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("Editing widget failed: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Editing widget failed: {0}", exception.Message));
|
||||||
|
|
||||||
if (widgetPart != null && widgetPart.LayerPart != null)
|
if (widgetPart != null && widgetPart.LayerPart != null)
|
||||||
return RedirectToAction("Index", "Admin", new { layerId = widgetPart.LayerPart.Id });
|
return RedirectToAction("Index", "Admin", new { layerId = widgetPart.LayerPart.Id });
|
||||||
@@ -341,11 +320,10 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = null;
|
WidgetPart widgetPart = null;
|
||||||
|
widgetPart = _widgetsService.GetWidget(id);
|
||||||
|
if (widgetPart == null)
|
||||||
|
return HttpNotFound();
|
||||||
try {
|
try {
|
||||||
widgetPart = _widgetsService.GetWidget(id);
|
|
||||||
if (widgetPart == null)
|
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
|
var model = Services.ContentManager.UpdateEditor(widgetPart, this);
|
||||||
// override the CommonPart's persisting of the current container
|
// override the CommonPart's persisting of the current container
|
||||||
widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
|
widgetPart.LayerPart = _widgetsService.GetLayer(layerId);
|
||||||
@@ -357,7 +335,8 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
|
|
||||||
Services.Notifier.Information(T("Your {0} has been saved.", widgetPart.TypeDefinition.DisplayName));
|
Services.Notifier.Information(T("Your {0} has been saved.", widgetPart.TypeDefinition.DisplayName));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
this.Error(exception, T("Editing widget failed: {0}", exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("Editing widget failed: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Editing widget failed: {0}", exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
@@ -373,16 +352,16 @@ namespace Orchard.Widgets.Controllers {
|
|||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
WidgetPart widgetPart = null;
|
WidgetPart widgetPart = null;
|
||||||
|
widgetPart = _widgetsService.GetWidget(id);
|
||||||
|
if (widgetPart == null)
|
||||||
|
return HttpNotFound();
|
||||||
try {
|
try {
|
||||||
widgetPart = _widgetsService.GetWidget(id);
|
|
||||||
if (widgetPart == null)
|
|
||||||
return HttpNotFound();
|
|
||||||
|
|
||||||
_widgetsService.DeleteWidget(widgetPart.Id);
|
_widgetsService.DeleteWidget(widgetPart.Id);
|
||||||
Services.Notifier.Information(T("Widget was successfully deleted"));
|
Services.Notifier.Information(T("Widget was successfully deleted"));
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
this.Error(exception, T("Removing Widget failed: {0}", exception.Message), Logger, Services.Notifier);
|
Logger.Error(T("Removing Widget failed: {0}", exception.Message).Text);
|
||||||
|
Services.Notifier.Error(T("Removing Widget failed: {0}", exception.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
return this.RedirectLocal(returnUrl, () => RedirectToAction("Index"));
|
||||||
|
@@ -16,6 +16,7 @@ using Orchard.Environment.ShellBuilders;
|
|||||||
using Orchard.Environment.State;
|
using Orchard.Environment.State;
|
||||||
using Orchard.Environment.Descriptor;
|
using Orchard.Environment.Descriptor;
|
||||||
using Orchard.Events;
|
using Orchard.Events;
|
||||||
|
using Orchard.Exceptions;
|
||||||
using Orchard.FileSystems.AppData;
|
using Orchard.FileSystems.AppData;
|
||||||
using Orchard.FileSystems.Dependencies;
|
using Orchard.FileSystems.Dependencies;
|
||||||
using Orchard.FileSystems.LockFile;
|
using Orchard.FileSystems.LockFile;
|
||||||
@@ -58,6 +59,7 @@ namespace Orchard.Environment {
|
|||||||
builder.RegisterType<OrchardFrameworkAssemblyNameResolver>().As<IAssemblyNameResolver>().SingleInstance();
|
builder.RegisterType<OrchardFrameworkAssemblyNameResolver>().As<IAssemblyNameResolver>().SingleInstance();
|
||||||
builder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
|
builder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
|
||||||
builder.RegisterType<ViewsBackgroundCompilation>().As<IViewsBackgroundCompilation>().SingleInstance();
|
builder.RegisterType<ViewsBackgroundCompilation>().As<IViewsBackgroundCompilation>().SingleInstance();
|
||||||
|
builder.RegisterType<DefaultExceptionPolicy>().As<IExceptionPolicy>().SingleInstance();
|
||||||
|
|
||||||
RegisterVolatileProvider<WebSiteFolder, IWebSiteFolder>(builder);
|
RegisterVolatileProvider<WebSiteFolder, IWebSiteFolder>(builder);
|
||||||
RegisterVolatileProvider<AppDataFolder, IAppDataFolder>(builder);
|
RegisterVolatileProvider<AppDataFolder, IAppDataFolder>(builder);
|
||||||
|
@@ -3,17 +3,17 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Orchard.Exceptions;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.UI.Notify;
|
|
||||||
|
|
||||||
namespace Orchard.Events {
|
namespace Orchard.Events {
|
||||||
public class DefaultOrchardEventBus : IEventBus {
|
public class DefaultOrchardEventBus : IEventBus {
|
||||||
private readonly Func<IEnumerable<IEventHandler>> _eventHandlers;
|
private readonly Func<IEnumerable<IEventHandler>> _eventHandlers;
|
||||||
private readonly INotifier _notifier;
|
private readonly IExceptionPolicy _exceptionPolicy;
|
||||||
|
|
||||||
public DefaultOrchardEventBus(Func<IEnumerable<IEventHandler>> eventHandlers) {
|
public DefaultOrchardEventBus(Func<IEnumerable<IEventHandler>> eventHandlers, IExceptionPolicy exceptionPolicy) {
|
||||||
_eventHandlers = eventHandlers;
|
_eventHandlers = eventHandlers;
|
||||||
_notifier = new Notifier();
|
_exceptionPolicy = exceptionPolicy;
|
||||||
T = NullLocalizer.Instance;
|
T = NullLocalizer.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,11 +49,10 @@ namespace Orchard.Events {
|
|||||||
try {
|
try {
|
||||||
return TryInvoke(eventHandler, interfaceName, methodName, eventData, out returnValue);
|
return TryInvoke(eventHandler, interfaceName, methodName, eventData, out returnValue);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception exception) {
|
||||||
_notifier.Error(T("{2} thrown from {0} by {1}",
|
if (!_exceptionPolicy.HandleException(this, exception)) {
|
||||||
messageName,
|
throw;
|
||||||
eventHandler.GetType().FullName,
|
}
|
||||||
ex.GetType().Name));
|
|
||||||
|
|
||||||
returnValue = null;
|
returnValue = null;
|
||||||
return false;
|
return false;
|
||||||
|
73
src/Orchard/Exceptions/DefaultExceptionPolicy.cs
Normal file
73
src/Orchard/Exceptions/DefaultExceptionPolicy.cs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
|
using System.Threading;
|
||||||
|
using Orchard.Events;
|
||||||
|
using Orchard.Localization;
|
||||||
|
using Orchard.Logging;
|
||||||
|
using Orchard.Security;
|
||||||
|
using Orchard.UI.Notify;
|
||||||
|
|
||||||
|
namespace Orchard.Exceptions {
|
||||||
|
public class DefaultExceptionPolicy : IExceptionPolicy {
|
||||||
|
private readonly INotifier _notifier;
|
||||||
|
private readonly Lazy<IAuthorizer> _authorizer;
|
||||||
|
|
||||||
|
public DefaultExceptionPolicy() {
|
||||||
|
Logger = NullLogger.Instance;
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultExceptionPolicy(INotifier notifier, Lazy<IAuthorizer> authorizer) {
|
||||||
|
_notifier = notifier;
|
||||||
|
_authorizer = authorizer;
|
||||||
|
Logger = NullLogger.Instance;
|
||||||
|
T = NullLocalizer.Instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
|
public bool HandleException(object sender, Exception exception) {
|
||||||
|
if (IsFatal(exception)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender is IEventBus && exception is OrchardFatalException) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Error(exception.Message);
|
||||||
|
|
||||||
|
do {
|
||||||
|
RaiseNotification(exception);
|
||||||
|
exception = exception.InnerException;
|
||||||
|
} while (exception != null);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsFatal(Exception exception) {
|
||||||
|
return
|
||||||
|
exception is OrchardSecurityException ||
|
||||||
|
exception is StackOverflowException ||
|
||||||
|
exception is AccessViolationException ||
|
||||||
|
exception is AppDomainUnloadedException ||
|
||||||
|
exception is ThreadAbortException ||
|
||||||
|
exception is SecurityException ||
|
||||||
|
exception is SEHException;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RaiseNotification(Exception exception) {
|
||||||
|
if (_notifier == null || _authorizer.Value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (exception is OrchardException) {
|
||||||
|
_notifier.Error((exception as OrchardException).LocalizedMessage);
|
||||||
|
}
|
||||||
|
else if (_authorizer.Value.Authorize(StandardPermissions.SiteOwner)) {
|
||||||
|
_notifier.Error(T(exception.Message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -8,12 +8,15 @@ using IFilterProvider = Orchard.Mvc.Filters.IFilterProvider;
|
|||||||
|
|
||||||
namespace Orchard.Exceptions.Filters {
|
namespace Orchard.Exceptions.Filters {
|
||||||
public class UnhandledExceptionFilter : FilterProvider, IActionFilter {
|
public class UnhandledExceptionFilter : FilterProvider, IActionFilter {
|
||||||
|
private readonly IExceptionPolicy _exceptionPolicy;
|
||||||
private readonly IOrchardServices _orchardServices;
|
private readonly IOrchardServices _orchardServices;
|
||||||
private readonly Lazy<IEnumerable<IFilterProvider>> _filterProviders;
|
private readonly Lazy<IEnumerable<IFilterProvider>> _filterProviders;
|
||||||
|
|
||||||
public UnhandledExceptionFilter(
|
public UnhandledExceptionFilter(
|
||||||
|
IExceptionPolicy exceptionPolicy,
|
||||||
IOrchardServices orchardServices,
|
IOrchardServices orchardServices,
|
||||||
Lazy<IEnumerable<IFilterProvider>> filters) {
|
Lazy<IEnumerable<IFilterProvider>> filters) {
|
||||||
|
_exceptionPolicy = exceptionPolicy;
|
||||||
_orchardServices = orchardServices;
|
_orchardServices = orchardServices;
|
||||||
_filterProviders = filters;
|
_filterProviders = filters;
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
@@ -26,30 +29,31 @@ namespace Orchard.Exceptions.Filters {
|
|||||||
|
|
||||||
public void OnActionExecuted(ActionExecutedContext filterContext) {
|
public void OnActionExecuted(ActionExecutedContext filterContext) {
|
||||||
if (!filterContext.ExceptionHandled && filterContext.Exception != null) {
|
if (!filterContext.ExceptionHandled && filterContext.Exception != null) {
|
||||||
var shape = _orchardServices.New.ErrorPage();
|
if (_exceptionPolicy.HandleException(this, filterContext.Exception)) {
|
||||||
shape.Message = filterContext.Exception.Message;
|
var shape = _orchardServices.New.ErrorPage();
|
||||||
shape.Exception = filterContext.Exception;
|
shape.Message = filterContext.Exception.Message;
|
||||||
Logger.Error(filterContext.Exception.Message);
|
shape.Exception = filterContext.Exception;
|
||||||
|
|
||||||
filterContext.ExceptionHandled = true;
|
filterContext.ExceptionHandled = true;
|
||||||
|
|
||||||
// inform exception filters of the exception that was suppressed
|
// inform exception filters of the exception that was suppressed
|
||||||
var filterInfo = new FilterInfo();
|
var filterInfo = new FilterInfo();
|
||||||
foreach (var filterProvider in _filterProviders.Value) {
|
foreach (var filterProvider in _filterProviders.Value) {
|
||||||
filterProvider.AddFilters(filterInfo);
|
filterProvider.AddFilters(filterInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
var exceptionContext = new ExceptionContext(filterContext.Controller.ControllerContext, filterContext.Exception);
|
var exceptionContext = new ExceptionContext(filterContext.Controller.ControllerContext, filterContext.Exception);
|
||||||
foreach (var exceptionFilter in filterInfo.ExceptionFilters) {
|
foreach (var exceptionFilter in filterInfo.ExceptionFilters) {
|
||||||
exceptionFilter.OnException(exceptionContext);
|
exceptionFilter.OnException(exceptionContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exceptionContext.ExceptionHandled) {
|
if (exceptionContext.ExceptionHandled) {
|
||||||
filterContext.Result = exceptionContext.Result;
|
filterContext.Result = exceptionContext.Result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
filterContext.Result = new ShapeResult(filterContext.Controller, shape);
|
filterContext.Result = new ShapeResult(filterContext.Controller, shape);
|
||||||
filterContext.RequestContext.HttpContext.Response.StatusCode = 500;
|
filterContext.RequestContext.HttpContext.Response.StatusCode = 500;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
src/Orchard/Exceptions/IExceptionPolicy.cs
Normal file
8
src/Orchard/Exceptions/IExceptionPolicy.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Orchard.Exceptions {
|
||||||
|
public interface IExceptionPolicy : ISingletonDependency {
|
||||||
|
/* return false if the exception should be rethrown by the caller */
|
||||||
|
bool HandleException(object sender, Exception exception);
|
||||||
|
}
|
||||||
|
}
|
@@ -224,7 +224,9 @@
|
|||||||
<Compile Include="Environment\WorkContextImplementation.cs" />
|
<Compile Include="Environment\WorkContextImplementation.cs" />
|
||||||
<Compile Include="Environment\WorkContextModule.cs" />
|
<Compile Include="Environment\WorkContextModule.cs" />
|
||||||
<Compile Include="Environment\WorkContextProperty.cs" />
|
<Compile Include="Environment\WorkContextProperty.cs" />
|
||||||
|
<Compile Include="Exceptions\DefaultExceptionPolicy.cs" />
|
||||||
<Compile Include="Exceptions\Filters\UnhandledExceptionFilter.cs" />
|
<Compile Include="Exceptions\Filters\UnhandledExceptionFilter.cs" />
|
||||||
|
<Compile Include="Exceptions\IExceptionPolicy.cs" />
|
||||||
<Compile Include="FileSystems\Dependencies\IExtensionDependenciesManager.cs" />
|
<Compile Include="FileSystems\Dependencies\IExtensionDependenciesManager.cs" />
|
||||||
<Compile Include="FileSystems\Dependencies\DefaultExtensionDependenciesManager.cs" />
|
<Compile Include="FileSystems\Dependencies\DefaultExtensionDependenciesManager.cs" />
|
||||||
<Compile Include="FileSystems\LockFile\ILockFile.cs" />
|
<Compile Include="FileSystems\LockFile\ILockFile.cs" />
|
||||||
@@ -251,6 +253,7 @@
|
|||||||
<Compile Include="Mvc\ShapeResult.cs" />
|
<Compile Include="Mvc\ShapeResult.cs" />
|
||||||
<Compile Include="Mvc\Spooling\HtmlStringWriter.cs" />
|
<Compile Include="Mvc\Spooling\HtmlStringWriter.cs" />
|
||||||
<Compile Include="Mvc\ViewEngines\Razor\IRazorCompilationEvents.cs" />
|
<Compile Include="Mvc\ViewEngines\Razor\IRazorCompilationEvents.cs" />
|
||||||
|
<Compile Include="OrchardFatalException.cs" />
|
||||||
<Compile Include="Recipes\Events\IRecipeSchedulerEventHandler.cs" />
|
<Compile Include="Recipes\Events\IRecipeSchedulerEventHandler.cs" />
|
||||||
<Compile Include="Recipes\Models\Recipe.cs" />
|
<Compile Include="Recipes\Models\Recipe.cs" />
|
||||||
<Compile Include="Recipes\Models\RecipeContext.cs" />
|
<Compile Include="Recipes\Models\RecipeContext.cs" />
|
||||||
@@ -531,7 +534,6 @@
|
|||||||
<Compile Include="Messaging\Services\IMessageManager.cs" />
|
<Compile Include="Messaging\Services\IMessageManager.cs" />
|
||||||
<Compile Include="Messaging\Services\IMessagingChannel.cs" />
|
<Compile Include="Messaging\Services\IMessagingChannel.cs" />
|
||||||
<Compile Include="IWorkContextAccessor.cs" />
|
<Compile Include="IWorkContextAccessor.cs" />
|
||||||
<Compile Include="Utility\Extensions\ControllerExtensions.cs" />
|
|
||||||
<Compile Include="Utility\Extensions\VirtualPathProviderExtensions.cs" />
|
<Compile Include="Utility\Extensions\VirtualPathProviderExtensions.cs" />
|
||||||
<Compile Include="Validation\PathValidation.cs" />
|
<Compile Include="Validation\PathValidation.cs" />
|
||||||
<Compile Include="Wcf\OrchardDependencyInjectionServiceBehavior.cs" />
|
<Compile Include="Wcf\OrchardDependencyInjectionServiceBehavior.cs" />
|
||||||
|
26
src/Orchard/OrchardFatalException.cs
Normal file
26
src/Orchard/OrchardFatalException.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using Orchard.Localization;
|
||||||
|
|
||||||
|
namespace Orchard {
|
||||||
|
[Serializable]
|
||||||
|
public class OrchardFatalException : Exception {
|
||||||
|
private readonly LocalizedString _localizedMessage;
|
||||||
|
|
||||||
|
public OrchardFatalException(LocalizedString message)
|
||||||
|
: base(message.Text) {
|
||||||
|
_localizedMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OrchardFatalException(LocalizedString message, Exception innerException)
|
||||||
|
: base(message.Text, innerException) {
|
||||||
|
_localizedMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected OrchardFatalException(SerializationInfo info, StreamingContext context)
|
||||||
|
: base(info, context) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalizedString LocalizedMessage { get { return _localizedMessage; } }
|
||||||
|
}
|
||||||
|
}
|
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using Orchard.Localization;
|
|
||||||
using Orchard.Logging;
|
|
||||||
using Orchard.UI.Notify;
|
|
||||||
|
|
||||||
namespace Orchard.Utility.Extensions {
|
|
||||||
public static class ControllerExtensions {
|
|
||||||
public static void Error(this Controller controller,
|
|
||||||
Exception exception,
|
|
||||||
LocalizedString localizedString,
|
|
||||||
ILogger logger,
|
|
||||||
INotifier notifier) {
|
|
||||||
|
|
||||||
logger.Error(exception, localizedString.ToString());
|
|
||||||
notifier.Error(localizedString);
|
|
||||||
|
|
||||||
for (Exception innerException = exception; innerException != null ; innerException = innerException.InnerException) {
|
|
||||||
notifier.Error(new LocalizedString(innerException.Message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user