diff --git a/src/Umbraco.Examine/UmbracoContentValueSetValidator.cs b/src/Umbraco.Examine/ContentValueSetValidator.cs
similarity index 89%
rename from src/Umbraco.Examine/UmbracoContentValueSetValidator.cs
rename to src/Umbraco.Examine/ContentValueSetValidator.cs
index 220f082e48..4fbb039bae 100644
--- a/src/Umbraco.Examine/UmbracoContentValueSetValidator.cs
+++ b/src/Umbraco.Examine/ContentValueSetValidator.cs
@@ -11,16 +11,17 @@ namespace Umbraco.Examine
{
///
- /// Used to validate a ValueSet for content - based on permissions, parent id, etc....
+ /// Used to validate a ValueSet for content/media - based on permissions, parent id, etc....
///
- public class UmbracoContentValueSetValidator : IValueSetValidator
+ public class ContentValueSetValidator : IValueSetValidator
{
private readonly UmbracoContentIndexerOptions _options;
private readonly IPublicAccessService _publicAccessService;
private const string PathKey = "path";
+ private static readonly IEnumerable ValidIndexTypes = new[] {IndexTypes.Content, IndexTypes.Media};
- public UmbracoContentValueSetValidator(UmbracoContentIndexerOptions options, IPublicAccessService publicAccessService)
+ public ContentValueSetValidator(UmbracoContentIndexerOptions options, IPublicAccessService publicAccessService)
{
_options = options;
_publicAccessService = publicAccessService;
@@ -28,6 +29,9 @@ namespace Umbraco.Examine
public bool Validate(ValueSet valueSet)
{
+ if (!ValidIndexTypes.Contains(valueSet.Category))
+ return false;
+
//check for published content
if (valueSet.Category == IndexTypes.Content && !_options.SupportUnpublishedContent)
{
diff --git a/src/Umbraco.Examine/IndexTypes.cs b/src/Umbraco.Examine/IndexTypes.cs
index fab72eca25..3fa00e234c 100644
--- a/src/Umbraco.Examine/IndexTypes.cs
+++ b/src/Umbraco.Examine/IndexTypes.cs
@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Lucene.Net.Store;
-
-namespace Umbraco.Examine
+namespace Umbraco.Examine
{
///
/// The index types stored in the Lucene Index
diff --git a/src/Umbraco.Examine/Umbraco.Examine.csproj b/src/Umbraco.Examine/Umbraco.Examine.csproj
index 0bb12ae00a..e36f911f47 100644
--- a/src/Umbraco.Examine/Umbraco.Examine.csproj
+++ b/src/Umbraco.Examine/Umbraco.Examine.csproj
@@ -81,7 +81,7 @@
-
+
diff --git a/src/Umbraco.Examine/UmbracoContentIndexer.cs b/src/Umbraco.Examine/UmbracoContentIndexer.cs
index 0433a75d41..8e8208479c 100644
--- a/src/Umbraco.Examine/UmbracoContentIndexer.cs
+++ b/src/Umbraco.Examine/UmbracoContentIndexer.cs
@@ -119,7 +119,7 @@ namespace Umbraco.Examine
parentId = indexSet.IndexParentId;
}
- ValueSetValidator = new UmbracoContentValueSetValidator(
+ ValueSetValidator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(
SupportUnpublishedContent, SupportProtectedContent, parentId,
ConfigIndexCriteria.IncludeItemTypes, ConfigIndexCriteria.ExcludeItemTypes),
diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs
index c8a5cbceb4..f66e55cbbd 100644
--- a/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs
+++ b/src/Umbraco.Tests/UmbracoExamine/IndexInitializer.cs
@@ -169,7 +169,7 @@ namespace Umbraco.Tests.UmbracoExamine
analyzer,
profilingLogger,
languageService,
- new UmbracoContentValueSetValidator(options, Mock.Of()),
+ new ContentValueSetValidator(options, Mock.Of()),
options);
i.IndexingError += IndexingError;
diff --git a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs
index 5ad542bf19..6ef3cc376f 100644
--- a/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs
+++ b/src/Umbraco.Tests/UmbracoExamine/IndexTest.cs
@@ -130,6 +130,9 @@ namespace Umbraco.Tests.UmbracoExamine
options: new UmbracoContentIndexerOptions(true, false, null)))
using (indexer.ProcessNonAsync())
{
+ contentRebuilder.RegisterIndex(indexer.Name);
+ mediaRebuilder.RegisterIndex(indexer.Name);
+
var searcher = indexer.GetSearcher();
//create the whole thing
@@ -278,12 +281,13 @@ namespace Umbraco.Tests.UmbracoExamine
public void Index_Reindex_Content()
{
var rebuilder = IndexInitializer.GetContentIndexRebuilder(Container.GetInstance(), IndexInitializer.GetMockContentService(), ScopeProvider.SqlContext);
-
using (var luceneDir = new RandomIdRamDirectory())
using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir,
options: new UmbracoContentIndexerOptions(true, false, null)))
using (indexer.ProcessNonAsync())
{
+ rebuilder.RegisterIndex(indexer.Name);
+
var searcher = indexer.GetSearcher();
//create the whole thing
diff --git a/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs b/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs
index fc95592d3d..648a5d7c86 100644
--- a/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs
+++ b/src/Umbraco.Tests/UmbracoExamine/SearchTests.cs
@@ -62,6 +62,7 @@ namespace Umbraco.Tests.UmbracoExamine
using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir))
using (indexer.ProcessNonAsync())
{
+ rebuilder.RegisterIndex(indexer.Name);
indexer.CreateIndex();
rebuilder.Populate(indexer);
diff --git a/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs b/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs
index d06b2b4fff..63ca0141f2 100644
--- a/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs
+++ b/src/Umbraco.Tests/UmbracoExamine/UmbracoContentValueSetValidatorTests.cs
@@ -14,10 +14,28 @@ namespace Umbraco.Tests.UmbracoExamine
[TestFixture]
public class UmbracoContentValueSetValidatorTests
{
+ [Test]
+ public void Invalid_Category()
+ {
+ var validator = new ContentValueSetValidator(
+ new UmbracoContentIndexerOptions(true, true, null),
+ Mock.Of());
+
+ var result = validator.Validate(new ValueSet("555", IndexTypes.Content, new { hello = "world", path = "-1,555" }));
+ Assert.IsTrue(result);
+
+ result = validator.Validate(new ValueSet("777", IndexTypes.Media, new { hello = "world", path = "-1,555" }));
+ Assert.IsTrue(result);
+
+ result = validator.Validate(new ValueSet("555", "invalid-category", new { hello = "world", path = "-1,555" }));
+ Assert.IsFalse(result);
+
+ }
+
[Test]
public void Must_Have_Path()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(true, true, null),
Mock.Of());
@@ -31,7 +49,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Parent_Id()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(true, true, 555),
Mock.Of());
@@ -51,7 +69,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Inclusion_List()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(true, true, includeContentTypes: new List { "include-content" }),
Mock.Of());
@@ -68,7 +86,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Exclusion_List()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(true, true, excludeContentTypes: new List { "exclude-content" }),
Mock.Of());
@@ -85,7 +103,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Inclusion_Exclusion_List()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(true, true,
includeContentTypes: new List { "include-content", "exclude-content" },
excludeContentTypes: new List { "exclude-content" }),
@@ -107,7 +125,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Recycle_Bin()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(false, true, null),
Mock.Of());
@@ -133,7 +151,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Published_Only()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(false, true, null),
Mock.Of());
@@ -162,7 +180,7 @@ namespace Umbraco.Tests.UmbracoExamine
[Test]
public void Published_Only_With_Variants()
{
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(false, true, null),
Mock.Of());
@@ -222,7 +240,7 @@ namespace Umbraco.Tests.UmbracoExamine
.Returns(Attempt.Succeed(new PublicAccessEntry(Guid.NewGuid(), 555, 444, 333, Enumerable.Empty())));
publicAccessService.Setup(x => x.IsProtected("-1,777"))
.Returns(Attempt.Fail());
- var validator = new UmbracoContentValueSetValidator(
+ var validator = new ContentValueSetValidator(
new UmbracoContentIndexerOptions(true, false, null),
publicAccessService.Object);
diff --git a/src/Umbraco.Web/Search/UmbracoIndexesBuilder.cs b/src/Umbraco.Web/Search/UmbracoIndexesBuilder.cs
index 339fa2f2be..bdfb259c10 100644
--- a/src/Umbraco.Web/Search/UmbracoIndexesBuilder.cs
+++ b/src/Umbraco.Web/Search/UmbracoIndexesBuilder.cs
@@ -104,7 +104,7 @@ namespace Umbraco.Web.Search
public virtual IValueSetValidator GetContentValueSetValidator(UmbracoContentIndexerOptions options)
{
- return new UmbracoContentValueSetValidator(options, PublicAccessService);
+ return new ContentValueSetValidator(options, PublicAccessService);
}
///