DominikSuess commented on code in PR #165:
URL: 
https://github.com/apache/sling-org-apache-sling-feature-cpconverter/pull/165#discussion_r1176084733


##########
src/main/java/org/apache/sling/feature/cpconverter/handlers/AbstractRegexEntryHandler.java:
##########
@@ -45,4 +54,39 @@ public final boolean matches(@NotNull String path) {
         return pattern;
     }
 
+    protected String extractTargetRunmode(String path, 
ContentPackage2FeatureModelConverter converter,
+            String runMode, String runModeMatch) {
+                String targetRunmode;
+                if  
(RunmodePolicy.PREPEND_INHERITED.equals(converter.getRunmodePolicy())) {
+                    final List<String> runModes = new ArrayList<>();
+                    final List<String> inheritedRunModes = runMode == null ? 
Collections.emptyList() : Arrays.asList(StringUtils.split(runMode, '.'));
+            
+                    runModes.addAll(inheritedRunModes);
+                    // append found runmodes without duplicates (legacy 
behavior direct_only established by appending to empty List)
+                    if (StringUtils.isNotEmpty(runModeMatch)) {
+                        // there is a specified RunMode
+                        logger.debug("Runmode {} was extracted from path {}", 
runModeMatch, path);
+                        List<String> newRunModes = 
Arrays.asList(StringUtils.split(runModeMatch, '.'));
+            
+                        // add only new RunModes that are not already present
+                        List<String> newRunModesList = newRunModes.stream()
+                                                                  .filter(mode 
-> !runModes.contains(mode))
+                                                                  
.collect(Collectors.toList());
+            
+                        // identify diverging list of runmodes between parent 
& direct definition as diverging criteria between runmode policies
+                        if(!runModes.isEmpty() && 
!CollectionUtils.isEqualCollection(newRunModes, inheritedRunModes)) {
+                            logger.info("Found diverging runmodes list {} 
diverging from defined runmodes on the parent {}", newRunModes.toString(), 
inheritedRunModes.toString());

Review Comment:
   wrt 3 - no that's not the point of the message, it is not about expected 
it's about divergence and therefore identifying that setting the policy will 
cause a difference depending on the policy. By that we can identify if users 
have been without being explicitly aware dependent on non-inheriting behavior 
so far - this may or may not be intentional.



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