Removes all of the med trust bits from umb examine

This commit is contained in:
Shannon
2014-09-30 11:38:02 +10:00
parent 78141630b7
commit 1f01001d16
10 changed files with 71 additions and 57 deletions

View File

@@ -42,14 +42,12 @@ namespace UmbracoExamine
/// <param name="indexPath"></param>
/// <param name="dataService"></param>
/// <param name="analyzer"></param>
[SecuritySafeCritical]
protected BaseUmbracoIndexer(IIndexCriteria indexerData, DirectoryInfo indexPath, IDataService dataService, Analyzer analyzer, bool async)
: base(indexerData, indexPath, analyzer, async)
{
DataService = dataService;
}
[SecuritySafeCritical]
protected BaseUmbracoIndexer(IIndexCriteria indexerData, Lucene.Net.Store.Directory luceneDirectory, IDataService dataService, Analyzer analyzer, bool async)
: base(indexerData, luceneDirectory, analyzer, async)
{
@@ -96,7 +94,6 @@ namespace UmbracoExamine
/// </summary>
/// <param name="name"></param>
/// <param name="config"></param>
[SecuritySafeCritical]
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
if (config["dataService"] != null && !string.IsNullOrEmpty(config["dataService"]))
@@ -217,7 +214,6 @@ namespace UmbracoExamine
/// Returns true if the Umbraco application is in a state that we can initialize the examine indexes
/// </summary>
/// <returns></returns>
[SecuritySafeCritical]
protected bool CanInitialize()
{
//check the DisableInitializationCheck and ensure that it is not set to true
@@ -268,6 +264,9 @@ namespace UmbracoExamine
/// <param name="type"></param>
protected override void PerformIndexAll(string type)
{
//TODO: Fix all of this up, the whole xpath thing is horrible and was made sooooooooo long ago to only work with published content
// but not it's being used for all content types and is really bad for performance.
if (!SupportedTypes.Contains(type))
return;
@@ -360,11 +359,9 @@ namespace UmbracoExamine
XDocument xDoc = GetXDocument(xPath, type);
if (xDoc != null)
{
XElement rootNode = xDoc.Root;
var rootNode = xDoc.Root;
IEnumerable<XElement> children = rootNode.Elements();
AddNodesToIndex(children, type);
AddNodesToIndex(rootNode.Elements(), type);
}
}

View File

@@ -28,7 +28,6 @@ namespace UmbracoExamine
/// If the type of node is not a Document, the cacheOnly has no effect, it will use the API to return
/// the xml.
/// </remarks>
[SecuritySafeCritical]
[Obsolete("This method is no longer used and will be removed in future versions")]
public static XDocument ToXDocument(this Content node, bool cacheOnly)
{
@@ -52,7 +51,6 @@ namespace UmbracoExamine
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
[SecuritySafeCritical]
[Obsolete("This method is no longer used and will be removed in future versions")]
private static XDocument ToXDocument(this Content node)
{

View File

@@ -29,14 +29,12 @@ namespace UmbracoExamine.DataServices
private readonly ApplicationContext _applicationContext;
[SecuritySafeCritical]
public UmbracoContentService()
: this(ApplicationContext.Current)
{
}
[SecuritySafeCritical]
public UmbracoContentService(ApplicationContext applicationContext)
{
_applicationContext = applicationContext;
@@ -47,7 +45,6 @@ namespace UmbracoExamine.DataServices
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
[SecuritySafeCritical]
public string StripHtml(string value)
{
return value.StripHtml();
@@ -58,7 +55,6 @@ namespace UmbracoExamine.DataServices
/// </summary>
/// <param name="xpath"></param>
/// <returns></returns>
[SecuritySafeCritical]
public XDocument GetPublishedContentByXPath(string xpath)
{
//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 @@ namespace UmbracoExamine.DataServices
/// </summary>
/// <param name="xpath"></param>
/// <returns></returns>
[SecuritySafeCritical]
public XDocument GetLatestContentByXPath(string xpath)
{
var xmlContent = XDocument.Parse("<content></content>");
@@ -93,7 +89,7 @@ namespace UmbracoExamine.DataServices
/// </summary>
/// <param name="documentId"></param>
/// <returns></returns>
[SecuritySafeCritical]
private static XmlNode GetPage(int documentId)
{
var xDoc = Access.GetXmlDocumentCopy();
@@ -118,7 +114,7 @@ namespace UmbracoExamine.DataServices
/// Returns a list of all of the user defined property names in Umbraco
/// </summary>
/// <returns></returns>
[SecuritySafeCritical]
public IEnumerable<string> GetAllUserPropertyNames()
{
try

View File

@@ -12,13 +12,13 @@ namespace UmbracoExamine.DataServices
{
public string ProviderName { get; set; }
[SecuritySafeCritical]
public void AddInfoLog(int nodeId, string msg)
{
LogHelper.Info<UmbracoLogService>("{0}, Provider={1}, NodeId={2}", () => msg, () => ProviderName, () => nodeId);
}
[SecuritySafeCritical]
public void AddErrorLog(int nodeId, string msg)
{
//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 @@ namespace UmbracoExamine.DataServices
new Exception(msg));
}
[SecuritySafeCritical]
public void AddVerboseLog(int nodeId, string msg)
{
LogHelper.Debug<UmbracoLogService>("{0}, Provider={1}, NodeId={2}", () => msg, () => ProviderName, () => nodeId);

View File

@@ -19,14 +19,14 @@ namespace UmbracoExamine.DataServices
{
private readonly ServiceContext _services;
[SecuritySafeCritical]
public UmbracoMediaService()
: this(ApplicationContext.Current.Services)
{
}
[SecuritySafeCritical]
public UmbracoMediaService(ServiceContext services)
{
_services = services;
@@ -39,7 +39,7 @@ namespace UmbracoExamine.DataServices
/// </summary>
/// <param name="xpath"></param>
/// <returns></returns>
[SecuritySafeCritical]
public XDocument GetLatestMediaByXpath(string xpath)
{
var xmlMedia = XDocument.Parse("<media></media>");

View File

@@ -28,9 +28,7 @@ using System.Security;
//NOTE: WE cannot make change the major version to be the same as Umbraco because of backwards compatibility, however we
// will make the minor version the same as the umbraco version
[assembly: AssemblyVersion("0.6.0.*")]
[assembly: AssemblyFileVersion("0.6.0.*")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyVersion("0.7.0.*")]
[assembly: AssemblyFileVersion("0.7.0.*")]
[assembly: InternalsVisibleTo("Umbraco.Tests")]

View File

@@ -45,7 +45,7 @@ namespace UmbracoExamine
/// <param name="indexPath"></param>
/// <param name="dataService"></param>
/// <param name="analyzer"></param>
[SecuritySafeCritical]
public UmbracoContentIndexer(IIndexCriteria indexerData, DirectoryInfo indexPath, IDataService dataService, Analyzer analyzer, bool async)
: base(indexerData, indexPath, dataService, analyzer, async) { }
@@ -57,7 +57,7 @@ namespace UmbracoExamine
/// <param name="dataService"></param>
/// <param name="analyzer"></param>
/// <param name="async"></param>
[SecuritySafeCritical]
public UmbracoContentIndexer(IIndexCriteria indexerData, Lucene.Net.Store.Directory luceneDirectory, IDataService dataService, Analyzer analyzer, bool async)
: base(indexerData, luceneDirectory, dataService, analyzer, async) { }
@@ -124,7 +124,7 @@ namespace UmbracoExamine
/// <exception cref="T:System.InvalidOperationException">
/// 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.
/// </exception>
[SecuritySafeCritical]
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
@@ -181,7 +181,7 @@ namespace UmbracoExamine
/// This ensures that the special __Raw_ fields are indexed
/// </summary>
/// <param name="docArgs"></param>
[SecuritySafeCritical]
protected override void OnDocumentWriting(DocumentWritingEventArgs docArgs)
{
var d = docArgs.Document;
@@ -316,7 +316,7 @@ namespace UmbracoExamine
/// ensure our special Path field is added to the collection
/// </summary>
/// <param name="e"></param>
[SecuritySafeCritical]
protected override void OnGatheringNodeData(IndexingNodeDataEventArgs e)
{
//strip html of all users fields if we detect it has HTML in it.

View File

@@ -45,7 +45,7 @@ namespace UmbracoExamine
}
}
[SecuritySafeCritical]
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
if (name == null) throw new ArgumentNullException("name");
@@ -67,7 +67,7 @@ namespace UmbracoExamine
/// </summary>
/// <param name="indexPath"></param>
/// <param name="analyzer"></param>
[SecuritySafeCritical]
public UmbracoExamineSearcher(DirectoryInfo indexPath, Analyzer analyzer)
: base(indexPath, analyzer)
{
@@ -78,7 +78,7 @@ namespace UmbracoExamine
/// </summary>
/// <param name="luceneDirectory"></param>
/// <param name="analyzer"></param>
[SecuritySafeCritical]
public UmbracoExamineSearcher(Lucene.Net.Store.Directory luceneDirectory, Analyzer analyzer)
: base(luceneDirectory, analyzer)
{
@@ -95,7 +95,7 @@ namespace UmbracoExamine
/// Returns true if the Umbraco application is in a state that we can initialize the examine indexes
/// </summary>
/// <returns></returns>
[SecuritySafeCritical]
protected bool CanInitialize()
{
//check the DisableInitializationCheck and ensure that it is not set to true

View File

@@ -1,17 +1,21 @@
using System.Collections;
using System;
using System.Collections;
using System.Linq;
using System.Security;
using System.Xml.Linq;
using System.Xml.XPath;
using Examine.LuceneEngine.Config;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using UmbracoExamine.Config;
using umbraco.cms.businesslogic.member;
using Examine.LuceneEngine;
using System.Collections.Generic;
using Examine;
using System.IO;
using UmbracoExamine.DataServices;
using Lucene.Net.Analysis;
using Member = umbraco.cms.businesslogic.member.Member;
namespace UmbracoExamine
{
@@ -34,7 +38,7 @@ namespace UmbracoExamine
/// <param name="indexPath"></param>
/// <param name="dataService"></param>
/// <param name="analyzer"></param>
[SecuritySafeCritical]
public UmbracoMemberIndexer(IIndexCriteria indexerData, DirectoryInfo indexPath, IDataService dataService, Analyzer analyzer, bool async)
: base(indexerData, indexPath, dataService, analyzer, async) { }
@@ -72,23 +76,45 @@ namespace UmbracoExamine
}
}
[SecuritySafeCritical]
protected override XDocument GetXDocument(string xPath, string type)
{
if (type == IndexTypes.Member)
{
Member[] rootMembers = Member.GetAll;
var xmlMember = XDocument.Parse("<member></member>");
foreach (Member member in rootMembers)
{
xmlMember.Root.Add(GetMemberItem(member.Id));
}
var result = ((IEnumerable)xmlMember.XPathEvaluate(xPath)).Cast<XElement>();
return result.ToXDocument();
}
/// <summary>
/// Reindex all members
/// </summary>
/// <param name="type"></param>
protected override void PerformIndexAll(string type)
{
//This only supports members
if (!SupportedTypes.Contains(type))
return;
return null;
}
//Re-index all members in batches of 5000
IEnumerable<IMember> members;
const int pageSize = 5000;
var pageIndex = 0;
do
{
int total;
members = ApplicationContext.Current.Services.MemberService.GetAll(pageIndex, pageSize, out total);
//AddNodesToIndex(GetSerializedMembers(members), type);
pageIndex++;
} while (members.Count() == pageSize);
}
private IEnumerable<XElement> GetSerializedMembers(IEnumerable<IMember> members)
{
var serializer = new EntityXmlSerializer();
foreach (var member in members)
{
yield return serializer.Serialize(ApplicationContext.Current.Services.DataTypeService, member);
}
}
protected override XDocument GetXDocument(string xPath, string type)
{
throw new NotSupportedException();
}
protected override Dictionary<string, string> GetSpecialFieldsToIndex(Dictionary<string, string> allValuesForIndexing)
{
@@ -123,7 +149,6 @@ namespace UmbracoExamine
}
}
[SecuritySafeCritical]
private static XElement GetMemberItem(int nodeId)
{
//TODO: Change this so that it is not using the LegacyLibrary, just serialize manually!

View File

@@ -21,7 +21,7 @@ namespace UmbracoExamine
/// XSLT extensions will ONLY work for provider that have a base class of BaseUmbracoIndexer
/// </remarks>
[XsltExtension("Examine")]
[SecuritySafeCritical]
public class XsltExtensions
{
///<summary>