Merge pull request #6582 from bielu/feature/split_indexcreator_and_config

V8: Split IndexCreator and Index config methods
This commit is contained in:
Shannon Deminick
2019-10-14 15:55:11 +11:00
committed by GitHub
5 changed files with 65 additions and 9 deletions

View File

@@ -0,0 +1,12 @@
using Examine;
namespace Umbraco.Examine
{
public interface IUmbracoIndexConfig
{
IContentValueSetValidator GetContentValueSetValidator();
IContentValueSetValidator GetPublishedContentValueSetValidator();
IValueSetValidator GetMemberValueSetValidator();
}
}

View File

@@ -64,9 +64,11 @@
<Compile Include="ExamineExtensions.cs" />
<Compile Include="IContentValueSetBuilder.cs" />
<Compile Include="IContentValueSetValidator.cs" />
<Compile Include="IUmbracoIndexConfig.cs" />
<Compile Include="IIndexCreator.cs" />
<Compile Include="IIndexDiagnostics.cs" />
<Compile Include="IIndexPopulator.cs" />
<Compile Include="UmbracoIndexConfig.cs" />
<Compile Include="IndexPopulator.cs" />
<Compile Include="IndexRebuilder.cs" />
<Compile Include="IPublishedContentValueSetBuilder.cs" />

View File

@@ -0,0 +1,34 @@
using Examine;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
namespace Umbraco.Examine
{
public class UmbracoIndexConfig : IUmbracoIndexConfig
{
public UmbracoIndexConfig(IPublicAccessService publicAccessService)
{
PublicAccessService = publicAccessService;
}
protected IPublicAccessService PublicAccessService { get; }
public IContentValueSetValidator GetContentValueSetValidator()
{
return new ContentValueSetValidator(false, true, PublicAccessService);
}
public IContentValueSetValidator GetPublishedContentValueSetValidator()
{
return new ContentValueSetValidator(true, false, PublicAccessService);
}
/// <summary>
/// Returns the <see cref="IValueSetValidator"/> for the member indexer
/// </summary>
/// <returns></returns>
public IValueSetValidator GetMemberValueSetValidator()
{
return new MemberValueSetValidator();
}
}
}

View File

@@ -29,6 +29,7 @@ namespace Umbraco.Web.Search
composition.Register<MediaIndexPopulator>(Lifetime.Singleton);
composition.Register<IndexRebuilder>(Lifetime.Singleton);
composition.RegisterUnique<IUmbracoIndexConfig, UmbracoIndexConfig>();
composition.RegisterUnique<IUmbracoIndexesCreator, UmbracoIndexesCreator>();
composition.RegisterUnique<IPublishedContentValueSetBuilder>(factory =>
new ContentValueSetBuilder(

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Umbraco.Core.Logging;
using Umbraco.Core.Services;
using Umbraco.Examine;
@@ -19,18 +20,20 @@ namespace Umbraco.Web.Search
public UmbracoIndexesCreator(IProfilingLogger profilingLogger,
ILocalizationService languageService,
IPublicAccessService publicAccessService,
IMemberService memberService)
IMemberService memberService, IUmbracoIndexConfig umbracoIndexConfig)
{
ProfilingLogger = profilingLogger ?? throw new System.ArgumentNullException(nameof(profilingLogger));
LanguageService = languageService ?? throw new System.ArgumentNullException(nameof(languageService));
PublicAccessService = publicAccessService ?? throw new System.ArgumentNullException(nameof(publicAccessService));
MemberService = memberService ?? throw new System.ArgumentNullException(nameof(memberService));
UmbracoIndexConfig = umbracoIndexConfig;
}
protected IProfilingLogger ProfilingLogger { get; }
protected ILocalizationService LanguageService { get; }
protected IPublicAccessService PublicAccessService { get; }
protected IMemberService MemberService { get; }
protected IUmbracoIndexConfig UmbracoIndexConfig { get; }
/// <summary>
/// Creates the Umbraco indexes
@@ -55,7 +58,8 @@ namespace Umbraco.Web.Search
new CultureInvariantWhitespaceAnalyzer(),
ProfilingLogger,
LanguageService,
GetContentValueSetValidator());
GetContentValueSetValidator()
);
return index;
}
@@ -80,28 +84,31 @@ namespace Umbraco.Web.Search
CreateFileSystemLuceneDirectory(Constants.UmbracoIndexes.MembersIndexPath),
new CultureInvariantWhitespaceAnalyzer(),
ProfilingLogger,
GetMemberValueSetValidator());
GetMemberValueSetValidator()
);
return index;
}
[Obsolete("This method should not be used and will be removed in future versions. GetContentValueSetValidator was moved to IUmbracoIndexConfig")]
public virtual IContentValueSetValidator GetContentValueSetValidator()
{
return new ContentValueSetValidator(false, true, PublicAccessService);
return UmbracoIndexConfig.GetContentValueSetValidator();
}
[Obsolete("This method should not be used and will be removed in future versions. GetPublishedContentValueSetValidator was moved to IUmbracoIndexConfig")]
public virtual IContentValueSetValidator GetPublishedContentValueSetValidator()
{
return new ContentValueSetValidator(true, false, PublicAccessService);
return UmbracoIndexConfig.GetPublishedContentValueSetValidator();
}
/// <summary>
/// Returns the <see cref="IValueSetValidator"/> for the member indexer
/// </summary>
/// <returns></returns>
[Obsolete("This method should not be used and will be removed in future versions. GetMemberValueSetValidator was moved to IUmbracoIndexConfig")]
public virtual IValueSetValidator GetMemberValueSetValidator()
{
return new MemberValueSetValidator();
return UmbracoIndexConfig.GetMemberValueSetValidator();
}
}
}