edu.ucsb.nceas.metacat.util

## Class RequestUtil

- java.lang.Object
- - edu.ucsb.nceas.metacat.util.RequestUtil

-     public class RequestUtil
      extends java.lang.Object

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `clearRequestMessages(javax.servlet.http.HttpServletRequest request)` Add a list of general messages to the request.
    `static void` | `forwardRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Hashtable<java.lang.String,java.lang.String[]> params)` Forward a request that was received by this servlet on to another JSP page or servlet to continue handling the request.
    `static void` | `forwardRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String destinationUrl, java.util.Hashtable<java.lang.String,java.lang.String[]> params)` Forward a request that was received by this servlet on to another JSP page or servlet to continue handling the request.
    `static java.lang.String` | `get(java.lang.String urlString, java.util.Hashtable<java.lang.String,java.lang.String[]> params)`
    `static javax.servlet.http.Cookie` | `getCookie(javax.servlet.http.HttpServletRequest request, java.lang.String cookieName)` Get a cookie from a request by the cookie name
    `static java.util.Hashtable<java.lang.String,java.lang.String[]>` | `getParameters(javax.servlet.http.HttpServletRequest request)` Get a cookie from a request by the cookie name
    `static SessionData` | `getSessionData(javax.servlet.http.HttpServletRequest request)` Get the session data from a request.
    `static SessionData` | `getSessionDataFromToken(javax.servlet.http.HttpServletRequest request)` Get SessionData from the DataONE auth token
    `static java.lang.String` | `post(org.apache.http.client.HttpClient httpclient, java.lang.String url, java.util.HashMap<java.lang.String,java.lang.String> paramMap)` Post a request and return the response body
    `static void` | `setRequestErrors(javax.servlet.http.HttpServletRequest request, java.util.Vector<java.lang.String> errorVector)` Add a list of errors to the request.
    `static void` | `setRequestFormErrors(javax.servlet.http.HttpServletRequest request, java.util.Vector<java.lang.String> errorVector)` Add a list of form errors to the request.
    `static void` | `setRequestMessage(javax.servlet.http.HttpServletRequest request, java.util.Vector<java.lang.String> messageVector)` Add a list of general messages to the request.
    `static void` | `setRequestSuccess(javax.servlet.http.HttpServletRequest request, java.util.Vector<java.lang.String> successVector)` Add a list of success messages to the request.
    `static void` | `setUserId(javax.servlet.http.HttpServletRequest request, java.lang.String userId)` Add the user's login id to the session on this request

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### forwardRequest

          public static void forwardRequest(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            java.lang.String destinationUrl,
                                            java.util.Hashtable<java.lang.String,java.lang.String[]> params)
                                     throws MetacatUtilException

      Forward a request that was received by this servlet on to another JSP page or servlet to continue handling the request.
      Parameters:
        `request` - to be forwarded
        `response` - that can be used for writing output to the client
        `destination` - the context-relative URL to which the request is forwarded
        `params` - the request parameters. these will be added to the request
      Throws:
        `MetacatUtilException`

    - #### forwardRequest

          public static void forwardRequest(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            java.util.Hashtable<java.lang.String,java.lang.String[]> params)
                                     throws MetacatUtilException

      Forward a request that was received by this servlet on to another JSP page or servlet to continue handling the request. In this case, the page must be referenced in a paramter named "forwardto". If the qformat is provided, the file will be retrieved from that skin. Otherwise, the file will be retrieved from the system default skin. For more specific file location, use: forwardRequest(request,response, destinationUrl, params)
      Parameters:
        `request` - to be forwarded
        `response` - that can be used for writing output to the client
        `params` - the request parameters. these will be added to the request.
      Throws:
        `MetacatUtilException`

    - #### post

          public static java.lang.String post(org.apache.http.client.HttpClient httpclient,
                                              java.lang.String url,
                                              java.util.HashMap<java.lang.String,java.lang.String> paramMap)
                                       throws java.io.IOException,
                                              org.apache.http.HttpException

      Post a request and return the response body
      Parameters:
        `httpClient` - The HttpClient to use in the post. This is passed in because the same client may be used in several posts
        `url` - the url to post to
        `paramMap` - map of parameters to add to the post
      Throws:
        `java.io.IOException`
        `org.apache.http.HttpException`

    - #### get

          public static java.lang.String get(java.lang.String urlString,
                                             java.util.Hashtable<java.lang.String,java.lang.String[]> params)
                                      throws MetacatUtilException

      Throws:
        `MetacatUtilException`

    - #### getCookie

          public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest request,
                                                            java.lang.String cookieName)

      Get a cookie from a request by the cookie name
      Parameters:
        `request` - the request from which to get the cookie
        `cookieName` - the name of the cookie to look for

    - #### getSessionData

          public static SessionData getSessionData(javax.servlet.http.HttpServletRequest request)

      Get the session data from a request. The Scenarios we can run across here: -- the session id parameter was set in the request parameters -- request.getSession returns a new session. There is a chance that the session id was set in a cookie. Check for a JSESSIONID cookie and use that id if provided. -- request.getSession returns a session that is a) preexisting or b) new but without a JSESSIONID cookie. Use the session id from this session
      Parameters:
        `request` - the request from which to get the session data
      Returns:
        the session data object representing the active session for this request. If there is no active session, the public session data is returned

    - #### getSessionDataFromToken

          public static SessionData getSessionDataFromToken(javax.servlet.http.HttpServletRequest request)

      Get SessionData from the DataONE auth token
      Parameters:
        `request` -
      Returns:

    - #### getParameters

          public static java.util.Hashtable<java.lang.String,java.lang.String[]> getParameters(javax.servlet.http.HttpServletRequest request)

      Get a cookie from a request by the cookie name
      Parameters:
        `request` - the request from which to get the cookie
        `cookieName` - the name of the cookie to look for

    - #### setRequestErrors

          public static void setRequestErrors(javax.servlet.http.HttpServletRequest request,
                                              java.util.Vector<java.lang.String> errorVector)

      Add a list of errors to the request. The pages will pick up the errors and display them where appropriate.
      Parameters:
        `request` - the request that will get forwarded
        `errorVector` - a list of error strings

    - #### setRequestFormErrors

          public static void setRequestFormErrors(javax.servlet.http.HttpServletRequest request,
                                                  java.util.Vector<java.lang.String> errorVector)

      Add a list of form errors to the request. The pages will pick up the errors and display them where appropriate.
      Parameters:
        `request` - the request that will get forwarded
        `errorVector` - a list of form error strings

    - #### setRequestSuccess

          public static void setRequestSuccess(javax.servlet.http.HttpServletRequest request,
                                               java.util.Vector<java.lang.String> successVector)

      Add a list of success messages to the request. The pages will pick up the messages and display them where appropriate.
      Parameters:
        `request` - the request that will get forwarded
        `errorVector` - a list of success message strings

    - #### setRequestMessage

          public static void setRequestMessage(javax.servlet.http.HttpServletRequest request,
                                               java.util.Vector<java.lang.String> messageVector)

      Add a list of general messages to the request. The pages will pick up the messages and display them where appropriate.
      Parameters:
        `request` - the request that will get forwarded
        `errorVector` - a list of general message strings

    - #### clearRequestMessages

          public static void clearRequestMessages(javax.servlet.http.HttpServletRequest request)

      Add a list of general messages to the request. The pages will pick up the messages and display them where appropriate.
      Parameters:
        `request` - the request that will get forwarded
        `errorVector` - a list of general message strings

    - #### setUserId

          public static void setUserId(javax.servlet.http.HttpServletRequest request,
                                       java.lang.String userId)

      Add the user's login id to the session on this request
      Parameters:
        `request` - the request that will get forwarded
        `userId` - the user's login id

Copyright © 2020 Regents of the University of California. All Rights Reserved.