Merge branch 'temp8' into temp8-backoffice-search-with-variants

This commit is contained in:
Shannon
2018-12-12 13:37:19 +11:00
9 changed files with 82 additions and 38 deletions

View File

@@ -0,0 +1,13 @@
using System.Collections.Generic;
using Examine;
namespace Umbraco.Examine
{
/// <summary>
/// Creates <see cref="IIndex"/>'s
/// </summary>
public interface IIndexCreator
{
IEnumerable<IIndex> Create();
}
}

View File

@@ -1,12 +1,9 @@
using System;
using System.Collections.Generic;
using Examine;
using Umbraco.Core;
namespace Umbraco.Examine
{
/// <summary>
/// Exposes diagnostic information about an index
/// </summary>

View File

@@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.IO;
using Examine;
using Examine.LuceneEngine.Directories;
using Lucene.Net.Store;
using Umbraco.Core.IO;
namespace Umbraco.Examine
{
/// <inheritdoc />
/// <summary>
/// Abstract class for creating Lucene based Indexes
/// </summary>
public abstract class LuceneIndexCreator : IIndexCreator
{
public abstract IEnumerable<IIndex> Create();
/// <summary>
/// Creates a file system based Lucene <see cref="Lucene.Net.Store.Directory"/> with the correct locking guidelines for Umbraco
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public virtual Lucene.Net.Store.Directory CreateFileSystemLuceneDirectory(string name)
{
//TODO: We should have a single AppSetting to be able to specify a default DirectoryFactory so we can have a single
//setting to configure all indexes that use this to easily swap the directory to Sync/%temp%/blog, etc...
var dirInfo = new DirectoryInfo(Path.Combine(IOHelper.MapPath(SystemDirectories.Data), "TEMP", "ExamineIndexes", name));
if (!dirInfo.Exists)
System.IO.Directory.CreateDirectory(dirInfo.FullName);
var luceneDir = new SimpleFSDirectory(dirInfo);
//we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain
//terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock
//which simply checks the existence of the lock file
// The full syntax of this is: new NoPrefixSimpleFsLockFactory(dirInfo)
// however, we are setting the DefaultLockFactory in startup so we'll use that instead since it can be managed globally.
luceneDir.SetLockFactory(DirectoryFactory.DefaultLockFactory(dirInfo));
return luceneDir;
}
}
}

View File

@@ -66,6 +66,7 @@
<Compile Include="ExamineExtensions.cs" />
<Compile Include="IContentValueSetBuilder.cs" />
<Compile Include="IContentValueSetValidator.cs" />
<Compile Include="IIndexCreator.cs" />
<Compile Include="IIndexDiagnostics.cs" />
<Compile Include="IIndexPopulator.cs" />
<Compile Include="IndexPopulator.cs" />
@@ -88,6 +89,7 @@
<Compile Include="UmbracoExamineIndexDiagnostics.cs" />
<Compile Include="UmbracoExamineIndex.cs" />
<Compile Include="UmbracoExamineSearcher.cs" />
<Compile Include="LuceneIndexCreator.cs" />
<Compile Include="UmbracoMemberIndex.cs" />
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>

View File

@@ -30,9 +30,5 @@
<add initialize="true" sortOrder="1" alias="memberGroups" application="member" title="Member Groups" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.MemberGroupTreeController, Umbraco.Web" />
<!--Translation-->
<add initialize="true" application="translation" alias="dictionary" title="Dictionary" type="Umbraco.Web.Trees.DictionaryTreeController, Umbraco.Web" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
<!-- Custom -->
<add initialize="true" sortOrder="2" alias="datasource" application="forms" title="Datasources" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.DataSourceTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="0" alias="form" application="forms" title="Forms" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.FormTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="3" alias="prevaluesource" application="forms" title="Prevalue sources" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.PreValueSourceTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="3" alias="formsecurity" application="users" title="Forms Security" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.FormSecurityTreeController, Umbraco.Forms.Web" />
</trees>

View File

@@ -30,9 +30,5 @@
<add initialize="true" sortOrder="1" alias="memberGroups" application="member" title="Member Groups" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Web.Trees.MemberGroupTreeController, Umbraco.Web" />
<!--Translation-->
<add initialize="true" application="translation" alias="dictionary" title="Dictionary" type="Umbraco.Web.Trees.DictionaryTreeController, Umbraco.Web" iconClosed="icon-folder" iconOpen="icon-folder" sortOrder="0" />
<!-- Custom -->
<add initialize="true" sortOrder="2" alias="datasource" application="forms" title="Datasources" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.DataSourceTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="0" alias="form" application="forms" title="Forms" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.FormTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="3" alias="prevaluesource" application="forms" title="Prevalue sources" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.PreValueSourceTreeController, Umbraco.Forms.Web" />
<add initialize="true" sortOrder="3" alias="formsecurity" application="users" title="Forms Security" iconClosed="icon-folder" iconOpen="icon-folder-open" type="Umbraco.Forms.Web.Trees.FormSecurityTreeController, Umbraco.Forms.Web" />
</trees>

View File

@@ -1,13 +1,14 @@
using System.Collections.Generic;
using Examine;
using Umbraco.Examine;
namespace Umbraco.Web.Search
{
/// <inheritdoc />
/// <summary>
/// Used to create the Umbraco indexes
/// </summary>
public interface IUmbracoIndexesCreator
public interface IUmbracoIndexesCreator : IIndexCreator
{
IEnumerable<IIndex> Create();
}
}

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Web.Search
/// <summary>
/// Creates the indexes used by Umbraco
/// </summary>
public class UmbracoIndexesCreator : IUmbracoIndexesCreator
public class UmbracoIndexesCreator : LuceneIndexCreator, IUmbracoIndexesCreator
{
//TODO: we should inject the different IValueSetValidator so devs can just register them instead of overriding this class?
@@ -45,7 +45,7 @@ namespace Umbraco.Web.Search
/// Creates the Umbraco indexes
/// </summary>
/// <returns></returns>
public IEnumerable<IIndex> Create()
public override IEnumerable<IIndex> Create()
{
return new []
{
@@ -61,7 +61,7 @@ namespace Umbraco.Web.Search
Constants.UmbracoIndexes.InternalIndexName,
//fixme - how to deal with languages like in UmbracoContentIndexer.CreateFieldValueTypes
UmbracoExamineIndex.UmbracoIndexFieldDefinitions,
GetFileSystemLuceneDirectory(Constants.UmbracoIndexes.InternalIndexPath),
CreateFileSystemLuceneDirectory(Constants.UmbracoIndexes.InternalIndexPath),
new CultureInvariantWhitespaceAnalyzer(),
ProfilingLogger,
LanguageService,
@@ -75,7 +75,7 @@ namespace Umbraco.Web.Search
Constants.UmbracoIndexes.ExternalIndexName,
//fixme - how to deal with languages like in UmbracoContentIndexer.CreateFieldValueTypes
UmbracoExamineIndex.UmbracoIndexFieldDefinitions,
GetFileSystemLuceneDirectory(Constants.UmbracoIndexes.ExternalIndexPath),
CreateFileSystemLuceneDirectory(Constants.UmbracoIndexes.ExternalIndexPath),
new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30),
ProfilingLogger,
LanguageService,
@@ -89,27 +89,13 @@ namespace Umbraco.Web.Search
Constants.UmbracoIndexes.MembersIndexName,
//fixme - how to deal with languages like in UmbracoContentIndexer.CreateFieldValueTypes
UmbracoExamineIndex.UmbracoIndexFieldDefinitions,
GetFileSystemLuceneDirectory(Constants.UmbracoIndexes.MembersIndexPath),
CreateFileSystemLuceneDirectory(Constants.UmbracoIndexes.MembersIndexPath),
new CultureInvariantWhitespaceAnalyzer(),
ProfilingLogger,
GetMemberValueSetValidator());
return index;
}
public virtual Lucene.Net.Store.Directory GetFileSystemLuceneDirectory(string name)
{
var dirInfo = new DirectoryInfo(Path.Combine(IOHelper.MapPath(SystemDirectories.Data), "TEMP", "ExamineIndexes", name));
if (!dirInfo.Exists)
System.IO.Directory.CreateDirectory(dirInfo.FullName);
var luceneDir = new SimpleFSDirectory(dirInfo);
//we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain
//terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock
//which simply checks the existence of the lock file
luceneDir.SetLockFactory(new NoPrefixSimpleFsLockFactory(dirInfo));
return luceneDir;
}
public virtual IContentValueSetValidator GetContentValueSetValidator()
{
return new ContentValueSetValidator(false, true, PublicAccessService);

View File

@@ -78,10 +78,20 @@ namespace Umbraco.Web.Trees
}
}
var multiTree = TreeRootNode.CreateMultiTreeRoot(collection);
multiTree.Name = Services.TextService.Localize("sections/" + application);
if(collection.Count > 0)
{
var multiTree = TreeRootNode.CreateMultiTreeRoot(collection);
multiTree.Name = Services.TextService.Localize("sections/" + application);
return multiTree;
return multiTree;
}
//Otherwise its a application/section with no trees (aka a full screen app)
//For example we do not have a Forms tree definied in C# & can not attribute with [Tree(isSingleNodeTree:true0]
var rootId = Constants.System.Root.ToString(CultureInfo.InvariantCulture);
var section = Services.TextService.Localize("sections/" + application);
return TreeRootNode.CreateSingleTreeRoot(rootId, null, null, section, TreeNodeCollection.Empty, true);
}
var rootNodeGroups = new List<TreeRootNode>();