You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2022/11/15 16:25:46 UTC

[sling-org-apache-sling-feature-cpconverter] branch master updated: SLING-11675 - Index definition extraction from content packages is missing non-XML file

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git


The following commit(s) were added to refs/heads/master by this push:
     new 6c29fee  SLING-11675 - Index definition extraction from content packages is missing non-XML file
6c29fee is described below

commit 6c29fee9917e56d68a9ac7832b5b355f022df455
Author: Niek Raaijmakers <ra...@adobe.com>
AuthorDate: Mon Nov 14 09:56:46 2022 +0100

    SLING-11675 - Index definition extraction from content packages is missing non-XML file
---
 .../cpconverter/handlers/IndexDefinitionsEntryHandler.java | 14 ++++++++++----
 .../handlers/IndexDefinitionsEntryHandlerTest.java         |  3 +++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandler.java b/src/main/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandler.java
index b4449be..cb7c9c0 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandler.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandler.java
@@ -48,12 +48,18 @@ import org.xml.sax.InputSource;
  */
 public class IndexDefinitionsEntryHandler extends AbstractRegexEntryHandler {
 
+    private static final String[] EXCLUDED_EXTENSIONS = new String[]{
+            "vlt",
+            "gitignore"
+    };
     private static final String PATH_PATTERN = "" +
-            "/jcr_root/" + // jcr_root dir
-            "(.*/)?" + // optional path segment
+            "/jcr_root" + // jcr_root dir
+            "(.*/?)/" + // optional path segment
             PlatformNameFormat.getPlatformName(IndexDefinitions.OAK_INDEX_NAME) +
-            "(.*/)?" + // additional path segments
-            "/.*xml"; // only xml files
+            "(.*/?)" + // additional path segments
+            "/(.*?)\\.(?!(" + //excluding extensions
+            String.join("|", EXCLUDED_EXTENSIONS) +
+            ")$)[^.]+$"; // match everything else
 
     private final class IndexDefinitionsParserHandler implements DocViewParserHandler {
         private final WorkspaceFilter filter;
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandlerTest.java b/src/test/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandlerTest.java
index 9fb9c0e..8425951 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandlerTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/handlers/IndexDefinitionsEntryHandlerTest.java
@@ -55,9 +55,12 @@ public class IndexDefinitionsEntryHandlerTest {
         IndexDefinitionsEntryHandler handler = new IndexDefinitionsEntryHandler();
         assertThat(handler.matches("/jcr_root/_oak_index/.content.xml")).isTrue();
         assertThat(handler.matches("/jcr_root/not_oak_index/.content.xml")).isFalse();
+        assertThat(handler.matches("/jcr_root/not_oak_index/stop.txt")).isFalse();
         assertThat(handler.matches("/jcr_root/_oak_index/bar/.content.xml")).isTrue();
         assertThat(handler.matches("/jcr_root/_oak_index/lucene/tika/config.xml")).isTrue();
         assertThat(handler.matches("/jcr_root/_oak_index/.vlt")).isFalse();
+        assertThat(handler.matches("/jcr_root/_oak_index/stop.txt")).isTrue();
+        assertThat(handler.matches("/jcr_root/not_oak_index/.vlt")).isFalse();
         assertThat(handler.matches("/jcr_root/apps/_oak_index/.content.xml")).isTrue();
         assertThat(handler.matches("/jcr_root/apps/.content.xml")).isFalse();
         assertThat(handler.matches("/jcr_root/not_oak_index/.content.xml")).isFalse();