/*  Copyright (c) 2001, Oracle Corporation. All Rights Reserved. */

package oracle.portal.provider.v2.http;

/**
 * A class to store http specific constants.
 */
public class HttpCommonConstants
{
    public static final String HTTP_GET_METHOD = "GET";
    public static final String HTTP_POST_METHOD = "POST";
    public static final String HTTP_ACCEPT_LANGUAGE = "Accept-Language";
    public static final String HTTP_ACCEPT_CHARSET = "Accept-Charset";
    public static final String HTTP_DEFAULT_CHARSET = "iso8859-1";
    public static final String HTTP_ACCEPT_CONTENT_TYPE = "Accept";
    public static final String HTTP_CONTENT_TYPE = "Content-type";
    public static final String HTTP_CONTENT_LANGUAGE = "Content-Language";
    public static final String HTTP_USER_AGENT = "User-Agent";
    public static final String HTTP_PORTAL_CONTENT_CHARSET = "x-oracle-portal-content-charset";
    public static final String HTTP_FORM_DATA_CONTENT_TYPE = "application/x-www-form-urlencoded";

    // String constants particular to iAS Wireless request data
    // iAS Wireless overwrites the accept header and places the original in another
    public static final String IASWIRELESS_ORIGINAL_ACCEPT_HEADER = "X-Oracle-Orig-Accept";
    public static final String IASWIRELESS_ORIGINAL_USERAGENT_HEADER = "X-Oracle-Orig-User-Agent";

    // iAS Wireless sends basic device characteristics in these header fields.
    public static final String HEADER_DEVICE_CLASS = "X-Oracle-Device.Class";
    public static final String HEADER_DEVICE_ORIENTATION = "X-Oracle-Device.Orientation";
    // maximum size of response? Spec says value in bytes?  Should this be unicode characters?
    public static final String HEADER_DEVICE_MAXDOCSIZE = "X-Oracle-Device.MaxDocSize";
    // Indicates (as boolean value) whether the connection from the client device is secure
    public static final String HEADER_DEVICE_SECURE = "X-Oracle-Device.Secure";
    // Oracle specific cache headers
    public static final String ORACLE_CACHE_LANG_HEADER = "x-oracle-cache-lang";
    public static final String ORACLE_CACHE_SUBID_HEADER = "x-oracle-cache-subid";
    public static final String ORACLE_CACHE_DEVICE_HEADER = "x-oracle-cache-device";
    public static final String ORACLE_CACHE_USER_HEADER = "x-oracle-cache-user";
    public static final String ORACLE_CACHE_ENCRYPT_HEADER = "x-oracle-cache-encrypt";

    // IASWireless location information passed in mobile request headers.
    public static final String HEADER_IASWIRELESS_USER_LOCATION_COMPANY = "X-Oracle-User.Location.Companyname";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_ADDRESSLINE1 = "X-Oracle-User.Location.AddressLine1";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_ADDRESSLINE2 = "X-Oracle-User.Location.AddressLine2";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_ADDRESSLASTLINE = "X-Oracle-User.Location.AddressLastLine";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_BLOCK = "X-Oracle-User.Location.Block";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_CITY = "X-Oracle-User.Location.City";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_COUNTY = "X-Oracle-User.Location.County";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_STATE = "X-Oracle-User.Location.State";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_POSTALCODE = "X-Oracle-User.Location.PostalCode";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_POSTALCODEEXT = "X-Oracle-User.Location.PostalCodeExt";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_COUNTRY = "X-Oracle-User.Location.Country";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_TYPE = "X-Oracle-User.Location.Type";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_X = "X-Oracle-User.Location.X";
    public static final String HEADER_IASWIRELESS_USER_LOCATION_Y = "X-Oracle-User.Location.Y";

    /**
     *  The constant that is used as the key for retrieving the
     *  ServletConfig from a ServletPortletRenderRequest using getAttribute().
     */
    public static final String SERVLET_CONFIG = "oracle.portal.ServletConfig";

    /**
     *  The constant that is used as the key for retrieving the
     *  ServletContext from a ServletPortletRenderRequest using getAttribute().
     */
    public static final String SERVLET_CONTEXT = "oracle.portal.ServletContext";

    /**
     *  The constant that is used as the key for retrieving the
     *  HttpServletRequest from a ServletPortletRenderRequest using getAttribute().
     */
    public static final String SERVLET_REQUEST = "oracle.portal.HttpServletRequest";

    /**
     *  The constant that is used as the key for retrieving the
     *  HttpServletResponse from a ServletPortletRenderRequest using getAttribute().
     */
    public static final String SERVLET_RESPONSE = "oracle.portal.HttpServletResponse";

    /**
     *  The constant that is used as the key for retrieving the
     *  PortletRenderRequest from a HttpServletRequest using getAttribute().
     *  This is provided so renderers that are implemented as servlets or jsps have
     *  a way to get back to the RenderRequest if they need it.
     */
    public static final String PORTLET_RENDER_REQUEST = "oracle.portal.PortletRenderRequest";

    /**
     *  The constant that is used as the key for retrieving the
     *  ProviderLoader from a HttpServletRequest using getAttribute().
     *  This is provided so the test pages implemented as servlets or jsps have
     *  a way to get back to the ProviderLoader Object if they need it.
     */
    public static final String PROVIDER_LOADER = "oracle.portal.provider.v2.ProviderLoader";

    /**
     * The constant used to retrieve the provider path of the original http
     * request after the resource renderer has forwarded a request. This is
     * used by the invalidation API to send invalidation requests. 
     * The provider path consists of the context path, servlet path and path 
     * info from the original request.
     * For example, for the request, http://host:port/jpdk/providers/service, the
     * provider path would be /jpdk/providers/service.  
     */
    public static final String ORIGINAL_PROVIDER_PATH = "oracle.portal.provider.v2.OriginalProviderPath";

    /**
     *  The constant that defines the expires cache header label.
     *  Oracle Portal supports expires-based caching.  To use this facility, a portlet
     *  must write a header value indicating the number of minutes this response is
     *  valid for.
     */
    public static final String EXPIRES_HEADER = "X-ORACLE-EXPIRES";

    /**
     *  The constant that defines the the validate cache header label.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks the portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed.  To support this facility, the portlet must tag their
     *  response with a "version".  This is written as a header field.  This constant
     *  defines this header field's name.  Subsequent requests from the Portal contain
     *  this version header.  Clients are expected to read this header and check whether
     *  the cached version is still valid.
     */
    public static final String CACHE_VERSION_HEADER ="ETag";

    /**
     *  The constant that defines the Web Cache invalidation based caching
     *  expiry header.
     */
    public static final String WC_EXPIRES_HEADER = "Surrogate-Control";
    
    /**
     * Qualified HMAC cookie name used in show requests
     */
    public static final String HMAC_CSUM_NAME = "oracle.webdb.provider.hmac.checksum";

    /**
     * Added to Web Cache surrogate control max-age header to specify headers 
     * that will be used as additional cache keys.
     */
     public static final String WC_VARY_HEADERS = ",vary=headers("
                     + ORACLE_CACHE_DEVICE_HEADER + "/f "
                     + ORACLE_CACHE_LANG_HEADER + "/f "
                     + ORACLE_CACHE_USER_HEADER + "/f "
                     + ORACLE_CACHE_SUBID_HEADER + "/f "
                     + ORACLE_CACHE_ENCRYPT_HEADER + "/f "
                     + HTTP_CONTENT_TYPE + "/f"
                     + ")";

    /**
     * Added to Web Cache surrogate control max-age header to use the HMAC
     * cookie as a cache key
     */
    public static final String WC_VARY_COOKIES = ";cookies(" 
                                                 + HMAC_CSUM_NAME +"/f)";
    /**
     * Surrogate control directive causing web cache to NOT store content, 
     * overriding any existing rules.
     */
    public static final String WC_NO_STORE = "no-store";         

