Class HttpHeaderHelper
java.lang.Object
fr.gouv.vitam.common.server.application.HttpHeaderHelper
Class helper to manage specifics Vitam headers
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkVitamHeaders
(javax.ws.rs.core.HttpHeaders headers) Check specific vitam headers values with regular expression from the (define inVitamHttpHeader
) At the first wrong value, treatment stops and throws anIllegalStateException
Note that, the regular expression is case insensitive.static void
checkVitamHeadersMap
(javax.ws.rs.core.MultivaluedMap<String, String> requestHeaders) Check specific vitam headers values with regular expression from the (define inVitamHttpHeader
) At the first wrong value, treatment stops and throws anIllegalStateException
Note that, the regular expression is case insensitive.getHeaderValues
(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader name) Get header values fromHttpHeaders
forVitamHttpHeader
getHeaderValues
(javax.ws.rs.core.HttpHeaders headers, String name) Retrieve header values fromHttpHeaders
forVitamHttpHeader
static boolean
hasValuesFor
(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader vitamHeader) Check if headers are declaredstatic void
validateHeaderValue
(javax.ws.rs.core.HttpHeaders headers, javax.ws.rs.core.MultivaluedHashMap<String, String> wantedHeaders) Validate HTTP header values.
-
Method Details
-
getHeaderValues
public static List<String> getHeaderValues(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader name) Get header values fromHttpHeaders
forVitamHttpHeader
- Parameters:
headers
- the headers listname
- theVitamHttpHeader
with wanted header name- Returns:
- the list of values for specified header name
- Throws:
IllegalArgumentException
- if headers or name is null
-
getHeaderValues
Retrieve header values fromHttpHeaders
forVitamHttpHeader
- Parameters:
headers
- the headers listname
- 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(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader vitamHeader) Check if headers are declared- Parameters:
headers
- the headers list to checkvitamHeader
- 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(javax.ws.rs.core.HttpHeaders headers) Check specific vitam headers values with regular expression from the (define inVitamHttpHeader
) At the first wrong value, treatment stops and throws anIllegalStateException
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 expressionIllegalArgumentException
- if headers is null
-
checkVitamHeadersMap
public static void checkVitamHeadersMap(javax.ws.rs.core.MultivaluedMap<String, String> requestHeaders) Check specific vitam headers values with regular expression from the (define inVitamHttpHeader
) At the first wrong value, treatment stops and throws anIllegalStateException
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(javax.ws.rs.core.HttpHeaders headers, javax.ws.rs.core.MultivaluedHashMap<String, String> wantedHeaders) Validate HTTP header values. If header is known by theVitamHttpHeader
then check if format matches with the defined regular expression. Also check the wantedHeaders map values withVitamHttpHeader
. 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 validatewantedHeaders
- 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 nullIllegalStateException
- 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.
-