Exemplo n.º 1
0
  @RolesAllowed(value = {"Manager"})
  @POST
  @Path("/invalidatecontestant")
  @Consumes("application/json")
  @Produces("application/json")
  public Response invalidateContestant(UserContest contestant) {
    UserContestDAO userContestDao = new UserContestDAO();
    ResponseBuilder builder;

    try {
      contestant = userContestDao.getById(contestant.getIdUserContest());
      logger.info("Invalidating contestant");

      if (contestant == null) {
        logger.info("Contestant not found");
        ForCodeError error = ErrorFactory.getErrorFromIndex(ErrorFactory.USER_CONTEST_NOT_FOUND);
        builder = Response.status(Response.Status.NOT_FOUND).entity(error);

      } else {
        contestant.setValid(false);
        userContestDao.update(contestant);

        logger.info("Contestant invalidated " + contestant.getUser().getUsername());
        builder = Response.status(Response.Status.ACCEPTED).entity(contestant);
      }
    } catch (ForCodeDataException fde) {
      logger.warn(fde.getMessage());
      builder = Response.status(Response.Status.BAD_REQUEST).entity(fde);
    }
    return builder.build();
  }
Exemplo n.º 2
0
 @PermitAll
 @GET
 @Path("/user/getusercontest/{idContest}/{idUser}")
 @Consumes("application/json")
 @Produces("application/json")
 public UserContest getUserContest(
     @PathParam("idContest") Integer idContest, @PathParam("idUser") Integer idUser) {
   UserContestDAO userContestDao = new UserContestDAO();
   try {
     return userContestDao.getUserContestByContest(idContest, idUser);
   } catch (ForCodeDataException fde) {
     return null;
   }
 }