joerghoh commented on code in PR #245:
URL: 
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/245#discussion_r4739377190


##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/QueryBuildHelper.java:
##########
@@ -45,4 +53,41 @@ public static String escapeString(String input) {
     public static String excludeSystemPath() {
         return String.format("NOT isdescendantnode('%s')", 
escapeString(JCR_SYSTEM_PATH));
     }
+
+    public enum PagingBehavior {
+        UNPAGED,
+        PAGED;
+
+        /**
+         * Resolves the query paging behavior from a system property.
+         *
+         * <p>Reads the system property named by {@code propname} and resolves 
it via
+         * {@link #valueOf(String)} after trimming and uppercasing. If the 
property is
+         * null, blank, or does not match a known {@link PagingBehavior}, this 
method
+         * logs an error (when invalid) and falls back to {@link #PAGED}.
+         *
+         * @param propname the name of the system property to read; may be 
null or blank
+         * @return the resolved {@link PagingBehavior}, defaulting to {@link 
#PAGED}
+         */
+        // TODO: update when more paging methods are added
+        public static PagingBehavior getPagingBehaviour(@NotNull String 
propname) {
+            PagingBehavior defaultVal = PAGED;
+
+            String raw = System.getProperty(propname);
+            if (raw == null || raw.isBlank()) {
+                return defaultVal;
+            }
+
+            try {
+                PagingBehavior resolved = 
valueOf(raw.trim().toUpperCase(Locale.ROOT));
+                if (resolved != defaultVal) {
+                    LOG.debug("{} = {} (default: {})", propname, resolved, 
defaultVal);

Review Comment:
   ```suggestion
                       LOG.debug("PagingBehavior calculation: {} = {} (default: 
{})", propname, resolved, defaultVal);
   ```



##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/QueryBuildHelper.java:
##########
@@ -45,4 +53,41 @@ public static String escapeString(String input) {
     public static String excludeSystemPath() {
         return String.format("NOT isdescendantnode('%s')", 
escapeString(JCR_SYSTEM_PATH));
     }
+
+    public enum PagingBehavior {
+        UNPAGED,
+        PAGED;
+
+        /**
+         * Resolves the query paging behavior from a system property.
+         *
+         * <p>Reads the system property named by {@code propname} and resolves 
it via
+         * {@link #valueOf(String)} after trimming and uppercasing. If the 
property is
+         * null, blank, or does not match a known {@link PagingBehavior}, this 
method
+         * logs an error (when invalid) and falls back to {@link #PAGED}.
+         *
+         * @param propname the name of the system property to read; may be 
null or blank
+         * @return the resolved {@link PagingBehavior}, defaulting to {@link 
#PAGED}
+         */
+        // TODO: update when more paging methods are added
+        public static PagingBehavior getPagingBehaviour(@NotNull String 
propname) {
+            PagingBehavior defaultVal = PAGED;
+
+            String raw = System.getProperty(propname);
+            if (raw == null || raw.isBlank()) {
+                return defaultVal;
+            }
+
+            try {
+                PagingBehavior resolved = 
valueOf(raw.trim().toUpperCase(Locale.ROOT));
+                if (resolved != defaultVal) {
+                    LOG.debug("{} = {} (default: {})", propname, resolved, 
defaultVal);
+                }
+                return resolved;
+            } catch (IllegalArgumentException e) {
+                LOG.error("Invalid value '{}' for {}, using default {}", raw, 
propname, defaultVal);

Review Comment:
   ```suggestion
                   LOG.error("PagingBehavior calculation: Invalid value '{}' 
for {}, using default {}", raw, propname, defaultVal);
   ```



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