    /**
     * Surrogate control directive causing web cache to process ESI tags.
     */
    public static final String WC_GENERATES_ESI = 
        "content=\"ORAESI/9.0.2\"";

    /**
     *  The constant that defines the validate cache header label that identifies
     *  the cache (user) level being specified.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks the portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed.  To support this facility, the portlet must tag their
     *  response with a "version".  As a portlet can render either a user specific
     *  version as well as a generic system (default) version, the portlet must also
     *  relate which response is being refrenced. This is written as a header field.
     *  This constant defines this header field's name.  Values are expected to be
     *  either "USER" or "SYSTEM" though it is better to use the constants defined
     *  herein.
     */
    public static final String CACHE_LEVEL_HEADER = "Cache-Control";

    /**
     *  The constant that identifies "user" level caching.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed.  To support this facility, the portlet must tag their
     *  response with a "version".  As a portlet can render either a user specific
     *  version as weel as a generic system (default) version, the portlet must also
     *  relate which response is being refrenced. This is written as a header field.
     *  This constant is the value used for this header field that indicates the
     *  response is user specific.
     */
    public static final String CACHE_LEVEL_USER = "USER";

    /**
     *  Constant integer value used to indicate user level caching.
     */
    public static final int USER_LEVEL = 1;

    /**
     *  The constant that identifies "system" level caching.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed.  To support this facility, the portlet must tag their
     *  response with a "version".  As a portlet can render either a user specific
     *  version as weel as a generic system (default) version, the portlet must also
     *  relate which response is being refrenced. This is written as a header field.
     *  This constant is the value used for this header field that indicates the
     *  response is system (default).
     */
    public static final String CACHE_LEVEL_SYSTEM = "SYSTEM";

    /**
     *  Constant integer value used to indicate system level caching.
     */
    public static final int SYSTEM_LEVEL = 0;

    /**
     *  The constant for the validation based cache header label that is used to
     *  indicate the existing (cached) version is valid and should be reused.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed. The indication of whether to update the cache or
     *  reuse the response in the cache is written as a header field.
     *  This constant defines this header field's name.  Use the constant
     *  CACHE_UPDATE_HEADER_VALUE as this header's value to indicate the current
     *  response should be cached (overwritting the existing cached response).
     *  Use CACHE_USE_HEADER_VALUE as this header's value to indicate the
     *  Portal should use the response in its cache.
     */
    public static final String CACHE_USE_HEADER = "X-ORACLE-CACHE";

    /**
     *  The constant value that indicates the current response is new and should
     *  replace the existing cached content.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed. The indication of whether to update the cache or
     *  reuse the response in the cache is written as a header field.
     *  This constant defines the value for CACHE_USE_HEADER that indicates the current
     *  response should be cached (overwritting the existing cached response).
     */
    public static final String CACHE_UPDATE_HEADER_VALUE = "WRITE";

    /**
     *  The constant value that indicates the current cached content is still valid
     *  and should be returned to the requester.
     *  Oracle Portal supports validation-based caching.  I.e. the portal asks portlet
     *  if the current (cached) version is still valid. If it is then it is resused
     *  rather then recomputed. The indication of whether to update the cache or
     *  reuse the response in the cache is written as a header field.
     *  This constant defines the value for CACHE_USE_HEADER that indicates the cached
     *  response is still valid and should be used.
     */
    public static final String CACHE_USE_HEADER_VALUE = "READ";

   /**
    *  The initialisation parameter that is used to specify whether or not to use
    *  invalidation caching.
    */
    public static final String INVALIDATION_CACHING = "invalidation_caching";
 
   /**
    * default expiry time for portlets which are using invalidation based
    * caching is 1 day or 1440 minutes as specified below. This value will
    * only be used if the max. exp. parameter sent in the portlet request
    * is corrupted somehow.
    */
    public static final int DEFAULT_WC_MAX_EXPIRY_TIME = 1440;
    
}
