Merge remote-tracking branch 'origin/netcore/dev' into netcore/feature/align-namespaces
# Conflicts: # src/Umbraco.Infrastructure/Examine/PublishedContentIndexPopulator.cs # src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs # src/Umbraco.Tests/UmbracoExamine/IndexTest.cs # src/Umbraco.Tests/UmbracoExamine/SearchTests.cs
This commit is contained in:
@@ -8,9 +8,9 @@ using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Examine
|
||||
{
|
||||
@@ -21,12 +21,14 @@ namespace Umbraco.Examine
|
||||
public class ContentIndexPopulator : IndexPopulator<IUmbracoContentIndex>
|
||||
{
|
||||
private readonly IContentService _contentService;
|
||||
private readonly IUmbracoDatabaseFactory _umbracoDatabaseFactory;
|
||||
private readonly IValueSetBuilder<IContent> _contentValueSetBuilder;
|
||||
|
||||
/// <summary>
|
||||
/// This is a static query, it's parameters don't change so store statically
|
||||
/// </summary>
|
||||
private static IQuery<IContent> _publishedQuery;
|
||||
private IQuery<IContent> _publishedQuery;
|
||||
private IQuery<IContent> PublishedQuery => _publishedQuery ??= _umbracoDatabaseFactory.SqlContext.Query<IContent>().Where(x => x.Published);
|
||||
|
||||
private readonly bool _publishedValuesOnly;
|
||||
private readonly int? _parentId;
|
||||
@@ -37,26 +39,20 @@ namespace Umbraco.Examine
|
||||
/// <param name="contentService"></param>
|
||||
/// <param name="sqlContext"></param>
|
||||
/// <param name="contentValueSetBuilder"></param>
|
||||
public ContentIndexPopulator(IContentService contentService, ISqlContext sqlContext, IContentValueSetBuilder contentValueSetBuilder)
|
||||
: this(false, null, contentService, sqlContext, contentValueSetBuilder)
|
||||
public ContentIndexPopulator(IContentService contentService, IUmbracoDatabaseFactory umbracoDatabaseFactory, IContentValueSetBuilder contentValueSetBuilder)
|
||||
: this(false, null, contentService, umbracoDatabaseFactory, contentValueSetBuilder)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Optional constructor allowing specifying custom query parameters
|
||||
/// </summary>
|
||||
/// <param name="publishedValuesOnly"></param>
|
||||
/// <param name="parentId"></param>
|
||||
/// <param name="contentService"></param>
|
||||
/// <param name="sqlContext"></param>
|
||||
/// <param name="contentValueSetBuilder"></param>
|
||||
public ContentIndexPopulator(bool publishedValuesOnly, int? parentId, IContentService contentService, ISqlContext sqlContext, IValueSetBuilder<IContent> contentValueSetBuilder)
|
||||
public ContentIndexPopulator(bool publishedValuesOnly, int? parentId, IContentService contentService, IUmbracoDatabaseFactory umbracoDatabaseFactory, IValueSetBuilder<IContent> contentValueSetBuilder)
|
||||
{
|
||||
if (sqlContext == null) throw new ArgumentNullException(nameof(sqlContext));
|
||||
if (umbracoDatabaseFactory == null) throw new ArgumentNullException(nameof(umbracoDatabaseFactory));
|
||||
_contentService = contentService ?? throw new ArgumentNullException(nameof(contentService));
|
||||
_umbracoDatabaseFactory = umbracoDatabaseFactory;
|
||||
_contentValueSetBuilder = contentValueSetBuilder ?? throw new ArgumentNullException(nameof(contentValueSetBuilder));
|
||||
if (_publishedQuery == null)
|
||||
_publishedQuery = sqlContext.Query<IContent>().Where(x => x.Published);
|
||||
_publishedValuesOnly = publishedValuesOnly;
|
||||
_parentId = parentId;
|
||||
}
|
||||
@@ -124,7 +120,7 @@ namespace Umbraco.Examine
|
||||
{
|
||||
//add the published filter
|
||||
//note: We will filter for published variants in the validator
|
||||
content = _contentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out _, _publishedQuery,
|
||||
content = _contentService.GetPagedDescendants(contentParentId, pageIndex, pageSize, out _, PublishedQuery,
|
||||
Ordering.By("Path", Direction.Ascending)).ToArray();
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Core.Persistence;
|
||||
|
||||
namespace Umbraco.Examine
|
||||
@@ -15,8 +13,8 @@ namespace Umbraco.Examine
|
||||
/// </remarks>
|
||||
public class PublishedContentIndexPopulator : ContentIndexPopulator
|
||||
{
|
||||
public PublishedContentIndexPopulator(IContentService contentService, ISqlContext sqlContext, IPublishedContentValueSetBuilder contentValueSetBuilder) :
|
||||
base(true, null, contentService, sqlContext, contentValueSetBuilder)
|
||||
public PublishedContentIndexPopulator(IContentService contentService, IUmbracoDatabaseFactory umbracoDatabaseFactory, IPublishedContentValueSetBuilder contentValueSetBuilder) :
|
||||
base(true, null, contentService, umbracoDatabaseFactory, contentValueSetBuilder)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
protected IVariationContextAccessor VariationContextAccessor => new TestVariationContextAccessor();
|
||||
|
||||
internal ScopeProvider ScopeProvider => Current.ScopeProvider as ScopeProvider;
|
||||
internal IUmbracoDatabaseFactory UmbracoDatabaseFactory => Factory.GetRequiredService<IUmbracoDatabaseFactory>();
|
||||
|
||||
protected ISqlContext SqlContext => Factory.GetRequiredService<ISqlContext>();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.Providers;
|
||||
using Lucene.Net.Analysis;
|
||||
using Lucene.Net.Analysis.Standard;
|
||||
using Lucene.Net.Store;
|
||||
@@ -16,6 +15,7 @@ using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Strings;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Scoping;
|
||||
using Umbraco.Examine;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -43,10 +43,10 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
return contentValueSetBuilder;
|
||||
}
|
||||
|
||||
public static ContentIndexPopulator GetContentIndexRebuilder(PropertyEditorCollection propertyEditors, IContentService contentService, IScopeProvider scopeProvider, bool publishedValuesOnly)
|
||||
public static ContentIndexPopulator GetContentIndexRebuilder(PropertyEditorCollection propertyEditors, IContentService contentService, IScopeProvider scopeProvider, IUmbracoDatabaseFactory umbracoDatabaseFactory, bool publishedValuesOnly)
|
||||
{
|
||||
var contentValueSetBuilder = GetContentValueSetBuilder(propertyEditors, scopeProvider, publishedValuesOnly);
|
||||
var contentIndexDataSource = new ContentIndexPopulator(publishedValuesOnly, null, contentService, scopeProvider.SqlContext, contentValueSetBuilder);
|
||||
var contentIndexDataSource = new ContentIndexPopulator(publishedValuesOnly, null, contentService, umbracoDatabaseFactory, contentValueSetBuilder);
|
||||
return contentIndexDataSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Examine;
|
||||
using Examine.LuceneEngine.Providers;
|
||||
using Lucene.Net.Index;
|
||||
using Lucene.Net.Search;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Examine;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Tests.TestHelpers.Entities;
|
||||
using Umbraco.Core.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Constants = Umbraco.Cms.Core.Constants;
|
||||
|
||||
namespace Umbraco.Tests.UmbracoExamine
|
||||
{
|
||||
@@ -48,7 +44,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
{
|
||||
Alias = "grid",
|
||||
Name = "Grid",
|
||||
PropertyEditorAlias = Constants.PropertyEditors.Aliases.Grid
|
||||
PropertyEditorAlias = Cms.Core.Constants.PropertyEditors.Aliases.Grid
|
||||
});
|
||||
var content = MockedContent.CreateBasicContent(contentType);
|
||||
content.Id = 555;
|
||||
@@ -126,7 +122,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
[Test]
|
||||
public void Rebuild_Index()
|
||||
{
|
||||
var contentRebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, false);
|
||||
var contentRebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, UmbracoDatabaseFactory,false);
|
||||
var mediaRebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockMediaService());
|
||||
|
||||
using (var luceneDir = new RandomIdRamDirectory())
|
||||
@@ -154,7 +150,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
[Test]
|
||||
public void Index_Protected_Content_Not_Indexed()
|
||||
{
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, false);
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, UmbracoDatabaseFactory,false);
|
||||
|
||||
|
||||
using (var luceneDir = new RandomIdRamDirectory())
|
||||
@@ -279,7 +275,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
[Test]
|
||||
public void Index_Reindex_Content()
|
||||
{
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, false);
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, UmbracoDatabaseFactory,false);
|
||||
using (var luceneDir = new RandomIdRamDirectory())
|
||||
using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir,
|
||||
validator: new ContentValueSetValidator(false)))
|
||||
@@ -320,7 +316,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
public void Index_Delete_Index_Item_Ensure_Heirarchy_Removed()
|
||||
{
|
||||
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, false);
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Factory.GetRequiredService<PropertyEditorCollection>(), IndexInitializer.GetMockContentService(), ScopeProvider, UmbracoDatabaseFactory,false);
|
||||
|
||||
using (var luceneDir = new RandomIdRamDirectory())
|
||||
using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir))
|
||||
|
||||
@@ -4,19 +4,13 @@ using System.Linq;
|
||||
using Examine;
|
||||
using Examine.Search;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NUnit.Framework;
|
||||
using Moq;
|
||||
using Umbraco.Cms.Core.Models;
|
||||
using Umbraco.Cms.Core.Persistence.Querying;
|
||||
using Umbraco.Cms.Core.PropertyEditors;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Tests.Common.Testing;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.Testing;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Examine;
|
||||
|
||||
namespace Umbraco.Tests.UmbracoExamine
|
||||
@@ -60,7 +54,7 @@ namespace Umbraco.Tests.UmbracoExamine
|
||||
allRecs);
|
||||
|
||||
var propertyEditors = Factory.GetRequiredService<PropertyEditorCollection>();
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(propertyEditors, contentService, ScopeProvider, true);
|
||||
var rebuilder = IndexInitializer.GetContentIndexRebuilder(propertyEditors, contentService, ScopeProvider, UmbracoDatabaseFactory,true);
|
||||
|
||||
using (var luceneDir = new RandomIdRamDirectory())
|
||||
using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir))
|
||||
|
||||
Reference in New Issue
Block a user