Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected Optional<String> get(HttpRequest httpRequest, HttpResponse httpResponse, StopWatch stopWatch) throws Exception {
- try {
- return fromNullable(filter(new QueryStringDecoder(httpRequest.getUri()).getParameters().entrySet().stream()
- .collect(toMap(
- e -> {
- if (e.getKey().length() > 1)
- throw new IllegalArgumentException("Multiple parameter values not supported");
- if(parameters.contains(e.getValue().get(0).toLowerCase()))
- return Filters.valueOf(e.getKey());
- else
- throw new IllegalArgumentException(format("Illegal parameter [key=%s]", e.getValue().get(0)));
- },
- e -> e.getValue().get(0)))).getContent());
- } catch (IllegalArgumentException e) {
- httpResponse.setStatus(HttpResponseStatus.BAD_REQUEST);
- return fromNullable(e.getMessage());
- } catch (Exception e) {
- httpResponse.setStatus(HttpResponseStatus.INTERNAL_SERVER_ERROR);
- return fromNullable(e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement