class SessionVote {

    @PUT
    @Path("/rate/{id}")
    @Produces(APPLICATION_JSON)
    @Consumes(APPLICATION_JSON)
    public SessionRating updateRating(@PathParam("id") String id, SessionRating newRating) {

        SessionRating original = selectedSessionRatingDAO.getRating(id);
        if (original == null) {
            throw new NotFoundException("Session Rating not found: " + id);
        }
        original.setSession(newRating.getSession());
        original.setRating(newRating.getRating());
        Attendee attendee = selectedAttendeeDAO.getAttendee(newRating.getAttendeeId());
        if (attendee == null) {
            throw new BadRequestException("Invalid attendee id: " + newRating.getAttendeeId());
        }
        original.setAttendee(attendee.getId());

        SessionRating updated = selectedSessionRatingDAO.updateRating(original);

        return updated;
    }

}