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/04/01 10:43:38 UTC
[sling-org-apache-sling-feature-cpconverter] branch issue/SLING-11240 updated (93fe0ea -> 11f9469)
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a change to branch issue/SLING-11240
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git.
discard 93fe0ea SLING-11240 - Content packages with invalid Long properties cause index definition extraction to fail
new 11f9469 SLING-11240 - Content packages with invalid Long properties cause index definition extraction to fail
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (93fe0ea)
\
N -- N -- N refs/heads/issue/SLING-11240 (11f9469)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../sling/feature/cpconverter/index/IndexDefinitionsJsonWriter.java | 3 ---
1 file changed, 3 deletions(-)
[sling-org-apache-sling-feature-cpconverter] 01/01: SLING-11240 - Content packages with invalid Long properties cause index definition extraction to fail
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch issue/SLING-11240
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git
commit 11f946975ceb2e100b2bd985f0a3a85833bc4ed3
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Fri Apr 1 12:43:26 2022 +0200
SLING-11240 - Content packages with invalid Long properties cause index definition extraction to fail
Incorrect index definitions in test.
---
.../index/IndexDefinitionsJsonWriter.java | 13 ++++++++++++-
.../index/IndexDefinitionsJsonWriterTest.java | 21 +++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriter.java b/src/main/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriter.java
index 2c8c106..0bb26cd 100644
--- a/src/main/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriter.java
+++ b/src/main/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriter.java
@@ -48,6 +48,17 @@ public class IndexDefinitionsJsonWriter {
private static final Function<String, JsonValue> BLOB_MAPPER = s -> Json.createValue(":blobid:" + Base64.encode(s));
+ private static final Function<String, JsonValue> SAFE_LONG_MAPPER = new Function<String, JsonValue>() {
+
+ @Override
+ public JsonValue apply(String t) {
+ if ( t.endsWith(".0") )
+ t = t.replace(".0", "");
+
+ return Json.createValue(Long.parseLong(t));
+ }
+ };
+
private final Logger logger = LoggerFactory.getLogger(getClass());
private final IndexDefinitions indexDefinitions;
@@ -91,7 +102,7 @@ public class IndexDefinitionsJsonWriter {
write(json, propertyName, property.getStringValues(), s -> Json.createValue("str:" + s ));
break;
case PropertyType.LONG:
- write(json, propertyName, property.getStringValues(), s -> Json.createValue(Long.parseLong(s) ));
+ write(json, propertyName, property.getStringValues(), SAFE_LONG_MAPPER );
break;
case PropertyType.BOOLEAN:
write(json, propertyName, property.getStringValues(), s -> ( Boolean.parseBoolean(s) ? JsonValue.TRUE : JsonValue.FALSE) );
diff --git a/src/test/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriterTest.java b/src/test/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriterTest.java
index 1e5c0f2..eacba53 100644
--- a/src/test/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriterTest.java
+++ b/src/test/java/org/apache/sling/feature/cpconverter/index/IndexDefinitionsJsonWriterTest.java
@@ -106,6 +106,27 @@ public class IndexDefinitionsJsonWriterTest {
}
@Test
+ public void invalidLongPropertyIsAccepted() throws IOException {
+
+ Collection<DocViewProperty2> fooProps = new ArrayList<>();
+ fooProps.add(new DocViewProperty2(nameFactory.create("{}type"), "property"));
+ fooProps.add(new DocViewProperty2(nameFactory.create(NamespaceRegistry.NAMESPACE_JCR, "primaryType"), PREFIX_OAK+":QueryIndexDefinition"));
+ fooProps.add(new DocViewProperty2(nameFactory.create("{}reindex"), Boolean.FALSE.toString(), PropertyType.BOOLEAN));
+ fooProps.add(new DocViewProperty2(nameFactory.create("{}reindexCount"), "1.0", PropertyType.LONG));
+
+ definitions.addNode("/oak:index", new DocViewNode2(nameFactory.create("{}foo"), fooProps));
+
+ JsonObject root = generateAndParse(definitions);
+ assertThat(root).as("indexDefinitions")
+ .hasSize(1)
+ .hasEntrySatisfying("/oak:index/foo", Conditions.isJsonObject());
+
+ JsonObject fooIndex = root.getJsonObject("/oak:index/foo");
+ assertThat(fooIndex).as("foo index")
+ .contains(entry("reindexCount", Json.createValue(1)));
+ }
+
+ @Test
public void luceneIndexDefinitionWithTikaConfig() throws IOException {
String configXmlFileContents = "<properties/>";