public static Map setRequestAttributes()

in src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java [54:69]


    public static Map<String, Object> setRequestAttributes(SlingHttpServletRequest request, Map<String, Object> newRequestAttributes) {
        Map<String, Object> originalRequestAttributes = new LinkedHashMap<String, Object>();
        if (newRequestAttributes != null && request != null) {
            for (Map.Entry<String, Object> attr : newRequestAttributes.entrySet()) {
                String key = attr.getKey();
                Object value = attr.getValue();
                originalRequestAttributes.put(key, request.getAttribute(key));
                if (value == null) {
                    request.removeAttribute(key);
                } else {
                    request.setAttribute(key, value);
                }
            }
        }
        return originalRequestAttributes;
    }