示例#1
0
 /**
  * Retrieves representation of an History resource
  *
  * @param id this id of the history
  * @return an instance of PublicHistoryTO
  * @throws ch.heigvd.skeleton.exceptions.EntityNotFoundException
  */
 @GET
 @Path("{id}")
 @Produces({"application/json"})
 public PublicHistoryTO getResource(@PathParam("id") long id) throws EntityNotFoundException {
   History history = historiesManager.findById(id);
   PublicHistoryTO historyTO = historiesTOService.buildPublicHistoryTO(history);
   return historyTO;
 }
示例#2
0
 /**
  * Updates an History resource
  *
  * @param id this id of the history
  * @param updatedHistoryTO a TO containing the history data
  * @return an instance of PublicHistoryTO
  * @throws ch.heigvd.skeleton.exceptions.EntityNotFoundException
  */
 @PUT
 @Path("{id}")
 @Consumes({"application/json"})
 public Response Resource(PublicHistoryTO updatedHistoryTO, @PathParam("id") long id)
     throws EntityNotFoundException {
   History historyToUpdate = historiesManager.findById(id);
   historiesTOService.updateHistoryEntity(historyToUpdate, updatedHistoryTO);
   historiesManager.update(historyToUpdate);
   return Response.ok().build();
 }