jsedding commented on code in PR #9:
URL: 
https://github.com/apache/sling-org-apache-sling-installer-provider-jcr/pull/9#discussion_r1608329623


##########
src/main/java/org/apache/sling/installer/provider/jcr/impl/JcrUtil.java:
##########
@@ -73,4 +75,21 @@ public static Node createPath(final Session session,
         }
         return parentNode.getNode(relativePath);
     }
+
+    /**
+     * Get the PID for a configuration event by using the R7 format before 
saving it.
+     *
+     * @param factoryPid factory PID of the configuration
+     * @param pid PID of the configuration
+     * @return The PID in R7 format
+     */
+    public static String getPid(final String factoryPid, final String pid) {
+        // if factory pid is separated from pid by a period (.), we need 
replace it with a ~ so that this can be installed
+        // and grouped as a factory configuration
+        if (pid.startsWith(factoryPid + '.')) {
+            String id = pid.substring(factoryPid.length() + 1);
+            return factoryPid + "~" + id;
+        }
+        return pid;

Review Comment:
   I would flip the logic. I.e. let a pid in the correct format through. If the 
format is incorrect, normalize the pid to a name by removing a prefix of 
`factoryPid` if present. Then concat the factoryPid, ~ and normalized pid.



-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to