Package com.day.cq.personalization
Class ContextSessionPersistence
java.lang.Object
com.day.cq.personalization.ContextSessionPersistence
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringget(SlingHttpServletRequest request, String key) Returns the value from the default session persistence cookie for the specifiedkey.static Stringget(SlingHttpServletRequest request, String key, String cookieName) Returns the value from the specifiedcookieName cookiefor the specifiedkey.static Stringget(SlingHttpServletRequest request, String key, SlingSettingsService settingsService) Deprecated.since 5.6.static StringReturn the name of the default session persistence cookie.static StringgetCookieName(String cookiePrefix, SlingSettingsService settingsService) Deprecated.since 5.6.static StringgetCookieName(SlingSettingsService settingsService) Deprecated.since 5.6.static StringgetMap(SlingHttpServletRequest request) Returns a key/value map of the default session persistence cookie.static StringgetMap(SlingHttpServletRequest request, String cookieName) Returns a key/value map of named cookie.static StringgetMap(SlingHttpServletRequest request, SlingSettingsService settingsService) Deprecated.since 5.6.getStore(SlingHttpServletRequest request, String key) Return a single store (by its key) from the default session persistence cookie.getStore(SlingHttpServletRequest request, String key, String cookieName) Return a single store (by its key) from a named cookie.getStore(SlingHttpServletRequest request, String key, SlingSettingsService settingsService) Deprecated.since 5.6.static voidput(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, String value) Add a name/value pair to the default session persistence cookie.static voidput(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, String value, String cookieName) Add a name/value pair to a named cookie.static voidput(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, String value, SlingSettingsService settingsService) Deprecated.since 5.6.static voidputStore(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, Map<String, String> store) Persists a single store under the given key.static voidputStore(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, Map<String, String> store, SlingSettingsService settingsService) Deprecated.since 5.6.static voidputStores(SlingHttpServletRequest request, SlingHttpServletResponse response, Map<String, Map<String, String>> stores, String cookieName) Put multiple stores at once without overwriting stores previously put to response.
-
Constructor Details
-
ContextSessionPersistence
public ContextSessionPersistence()
-
-
Method Details
-
get
public static String get(SlingHttpServletRequest request, String key, SlingSettingsService settingsService) Deprecated.since 5.6. Useget(org.apache.sling.api.SlingHttpServletRequest, String)instead.Returns the value from the default session persistence cookie for the specifiedkey.- Parameters:
request- The SlingHttpServletRequestkey- KeysettingsService- The SlingSettingsService- Returns:
- Value or an empty string
-
get
Returns the value from the default session persistence cookie for the specifiedkey.- Parameters:
request- The SlingHttpServletRequestkey- Key- Returns:
- Value or an empty string
-
get
Returns the value from the specifiedcookieName cookiefor the specifiedkey.- Parameters:
request- The SlingHttpServletRequestkey- KeycookieName- Cookie name- Returns:
- Value or an empty string
-
getMap
Deprecated.since 5.6. UsegetMap(org.apache.sling.api.SlingHttpServletRequest)instead.Returns a key/value map of the default session persistence cookie.- Parameters:
request- The SlingHttpServletRequestsettingsService- The SlingSettingsService- Returns:
- Map with key/value pairs
-
getMap
Returns a key/value map of the default session persistence cookie.- Parameters:
request- The SlingHttpServletRequest- Returns:
- Map with key/value pairs
-
getMap
Returns a key/value map of named cookie.- Parameters:
request- The SlingHTTPServletRequestcookieName- Cookie name- Returns:
- Map with key/value pairs
-
put
public static void put(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, String value, SlingSettingsService settingsService) Deprecated.Add a name/value pair to the default session persistence cookie.- Parameters:
request- The SlingHTTPServletRequestresponse- The SlingHTTPServletResponsekey- Keyvalue- ValuesettingsService- The SlingSettingsService
-
put
public static void put(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, String value) Add a name/value pair to the default session persistence cookie.- Parameters:
request- The SlingHTTPServletRequestresponse- The SlingHTTPServletResponsekey- Keyvalue- Value
-
put
public static void put(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, String value, String cookieName) Add a name/value pair to a named cookie.- Parameters:
request- The SlingHTTPServletRequestresponse- The SlingHTTPServletResponsekey- Keyvalue- ValuecookieName- Cookie name
-
getStore
public static Map<String,String> getStore(SlingHttpServletRequest request, String key, SlingSettingsService settingsService) Deprecated.since 5.6. UsegetStore(org.apache.sling.api.SlingHttpServletRequest, String)instead.Return a single store (by its key) from the default session persistence cookie.- Parameters:
request- The SlingHTTPServletRequestkey- Key referencing the storesettingsService- The SlingSettingsService- Returns:
- the store
-
getStore
Return a single store (by its key) from the default session persistence cookie.- Parameters:
request- The SlingHttpServletRequestkey- Key referencing the store- Returns:
- the store
-
getStore
public static Map<String,String> getStore(SlingHttpServletRequest request, String key, String cookieName) Return a single store (by its key) from a named cookie.- Parameters:
request- The SlingHttpServletRequestkey- Key referencing the storecookieName- Cookie name- Returns:
- the store
-
putStore
public static void putStore(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, Map<String, String> store, SlingSettingsService settingsService) Deprecated.Persists a single store under the given key.- Parameters:
request- The SlingHttpServletRequestresponse- The SlingHttpServletResponsekey- Keystore- A map representing the storesettingsService- The SlingSettingsService
-
putStore
public static void putStore(SlingHttpServletRequest request, SlingHttpServletResponse response, String key, Map<String, String> store) Persists a single store under the given key.Note: Don't use this method to persist multiple stores. Use
putStores(SlingHttpServletRequest, SlingHttpServletResponse, Map, String)instead.- Parameters:
request- The SlingHttpServletRequestresponse- The SlingHttpServletResponsekey- Keystore- A map representing the store
-
putStores
public static void putStores(SlingHttpServletRequest request, SlingHttpServletResponse response, Map<String, Map<String, String>> stores, String cookieName) Put multiple stores at once without overwriting stores previously put to response. The method takes a map of stores where the key corresponds to the store key.- Parameters:
request- The requestresponse- The responsestores- The map of storescookieName- The cookie's name
-
getCookieName
Return the name of the default session persistence cookie.- Returns:
- Cookie name
-
getCookieName
Deprecated.since 5.6. UsegetCookieName()instead.Return the name of the cookie.- Parameters:
settingsService- The SlingSettingsService- Returns:
- Cookie name
-
getCookieName
Deprecated.since 5.6. UsegetCookieName()instead.Return the name of the cookie.- Parameters:
cookiePrefix- The cookie prefixsettingsService- The SlingSettingsService- Returns:
- Cookie name
-