Skip to content

Commit 33036f8

Browse files
committed
Fixes: U4-5789 Add native option to UmbracoExamine library to run the indexes locally
1 parent 0688550 commit 33036f8

12 files changed

+69
-122
lines changed

src/UmbracoExamine/BaseUmbracoIndexer.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,12 @@ protected BaseUmbracoIndexer()
4242
/// <param name="indexPath"></param>
4343
/// <param name="dataService"></param>
4444
/// <param name="analyzer"></param>
45-
[SecuritySafeCritical]
4645
protected BaseUmbracoIndexer(IIndexCriteria indexerData, DirectoryInfo indexPath, IDataService dataService, Analyzer analyzer, bool async)
4746
: base(indexerData, indexPath, analyzer, async)
4847
{
4948
DataService = dataService;
5049
}
5150

52-
[SecuritySafeCritical]
5351
protected BaseUmbracoIndexer(IIndexCriteria indexerData, Lucene.Net.Store.Directory luceneDirectory, IDataService dataService, Analyzer analyzer, bool async)
5452
: base(indexerData, luceneDirectory, analyzer, async)
5553
{
@@ -96,7 +94,6 @@ protected BaseUmbracoIndexer(IIndexCriteria indexerData, Lucene.Net.Store.Direct
9694
/// </summary>
9795
/// <param name="name"></param>
9896
/// <param name="config"></param>
99-
[SecuritySafeCritical]
10097
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
10198
{
10299
if (config["dataService"] != null && !string.IsNullOrEmpty(config["dataService"]))
@@ -217,7 +214,6 @@ public override void DeleteFromIndex(string nodeId)
217214
/// Returns true if the Umbraco application is in a state that we can initialize the examine indexes
218215
/// </summary>
219216
/// <returns></returns>
220-
[SecuritySafeCritical]
221217
protected bool CanInitialize()
222218
{
223219
//check the DisableInitializationCheck and ensure that it is not set to true
@@ -268,6 +264,9 @@ protected override void PerformIndexRebuild()
268264
/// <param name="type"></param>
269265
protected override void PerformIndexAll(string type)
270266
{
267+
//TODO: Fix all of this up, the whole xpath thing is horrible and was made sooooooooo long ago to only work with published content
268+
// but not it's being used for all content types and is really bad for performance.
269+
271270
if (!SupportedTypes.Contains(type))
272271
return;
273272

@@ -360,11 +359,9 @@ private void AddNodesToIndex(string xPath, string type)
360359
XDocument xDoc = GetXDocument(xPath, type);
361360
if (xDoc != null)
362361
{
363-
XElement rootNode = xDoc.Root;
364-
365-
IEnumerable<XElement> children = rootNode.Elements();
362+
var rootNode = xDoc.Root;
366363

367-
AddNodesToIndex(children, type);
364+
AddNodesToIndex(rootNode.Elements(), type);
368365
}
369366

370367
}

src/UmbracoExamine/ContentExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public static class ContentExtensions
2828
/// If the type of node is not a Document, the cacheOnly has no effect, it will use the API to return
2929
/// the xml.
3030
/// </remarks>
31-
[SecuritySafeCritical]
3231
[Obsolete("This method is no longer used and will be removed in future versions")]
3332
public static XDocument ToXDocument(this Content node, bool cacheOnly)
3433
{
@@ -52,7 +51,6 @@ public static XDocument ToXDocument(this Content node, bool cacheOnly)
5251
/// </summary>
5352
/// <param name="node"></param>
5453
/// <returns></returns>
55-
[SecuritySafeCritical]
5654
[Obsolete("This method is no longer used and will be removed in future versions")]
5755
private static XDocument ToXDocument(this Content node)
5856
{

src/UmbracoExamine/DataServices/UmbracoContentService.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,12 @@ public class UmbracoContentService : IContentService
2929

3030
private readonly ApplicationContext _applicationContext;
3131

32-
[SecuritySafeCritical]
3332
public UmbracoContentService()
3433
: this(ApplicationContext.Current)
3534
{
3635

3736
}
3837

39-
[SecuritySafeCritical]
4038
public UmbracoContentService(ApplicationContext applicationContext)
4139
{
4240
_applicationContext = applicationContext;
@@ -47,7 +45,6 @@ public UmbracoContentService(ApplicationContext applicationContext)
4745
/// </summary>
4846
/// <param name="value"></param>
4947
/// <returns></returns>
50-
[SecuritySafeCritical]
5148
public string StripHtml(string value)
5249
{
5350
return value.StripHtml();
@@ -58,7 +55,6 @@ public string StripHtml(string value)
5855
/// </summary>
5956
/// <param name="xpath"></param>
6057
/// <returns></returns>
61-
[SecuritySafeCritical]
6258
public XDocument GetPublishedContentByXPath(string xpath)
6359
{
6460
//TODO: Remove the need for this, the best way would be to remove all requirements of examine based on Xml but that
@@ -74,7 +70,7 @@ public XDocument GetPublishedContentByXPath(string xpath)
7470
/// </summary>
7571
/// <param name="xpath"></param>
7672
/// <returns></returns>
77-
[SecuritySafeCritical]
73+
7874
public XDocument GetLatestContentByXPath(string xpath)
7975
{
8076
var xmlContent = XDocument.Parse("<content></content>");
@@ -93,7 +89,7 @@ public XDocument GetLatestContentByXPath(string xpath)
9389
/// </summary>
9490
/// <param name="documentId"></param>
9591
/// <returns></returns>
96-
[SecuritySafeCritical]
92+
9793
private static XmlNode GetPage(int documentId)
9894
{
9995
var xDoc = Access.GetXmlDocumentCopy();
@@ -118,7 +114,7 @@ public bool IsProtected(int nodeId, string path)
118114
/// Returns a list of all of the user defined property names in Umbraco
119115
/// </summary>
120116
/// <returns></returns>
121-
[SecuritySafeCritical]
117+
122118
public IEnumerable<string> GetAllUserPropertyNames()
123119
{
124120
try

src/UmbracoExamine/DataServices/UmbracoLogService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public class UmbracoLogService : ILogService
1212
{
1313
public string ProviderName { get; set; }
1414

15-
[SecuritySafeCritical]
15+
1616
public void AddInfoLog(int nodeId, string msg)
1717
{
1818
LogHelper.Info<UmbracoLogService>("{0}, Provider={1}, NodeId={2}", () => msg, () => ProviderName, () => nodeId);
1919
}
2020

21-
[SecuritySafeCritical]
21+
2222
public void AddErrorLog(int nodeId, string msg)
2323
{
2424
//NOTE: not really the prettiest but since AddErrorLog is legacy code, we cannot change it now to accept a real Exception obj for
@@ -28,7 +28,7 @@ public void AddErrorLog(int nodeId, string msg)
2828
new Exception(msg));
2929
}
3030

31-
[SecuritySafeCritical]
31+
3232
public void AddVerboseLog(int nodeId, string msg)
3333
{
3434
LogHelper.Debug<UmbracoLogService>("{0}, Provider={1}, NodeId={2}", () => msg, () => ProviderName, () => nodeId);

src/UmbracoExamine/DataServices/UmbracoMediaService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public class UmbracoMediaService : IMediaService
1919
{
2020
private readonly ServiceContext _services;
2121

22-
[SecuritySafeCritical]
22+
2323
public UmbracoMediaService()
2424
: this(ApplicationContext.Current.Services)
2525
{
2626

2727
}
2828

29-
[SecuritySafeCritical]
29+
3030
public UmbracoMediaService(ServiceContext services)
3131
{
3232
_services = services;
@@ -39,7 +39,7 @@ public UmbracoMediaService(ServiceContext services)
3939
/// </summary>
4040
/// <param name="xpath"></param>
4141
/// <returns></returns>
42-
[SecuritySafeCritical]
42+
4343
public XDocument GetLatestMediaByXpath(string xpath)
4444
{
4545
var xmlMedia = XDocument.Parse("<media></media>");

src/UmbracoExamine/LocalStorage/LocalTempStorageDirectory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public override void TouchFile(string name)
4949
public override void DeleteFile(string name)
5050
{
5151
//perform on both dirs
52-
_realDirectory.DeleteFile(name);
5352
base.DeleteFile(name);
53+
_realDirectory.DeleteFile(name);
5454
}
5555

5656
/// <summary>Returns the length of a file in the directory. </summary>

src/UmbracoExamine/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828

2929
//NOTE: WE cannot make change the major version to be the same as Umbraco because of backwards compatibility, however we
3030
// will make the minor version the same as the umbraco version
31-
[assembly: AssemblyVersion("0.6.0.*")]
32-
[assembly: AssemblyFileVersion("0.6.0.*")]
33-
34-
[assembly: AllowPartiallyTrustedCallers]
31+
[assembly: AssemblyVersion("0.7.0.*")]
32+
[assembly: AssemblyFileVersion("0.7.0.*")]
3533

3634
[assembly: InternalsVisibleTo("Umbraco.Tests")]

src/UmbracoExamine/UmbracoContentIndexer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public UmbracoContentIndexer()
4747
/// <param name="indexPath"></param>
4848
/// <param name="dataService"></param>
4949
/// <param name="analyzer"></param>
50-
[SecuritySafeCritical]
50+
5151
public UmbracoContentIndexer(IIndexCriteria indexerData, DirectoryInfo indexPath, IDataService dataService, Analyzer analyzer, bool async)
5252
: base(indexerData, indexPath, dataService, analyzer, async) { }
5353

@@ -59,7 +59,7 @@ public UmbracoContentIndexer(IIndexCriteria indexerData, DirectoryInfo indexPath
5959
/// <param name="dataService"></param>
6060
/// <param name="analyzer"></param>
6161
/// <param name="async"></param>
62-
[SecuritySafeCritical]
62+
6363
public UmbracoContentIndexer(IIndexCriteria indexerData, Lucene.Net.Store.Directory luceneDirectory, IDataService dataService, Analyzer analyzer, bool async)
6464
: base(indexerData, luceneDirectory, dataService, analyzer, async) { }
6565

@@ -128,8 +128,8 @@ internal static readonly List<StaticField> IndexFieldPolicies
128128
/// <exception cref="T:System.InvalidOperationException">
129129
/// An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"/> on a provider after the provider has already been initialized.
130130
/// </exception>
131-
[SecuritySafeCritical]
132-
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
131+
132+
public override void Initialize(string name, NameValueCollection config)
133133
{
134134

135135
//check if there's a flag specifying to support unpublished content,
@@ -201,7 +201,7 @@ protected override void OnIndexingError(IndexingErrorEventArgs e)
201201
/// This ensures that the special __Raw_ fields are indexed
202202
/// </summary>
203203
/// <param name="docArgs"></param>
204-
[SecuritySafeCritical]
204+
205205
protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
206206
{
207207
var d = docArgs.Document;
@@ -363,7 +363,7 @@ public void RefreshIndexerDataFromDataService()
363363
/// ensure our special Path field is added to the collection
364364
/// </summary>
365365
/// <param name="e"></param>
366-
[SecuritySafeCritical]
366+
367367
protected override void OnGatheringNodeData(IndexingNodeDataEventArgs e)
368368
{
369369
//strip html of all users fields if we detect it has HTML in it.

src/UmbracoExamine/UmbracoExamineSearcher.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public override string Name
5454
}
5555
}
5656

57-
[SecuritySafeCritical]
57+
5858
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
5959
{
6060
if (name == null) throw new ArgumentNullException("name");
@@ -99,7 +99,7 @@ public override void Initialize(string name, System.Collections.Specialized.Name
9999
/// </summary>
100100
/// <param name="indexPath"></param>
101101
/// <param name="analyzer"></param>
102-
[SecuritySafeCritical]
102+
103103
public UmbracoExamineSearcher(DirectoryInfo indexPath, Analyzer analyzer)
104104
: base(indexPath, analyzer)
105105
{
@@ -110,7 +110,7 @@ public UmbracoExamineSearcher(DirectoryInfo indexPath, Analyzer analyzer)
110110
/// </summary>
111111
/// <param name="luceneDirectory"></param>
112112
/// <param name="analyzer"></param>
113-
[SecuritySafeCritical]
113+
114114
public UmbracoExamineSearcher(Lucene.Net.Store.Directory luceneDirectory, Analyzer analyzer)
115115
: base(luceneDirectory, analyzer)
116116
{
@@ -127,7 +127,7 @@ public UmbracoExamineSearcher(Lucene.Net.Store.Directory luceneDirectory, Analyz
127127
/// Returns true if the Umbraco application is in a state that we can initialize the examine indexes
128128
/// </summary>
129129
/// <returns></returns>
130-
[SecuritySafeCritical]
130+
131131
protected bool CanInitialize()
132132
{
133133
//check the DisableInitializationCheck and ensure that it is not set to true

0 commit comments

Comments
 (0)