Package io.dropwizard.jersey.errors

Examples of io.dropwizard.jersey.errors.ErrorMessage


            final Response response = e.getResponse();

            assertThat(response.getStatus())
                    .isEqualTo(400);

            ErrorMessage entity = (ErrorMessage) response.getEntity();
            assertThat(entity.getCode()).isEqualTo(400);
            assertThat(entity.getMessage())
                    .isEqualTo("\"foo\" is not a UUID.");
        }
    }
View Full Code Here


            final Response response = e.getResponse();

            assertThat(response.getStatus())
                    .isEqualTo(400);

            ErrorMessage entity = (ErrorMessage) response.getEntity();
            assertThat(entity.getCode()).isEqualTo(400);
            assertThat(entity.getMessage())
                    .isEqualTo("\"null\" must be \"true\" or \"false\".");
        }
    }
View Full Code Here

            final Response response = e.getResponse();

            assertThat(response.getStatus())
                    .isEqualTo(400);

            ErrorMessage entity = (ErrorMessage) response.getEntity();
            assertThat(entity.getCode()).isEqualTo(400);
            assertThat(entity.getMessage())
                    .isEqualTo("\"foo\" must be \"true\" or \"false\".");
        }
    }
View Full Code Here

            final Response response = e.getResponse();

            assertThat(response.getStatus())
                    .isEqualTo(400);

            ErrorMessage entity = (ErrorMessage) response.getEntity();
            assertThat(entity.getCode()).isEqualTo(400);
            assertThat(entity.getMessage())
                    .isEqualTo("\"foo\" is not a number.");
        }
    }
View Full Code Here

            final Response response = e.getResponse();

            assertThat(response.getStatus())
                    .isEqualTo(400);

            ErrorMessage entity = (ErrorMessage) response.getEntity();
            assertThat(entity.getCode()).isEqualTo(400);
            assertThat(entity.getMessage())
                    .isEqualTo("\"foo\" is not a number.");
        }
    }
View Full Code Here

        /*
         * Otherwise, it's those pesky users.
         */
        LOGGER.debug("Unable to process JSON", exception);
        return Response.status(Response.Status.BAD_REQUEST)
                       .entity(new ErrorMessage(Response.Status.BAD_REQUEST.getStatusCode(),
                               "Unable to process JSON"))
                       .build();
    }
View Full Code Here

     * @param e the exception thrown while parsing {@code input}
     * @return the {@link Response} to be sent to the client
     */
    protected Response error(String input, Exception e) {
        return Response.status(getErrorStatus())
                       .entity(new ErrorMessage(getErrorStatus().getStatusCode(),
                               errorMessage(input, e)))
                       .type(mediaType())
                       .build();
    }
View Full Code Here

    Optional<User> foundUser = getAuthUser(request);
   
    if (!foundUser.isPresent()) {
      return Response
          .status(Status.NOT_FOUND)
          .entity(new ErrorMessage(AuthResource.NOT_FOUND_MSG)).build();
    }
   
    User userToUpdate = foundUser.get();
    userToUpdate.setDisplayName(user.getDisplayName());
    userToUpdate.setEmail(user.getEmail());
View Full Code Here

    if (foundUser.isPresent()
        && PasswordService.checkPassword(user.getPassword(), foundUser.get().getPassword())) {
      Token token = AuthUtils.createToken(request.getRemoteHost(), foundUser.get().getId());
      return Response.ok().entity(token).build();
    }
    return Response.status(Status.UNAUTHORIZED).entity(new ErrorMessage(LOGING_ERROR_MSG))
        .build();
  }
View Full Code Here

      IllegalAccessException, NoSuchFieldException, SecurityException {
    String subject = AuthUtils.getSubject(request.getHeader(AuthUtils.AUTH_HEADER_KEY));
    Optional<User> foundUser = dao.findById(Long.parseLong(subject));

    if (!foundUser.isPresent()) {
      return Response.status(Status.NOT_FOUND).entity(new ErrorMessage(NOT_FOUND_MSG))
          .build();
    }

    User userToUnlink = foundUser.get();

    // check that the user is not trying to unlink the only sign-in method
    if (userToUnlink.getSignInMethodCount() == 1) {
      return Response.status(Status.BAD_REQUEST)
          .entity(new ErrorMessage(String.format(UNLINK_ERROR_MSG, provider))).build();
    }

    try {
      userToUnlink.setProviderId(Provider.valueOf(provider.toUpperCase()), null);
    } catch (IllegalArgumentException e) {
View Full Code Here

TOP

Related Classes of io.dropwizard.jersey.errors.ErrorMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.