Interface RequestStorage

  • All Known Subinterfaces:
    RequestStorageWrite

    public interface RequestStorage
    This allows access to values which are stored in the current request thread, these values are inaccessible outside of a request and will be destroyed when the thread ends
    This also "magically" exposes all the values in the request (attributes and params) as if they were stored in the map as well, if there are conflicts then locally stored data always wins over data from the request
    Standard reserved keys have values that are always available:
    • _locale : Locale
    • _requestEntityReference : String
    • _requestActive : [true,false]
    • _requestOrigin : ['REST','EXTERNAL','INTERNAL']
    Author:
    Aaron Zeckoski (azeckoski @ gmail.com)
    • Method Detail

      • getStorageMapCopy

        Map<String,​Object> getStorageMapCopy()
        Get the data as a map for easy access to the full set of keys/values, this is a copy and changing it has no effect on the data in the request
        Returns:
        a copy of the internal storage of request keys and values as a map, may be empty but will not be null
      • getStorageMapCopy

        Map<String,​Object> getStorageMapCopy​(boolean includeInternal,
                                                   boolean includeHeaders,
                                                   boolean includeParams,
                                                   boolean includeAttributes)
        Special version which allows getting only the parts that are desired
        Parameters:
        includeInternal - include the internal request values
        includeHeaders - include the request headers
        includeParams - include the request parameters
        includeAttributes - include the request attributes
        Returns:
        the map with the requested values
      • getStoredValue

        Object getStoredValue​(String key)
        Get a value that is stored in the request for a specific key
        Parameters:
        key - a key for a stored value
        Returns:
        the stored value if found OR null if not found
        Throws:
        IllegalArgumentException - if the key is null
      • getStoredValueAsType

        <T> T getStoredValueAsType​(Class<T> type,
                                   String key)
        Type Parameters:
        T -
        Parameters:
        type - an object type to attempt to convert the object to
        key - a key for the stored value
        Returns:
        the stored value converted to the requested type OR null if none found
        Throws:
        IllegalArgumentException - if the type or key is null
        IllegalFormatConversionException - if the conversion cannot be completed