Package fr.gouv.vitam.common.server.application

# Class HttpHeaderHelper

java.lang.Object
fr.gouv.vitam.common.server.application.HttpHeaderHelper

public final class HttpHeaderHelper extends Object
Class helper to manage specifics Vitam headers

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `checkVitamHeaders(jakarta.ws.rs.core.HttpHeaders headers)`
  Check specific vitam headers values with regular expression from the (define in `VitamHttpHeader`) At the first wrong value, treatment stops and throws an `IllegalStateException` Note that, the regular expression is case insensitive.
  `static void`
  `checkVitamHeadersMap(jakarta.ws.rs.core.MultivaluedMap<String,String> requestHeaders)`
  Check specific vitam headers values with regular expression from the (define in `VitamHttpHeader`) At the first wrong value, treatment stops and throws an `IllegalStateException` Note that, the regular expression is case insensitive.
  `static List<String>`
  `getHeaderValues(jakarta.ws.rs.core.HttpHeaders headers, VitamHttpHeader name)`
  Get header values from `HttpHeaders` for `VitamHttpHeader`
  `static List<String>`
  `getHeaderValues(jakarta.ws.rs.core.HttpHeaders headers, String name)`
  Retrieve header values from `HttpHeaders` for `VitamHttpHeader`
  `static boolean`
  `hasValuesFor(jakarta.ws.rs.core.HttpHeaders headers, VitamHttpHeader vitamHeader)`
  Check if headers are declared
  `static void`
  `validateHeaderValue(jakarta.ws.rs.core.HttpHeaders headers, jakarta.ws.rs.core.MultivaluedHashMap<String,String> wantedHeaders)`
  Validate HTTP header values.

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

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

- ## Method Details

  - ### getHeaderValues

    public static List<String> getHeaderValues(jakarta.ws.rs.core.HttpHeaders headers, VitamHttpHeader name)
    Get header values from `HttpHeaders` for `VitamHttpHeader`
    Parameters:
      `headers` - the headers list
      `name` - the `VitamHttpHeader` with wanted header name
    Returns:
      the list of values for specified header name
    Throws:
      `IllegalArgumentException` - if headers or name is null

  - ### getHeaderValues

    public static List<String> getHeaderValues(jakarta.ws.rs.core.HttpHeaders headers, String name)
    Retrieve header values from `HttpHeaders` for `VitamHttpHeader`
    Parameters:
      `headers` - the headers list
      `name` - the header name
    Returns:
      the list of values for specified header name
    Throws:
      `IllegalArgumentException` - if headers is null or name is null or empty

  - ### hasValuesFor

    public static boolean hasValuesFor(jakarta.ws.rs.core.HttpHeaders headers, VitamHttpHeader vitamHeader)
    Check if headers are declared
    Parameters:
      `headers` - the headers list to check
      `vitamHeader` - the header to retreive
    Returns:
      true if the header is defined, false otherwise
    Throws:
      `IllegalArgumentException` - if headers or vitamHeader is null

  - ### checkVitamHeaders

    public static void checkVitamHeaders(jakarta.ws.rs.core.HttpHeaders headers)
    Check specific vitam headers values with regular expression from the (define in `VitamHttpHeader`) At the first wrong value, treatment stops and throws an `IllegalStateException` Note that, the regular expression is case insensitive.
    Parameters:
      `headers` - HTTP headers list to check
    Throws:
      `IllegalStateException` - when a header value doesn't match with teh defined regular expression
      `IllegalArgumentException` - if headers is null

  - ### checkVitamHeadersMap

    public static void checkVitamHeadersMap(jakarta.ws.rs.core.MultivaluedMap<String,String> requestHeaders)
    Check specific vitam headers values with regular expression from the (define in `VitamHttpHeader`) At the first wrong value, treatment stops and throws an `IllegalStateException` Note that, the regular expression is case insensitive.
    Parameters:
      `requestHeaders` - HTTP headers list to check
    Throws:
      `IllegalStateException` - when a header value doesn't match with the defined regular expression

  - ### validateHeaderValue

    public static void validateHeaderValue(jakarta.ws.rs.core.HttpHeaders headers, jakarta.ws.rs.core.MultivaluedHashMap<String,String> wantedHeaders)
    Validate HTTP header values. If header is known by the `VitamHttpHeader` then check if format matches with the defined regular expression. Also check the wantedHeaders map values with `VitamHttpHeader`. Values of headers (from HTTP or from wanted list) can not be null (throw an exception). In case of error, the exception contains all errors in its message.
    Parameters:
      `headers` - the headers list to validate
      `wantedHeaders` - the map representing wanted header values with the key for header name and the value (list) for the wanted values for this specific header name
    Throws:
      `IllegalArgumentException` - if headers is null
      `IllegalStateException` - if one or more header values does not equal to wanted values, header values do not match with the defined regular expression, wanted values for a header are null, header values are null. This exception contains all errors in its message.