class HttpHeaderHelper {

    public static void validateHeaderValue(HttpHeaders headers, MultivaluedHashMap<String, String> wantedHeaders) {
        ParametersChecker.checkParameter("Headers cannot be null", headers);

        final List<String> errorDetails = new ArrayList<>();

        for (final String wantedHeaderName : wantedHeaders.keySet()) {
            final List<String> wantedValues = toLowerCaseList(wantedHeaders.get(wantedHeaderName));
            final VitamHttpHeader vitamHeader = VitamHttpHeader.get(wantedHeaderName);
            final List<String> headersValues = toLowerCaseList(headers.getRequestHeader(wantedHeaderName));
            List<String> tmpHeadersValues;
            final List<String> tmpWantedValues = toLowerCaseList(wantedValues);

            if (headersValues.isEmpty()) {
                errorDetails.add(String.format("Header %s values are null", wantedHeaderName));
            } else {
                tmpHeadersValues = toLowerCaseList(headersValues);
                if (vitamHeader != null) {
                    errorDetails
                        .addAll(collectNonMatchingItems(vitamHeader, wantedValues, wantedHeaderName, "Wanted " +
                            "value %s for header %s does not match with define regular %s"));
                    errorDetails
                        .addAll(collectNonMatchingItems(vitamHeader, headersValues, wantedHeaderName, "Found " +
                            "value %s for header %s does not match with define regular %s"));
                }
                tmpHeadersValues.removeAll(wantedValues);
                tmpWantedValues.removeAll(headersValues);
                if (!tmpHeadersValues.isEmpty()) {
                    // error ?
                    LOGGER.warn("Some values ({}) from header {} were not check (not asked)",
                        Joiner.on(", ").join(tmpHeadersValues), wantedHeaderName);
                }
            }
            if (!tmpWantedValues.isEmpty()) {
                errorDetails.add(String.format("Some WANTED values from header %s were not found (%s)",
                    wantedHeaderName, Joiner.on(", ").join(tmpWantedValues)));
            }
        }
        if (!errorDetails.isEmpty()) {
            throw new IllegalArgumentException(
                String.format("There are %d errors %n%s", errorDetails.size(), Joiner.on("\n").join(errorDetails)));
        }
    }

    private  HttpHeaderHelper();

}