[
https://issues.apache.org/jira/browse/JCRVLT-724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780285#comment-17780285
]
Julian Reschke edited comment on JCRVLT-724 at 10/27/23 9:49 AM:
-----------------------------------------------------------------
It appears the problem is caused by Oak allowing square brackets into persisted
names (see
https://jackrabbit.apache.org/oak/docs/differences.html#Same_name_siblings),
but not handling them "properly" in {{Node.getName()}} (not removing the index
here). I'll do some digging in Oak to reproduce this and open a ticket (which
may be hard to resolve due to backwards compat).
In the meantime I've been testing with the above test case and the following
diff:
{noformat}
diff --git
a/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
b/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
index e065dabe..0de5da52 100644
---
a/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
+++
b/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
@@ -94,7 +94,12 @@ public class DocViewNode2 {
if (isRoot) {
nodeName = NameConstants.JCR_ROOT;
} else {
- nodeName = nameResolver.getQName(node.getName());
+ String name = node.getName();
+ if (node.getIndex() > 1) {
+ name = name + "[" + node.getIndex() + "]";
+ }
+ nodeName = nameResolver.getQName(name);
}
Collection<DocViewProperty2> docViewProps = new ArrayList<>();
for (Property property : properties) {
{noformat}
and verified that I see the reported behavior.
was (Author: reschke):
It appears the problem is caused by Oak allowing square brackets into persisted
names (see
https://jackrabbit.apache.org/oak/docs/differences.html#Same_name_siblings),
but not handling them "properly" in {{Node.getName()}} (not removing the index
here). I'll do some digging in Oak to reproduce this and open a ticket (which
may be hard to resolve due to backwards compat).
In the meantime I've been testing with the above test case and the following
diff:
{{noformat}}
diff --git
a/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
b/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
index e065dabe..0de5da52 100644
---
a/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
+++
b/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java
@@ -94,7 +94,12 @@ public class DocViewNode2 {
if (isRoot) {
nodeName = NameConstants.JCR_ROOT;
} else {
- nodeName = nameResolver.getQName(node.getName());
+ String name = node.getName();
+ if (node.getIndex() > 1) {
+ name = name + "[" + node.getIndex() + "]";
+ }
+ nodeName = nameResolver.getQName(name);
}
Collection<DocViewProperty2> docViewProps = new ArrayList<>();
for (Property property : properties) {
{{noformat}}
and verified that I see the reported behavior.
> docviewnode: improve diagnostics when generating DocViewNode2 from JCR node
> ---------------------------------------------------------------------------
>
> Key: JCRVLT-724
> URL: https://issues.apache.org/jira/browse/JCRVLT-724
> Project: Jackrabbit FileVault
> Issue Type: Task
> Components: vlt
> Reporter: Julian Reschke
> Assignee: Julian Reschke
> Priority: Major
> Attachments: SameNameSiblingIT.java
>
>
> See
> <[https://github.com/apache/jackrabbit-filevault/blob/c0480b9f83ede8969d8bcaf03428a35f81d146c2/vault-core/src/main/java/org/apache/jackrabbit/vault/util/DocViewNode2.java#L91-L110]>
> We have the unfortunate condition that an existing repository apparently
> contains invalid node names. The code above gets an IllegalNameException from
> {{nameresolver.getQName()}}, but that code doesn't have the full path to the
> node (well, it shouldn't exist in the first place...).
> It might be good to catch that exception and add information about the node's
> path and rethrow it, either where or in the calling code
> ({{AggregateImpl.walk()}}?).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)