kwin commented on code in PR #41:
URL: 
https://github.com/apache/sling-org-apache-sling-jcr-repoinit/pull/41#discussion_r1049627267


##########
src/main/java/org/apache/sling/jcr/repoinit/impl/NodeVisitor.java:
##########
@@ -57,18 +59,33 @@ public void visitCreatePath(CreatePath cp) {
             String parentPath = parentPathBuilder.toString();
             final String fullPath = String.format("%s/%s", parentPath, 
psd.getSegment());
             try {
-                if (session.itemExists(fullPath)) {
-                    log.info("Path already exists, nothing to do (and not 
checking its primary type for now): {}", fullPath);
-                } else {
+                final Node node;
+                if (session.nodeExists(fullPath)) {
+                    log.info("Node at {} already exists, checking/adjusting 
its types", fullPath);
+                    node = session.getNode(fullPath);
+                    if (psd.getPrimaryType() != null && 
!node.getPrimaryNodeType().getName().equals(psd.getPrimaryType())) {
+                        log.info("Adjusting primary type of node {} to {}", 
fullPath, psd.getPrimaryType());
+                        node.setPrimaryType(psd.getPrimaryType());

Review Comment:
   see 
https://github.com/apache/sling-org-apache-sling-jcr-repoinit/pull/41#issuecomment-1353043016



-- 
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]

Reply via email to