Class HttpHeaderHelper
- java.lang.Object
-
- fr.gouv.vitam.common.server.application.HttpHeaderHelper
-
public final class HttpHeaderHelper extends java.lang.ObjectClass helper to manage specifics Vitam headers
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckVitamHeaders(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 anIllegalStateExceptionNote that, the regular expression is case insensitive.static voidcheckVitamHeadersMap(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> requestHeaders)Check specific vitam headers values with regular expression from the (define inVitamHttpHeader) At the first wrong value, treatment stops and throws anIllegalStateExceptionNote that, the regular expression is case insensitive.static java.util.List<java.lang.String>getHeaderValues(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader name)Get header values fromHttpHeadersforVitamHttpHeaderstatic java.util.List<java.lang.String>getHeaderValues(javax.ws.rs.core.HttpHeaders headers, java.lang.String name)Retrieve header values fromHttpHeadersforVitamHttpHeaderstatic booleanhasValuesFor(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader vitamHeader)Check if headers are declaredstatic voidvalidateHeaderValue(javax.ws.rs.core.HttpHeaders headers, javax.ws.rs.core.MultivaluedHashMap<java.lang.String,java.lang.String> wantedHeaders)Validate HTTP header values.
-
-
-
Method Detail
-
getHeaderValues
public static java.util.List<java.lang.String> getHeaderValues(javax.ws.rs.core.HttpHeaders headers, VitamHttpHeader name)Get header values fromHttpHeadersforVitamHttpHeader- Parameters:
headers- the headers listname- theVitamHttpHeaderwith wanted header name- Returns:
- the list of values for specified header name
- Throws:
java.lang.IllegalArgumentException- if headers or name is null
-
getHeaderValues
public static java.util.List<java.lang.String> getHeaderValues(javax.ws.rs.core.HttpHeaders headers, java.lang.String name)Retrieve header values fromHttpHeadersforVitamHttpHeader- Parameters:
headers- the headers listname- the header name- Returns:
- the list of values for specified header name
- Throws:
java.lang.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:
java.lang.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 anIllegalStateExceptionNote that, the regular expression is case insensitive.- Parameters:
headers- HTTP headers list to check- Throws:
java.lang.IllegalStateException- when a header value doesn't match with teh defined regular expressionjava.lang.IllegalArgumentException- if headers is null
-
checkVitamHeadersMap
public static void checkVitamHeadersMap(javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> requestHeaders)
Check specific vitam headers values with regular expression from the (define inVitamHttpHeader) At the first wrong value, treatment stops and throws anIllegalStateExceptionNote that, the regular expression is case insensitive.- Parameters:
requestHeaders- HTTP headers list to check- Throws:
java.lang.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<java.lang.String,java.lang.String> wantedHeaders)Validate HTTP header values. If header is known by theVitamHttpHeaderthen 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:
java.lang.IllegalArgumentException- if headers is nulljava.lang.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.
-
-