package com.composum.sling.platform.security;

import javax.servlet.http.HttpServletRequest;

public enum AccessMode {

    AUTHOR, PREVIEW, PUBLIC;

    public static AccessMode accessModeValue(Object value) {
        AccessMode mode = null;
        if (value != null) {
            try {
                mode = Enum.valueOf(AccessMode.class, value.toString().trim().toUpperCase());
            } catch (IllegalArgumentException iaex) {
                // ok, null...
            }
        }
        return mode;
    }

    public static AccessMode requestMode(HttpServletRequest request) {
        return accessModeValue(request.getAttribute(PlatformAccessFilter.ACCESS_MODE_KEY));
    }
}

@@ -200,16 +200,41 @@
 ct value
+, AccessMode defaultValue
 ) %7B%0A    
@@ -530,16 +530,159 @@
 urn mode
+ != null ? mode : defaultValue;%0A    %7D%0A%0A    public static AccessMode accessModeValue(Object value) %7B%0A        return accessModeValue(value, null)
 ;%0A    %7D%0A

access mode class separated - easier access with default value