kwin commented on a change in pull request #163:
URL:
https://github.com/apache/jackrabbit-filevault/pull/163#discussion_r746688910
##########
File path:
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1295,6 +1298,33 @@ public void endElement(String uri, String localName,
String qName) throws SAXExc
}
}
+ private boolean hasSiblingWithSameType(Node child) throws
RepositoryException {
+
+ Node parent = child.getParent();
+
+ try {
+ EffectiveNodeType ent = EffectiveNodeType.ofNode(parent);
+ String typeName =
ent.getApplicableChildNodeDefinition(child.getName(),
child.getPrimaryNodeType()).get().getName();
+
+ NodeIterator iter = parent.getNodes();
+ while (iter.hasNext()) {
+ Node sibling = iter.nextNode();
+ if (!sibling.isSame(child)) {
+ Optional<NodeDefinition> childDef =
ent.getApplicableChildNodeDefinition(sibling.getName(),
+ sibling.getPrimaryNodeType());
+ try {
+ if (typeName.equals(childDef.get().getName())) {
Review comment:
Shouldn't we rather compare
childDef.get().getDeclaringNodeType().getName() (with a null check?)
##########
File path:
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1295,6 +1298,33 @@ public void endElement(String uri, String localName,
String qName) throws SAXExc
}
}
+ private boolean hasSiblingWithSameType(Node child) throws
RepositoryException {
+
+ Node parent = child.getParent();
+
+ try {
+ EffectiveNodeType ent = EffectiveNodeType.ofNode(parent);
+ String typeName =
ent.getApplicableChildNodeDefinition(child.getName(),
child.getPrimaryNodeType()).get().getName();
+
+ NodeIterator iter = parent.getNodes();
+ while (iter.hasNext()) {
+ Node sibling = iter.nextNode();
+ if (!sibling.isSame(child)) {
+ Optional<NodeDefinition> childDef =
ent.getApplicableChildNodeDefinition(sibling.getName(),
+ sibling.getPrimaryNodeType());
+ try {
+ if (typeName.equals(childDef.get().getName())) {
+ return true;
+ }
+ } catch (NoSuchElementException ignored) {
+ }
+ }
+ }
+ } catch (NoSuchElementException ignored) {
Review comment:
Same as above and do some logging in case the child node definition
cannot be found
##########
File path:
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1295,6 +1298,33 @@ public void endElement(String uri, String localName,
String qName) throws SAXExc
}
}
+ private boolean hasSiblingWithSameType(Node child) throws
RepositoryException {
+
+ Node parent = child.getParent();
+
+ try {
+ EffectiveNodeType ent = EffectiveNodeType.ofNode(parent);
+ String typeName =
ent.getApplicableChildNodeDefinition(child.getName(),
child.getPrimaryNodeType()).get().getName();
+
+ NodeIterator iter = parent.getNodes();
+ while (iter.hasNext()) {
+ Node sibling = iter.nextNode();
+ if (!sibling.isSame(child)) {
+ Optional<NodeDefinition> childDef =
ent.getApplicableChildNodeDefinition(sibling.getName(),
+ sibling.getPrimaryNodeType());
+ try {
+ if (typeName.equals(childDef.get().getName())) {
+ return true;
+ }
+ } catch (NoSuchElementException ignored) {
Review comment:
I would rather do a check via `Optional.isPresent()` instead of relying
on exceptions here.
##########
File path:
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1295,6 +1298,33 @@ public void endElement(String uri, String localName,
String qName) throws SAXExc
}
}
+ private boolean hasSiblingWithSameType(Node child) throws
RepositoryException {
+
+ Node parent = child.getParent();
+
+ try {
+ EffectiveNodeType ent = EffectiveNodeType.ofNode(parent);
+ String typeName =
ent.getApplicableChildNodeDefinition(child.getName(),
child.getPrimaryNodeType()).get().getName();
Review comment:
You should consider the mixins as well!
##########
File path:
vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/DocViewSAXImporter.java
##########
@@ -1295,6 +1298,33 @@ public void endElement(String uri, String localName,
String qName) throws SAXExc
}
}
+ private boolean hasSiblingWithSameType(Node child) throws
RepositoryException {
+
+ Node parent = child.getParent();
+
+ try {
+ EffectiveNodeType ent = EffectiveNodeType.ofNode(parent);
+ String typeName =
ent.getApplicableChildNodeDefinition(child.getName(),
child.getPrimaryNodeType()).get().getName();
+
+ NodeIterator iter = parent.getNodes();
+ while (iter.hasNext()) {
+ Node sibling = iter.nextNode();
+ if (!sibling.isSame(child)) {
+ Optional<NodeDefinition> childDef =
ent.getApplicableChildNodeDefinition(sibling.getName(),
+ sibling.getPrimaryNodeType());
Review comment:
consider mixins
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]