@Path("{id}/reject") @POST public Response reject(@PathParam("id") final String signupId) { checkAuthenticated(); courseService.reject(signupId); return Response.ok().build(); }
@Path("/advance/{id}") @POST @Produces("text/html") public Response advancePost( @PathParam("id") final String encoded, @FormParam("formStatus") final String formStatus) { if (null == encoded) { return Response.noContent().build(); } String[] params = courseService.getCourseSignupFromEncrypted(encoded); String signupId = params[0]; Status status = toStatus(params[1]); String placementId = params[2]; CourseSignup signup = courseService.getCourseSignupAnyway(signupId); if (null == signup) { return Response.noContent().build(); } Map<String, Object> model = new HashMap<String, Object>(); model.put("signup", signup); if (!statusProgression.next(signup.getStatus()).contains(status)) { model.put("errors", Collections.singletonList("The signup has already been dealt with.")); } else { try { switch (formStatus.toLowerCase()) { case "accept": courseService.accept(signupId, true, placementId); break; case "approve": courseService.approve(signupId, true, placementId); break; case "confirm": courseService.confirm(signupId, true, placementId); break; case "reject": courseService.reject(signupId, true, placementId); break; default: throw new IllegalStateException("No mapping for action of: " + formStatus); } } catch (IllegalStateException ise) { model.put("errors", Collections.singletonList(ise.getMessage())); } } addStandardAttributes(model); return Response.ok(new Viewable("/static/ok", model)).build(); }