Locale detectLocale(HttpHeaders headers) { final List<Locale> languages; try { languages = headers.getAcceptableLanguages(); } catch (HeaderValueException e) { throw new WebApplicationException(e.getMessage(), Response.Status.BAD_REQUEST); } for (Locale locale : languages) { if (!locale.toString().contains("*")) { // Freemarker doesn't do wildcards well return locale; } } return Locale.getDefault(); }
@Override public Response toResponse(final HeaderValueException e) { debugException(this, e, LOGGER); return status(BAD_REQUEST).entity(e.getMessage() + " ...should value be quoted?").type(TEXT_PLAIN_WITH_CHARSET) .build(); } }
@VisibleForTesting Locale detectLocale(HttpHeaders headers) { final List<Locale> languages; try { languages = headers.getAcceptableLanguages(); } catch (HeaderValueException e) { throw new WebApplicationException(e.getMessage(), Response.Status.BAD_REQUEST); } for (Locale locale : languages) { if (!locale.toString().contains("*")) { // Freemarker doesn't do wildcards well return locale; } } return Locale.getDefault(); }