anchela commented on a change in pull request #19:
URL:
https://github.com/apache/sling-org-apache-sling-jcr-repoinit/pull/19#discussion_r647565640
##########
File path: src/main/java/org/apache/sling/jcr/repoinit/impl/AclVisitor.java
##########
@@ -142,7 +142,9 @@ public void visitCreatePath(CreatePath cp) {
for (PathSegmentDefinition psd : cp.getDefinitions()) {
final String fullPath = parentPath + "/" + psd.getSegment();
try {
- if (session.itemExists(fullPath)) {
+ if (session.propertyExists(fullPath)) {
+ throw new RuntimeException("Error creating Node at " +
fullPath + ": a property exists with the same path");
+ } else if (session.itemExists(fullPath)) {
Review comment:
i would rather use 'session.nodeExists(fullPath)' here just for the sake
of clarity and also to make really sure we don't by mistake have a property
introduced just now somehow.... not very likely but i have seen all sort of
unlikely nonsense.
##########
File path: src/test/java/org/apache/sling/jcr/repoinit/CreatePathsTest.java
##########
@@ -19,6 +19,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
+import java.util.UUID;
Review comment:
unused import?
##########
File path: src/main/java/org/apache/sling/jcr/repoinit/impl/AclVisitor.java
##########
@@ -142,7 +142,9 @@ public void visitCreatePath(CreatePath cp) {
for (PathSegmentDefinition psd : cp.getDefinitions()) {
final String fullPath = parentPath + "/" + psd.getSegment();
try {
- if (session.itemExists(fullPath)) {
+ if (session.propertyExists(fullPath)) {
+ throw new RuntimeException("Error creating Node at " +
fullPath + ": a property exists with the same path");
+ } else if (session.itemExists(fullPath)) {
log.info("Path already exists, nothing to do (and not
checking its primary type for now): {}", fullPath);
Review comment:
log.info("Node at {} already exists.....
that makes it unambiguous that we are trying to create a node and not a
property. "Path already exists" is a bit vague....
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]