mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Refactor OrchardException classes
All constructors now take a"LocalizedString" as the error message. --HG-- branch : dev
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Lucene.Net.Documents;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Indexing.Models {
|
||||
@@ -20,14 +21,17 @@ namespace Orchard.Indexing.Models {
|
||||
|
||||
public int ContentItemId { get; private set; }
|
||||
|
||||
public LuceneDocumentIndex(int documentId) {
|
||||
public LuceneDocumentIndex(int documentId, Localizer t) {
|
||||
Fields = new List<AbstractField>();
|
||||
SetContentItemId(documentId);
|
||||
IsDirty = false;
|
||||
|
||||
_typeCode = TypeCode.Empty;
|
||||
T = t;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public bool IsDirty { get; private set; }
|
||||
|
||||
public IDocumentIndex Add(string name, string value) {
|
||||
@@ -113,7 +117,7 @@ namespace Orchard.Indexing.Models {
|
||||
case TypeCode.Empty:
|
||||
break;
|
||||
default:
|
||||
throw new OrchardException("Unexpected index type");
|
||||
throw new OrchardException(T("Unexpected index type"));
|
||||
}
|
||||
|
||||
_removeTags = false;
|
||||
|
@@ -10,6 +10,7 @@ using Lucene.Net.Store;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.FileSystems.AppData;
|
||||
using Orchard.Indexing.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using System.Xml.Linq;
|
||||
using Directory = Lucene.Net.Store.Directory;
|
||||
@@ -29,8 +30,6 @@ namespace Orchard.Indexing.Services {
|
||||
public static readonly string Settings = "Settings";
|
||||
public static readonly string LastIndexUtc = "LastIndexedUtc";
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public LuceneIndexProvider(IAppDataFolder appDataFolder, ShellSettings shellSettings) {
|
||||
_appDataFolder = appDataFolder;
|
||||
_shellSettings = shellSettings;
|
||||
@@ -43,8 +42,14 @@ namespace Orchard.Indexing.Services {
|
||||
|
||||
// Ensures the directory exists
|
||||
EnsureDirectoryExists();
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
|
||||
public static Analyzer CreateAnalyzer() {
|
||||
// StandardAnalyzer does lower-case and stop-word filtering. It also removes punctuation
|
||||
return new StandardAnalyzer(LuceneVersion);
|
||||
@@ -189,7 +194,7 @@ namespace Orchard.Indexing.Services {
|
||||
}
|
||||
|
||||
public IDocumentIndex New(int documentId) {
|
||||
return new LuceneDocumentIndex(documentId);
|
||||
return new LuceneDocumentIndex(documentId, T);
|
||||
}
|
||||
|
||||
public ISearchBuilder CreateSearchBuilder(string indexName) {
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Roles.Models;
|
||||
@@ -20,16 +21,23 @@ namespace Orchard.Roles.Services {
|
||||
public RolesBasedAuthorizationService(IRoleService roleService, IAuthorizationServiceEventHandler authorizationServiceEventHandler) {
|
||||
_roleService = roleService;
|
||||
_authorizationServiceEventHandler = authorizationServiceEventHandler;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
public ILogger Logger { get; set; }
|
||||
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
|
||||
|
||||
|
||||
public void CheckAccess(Permission permission, IUser user, IContent content) {
|
||||
if (!TryCheckAccess(permission, user, content)) {
|
||||
throw new OrchardSecurityException { PermissionName = permission.Name };
|
||||
throw new OrchardSecurityException(T("A security exception occurred in the content management system.")) {
|
||||
PermissionName = permission.Name,
|
||||
User = user,
|
||||
Content = content
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user