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


##########
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 was thinking to keep this slightly more generic (note: untested code 
below!):
   
   ```suggestion
           final String name;
           if (pid.matches("^" + factoryPid + "[^a-zA-Z0-9\\s]")) {
               name = pid.substring(factoryPid.length() + 1);
           } else {
               name = pid;
           }
           return factoryPid + "~" + name;
   ```
   
   WDYT?



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