/*
  * (non-Javadoc)
  *
  * @see org.resthub.web.controller.GenericController#update(ID, T)
  */
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 @PUT
 @Path("/{id}")
 public T update(@PathParam("id") ID id, T entity) {
   Assert.notNull(id, "id cannot be null");
   T retreivedEntity = this.service.findById(id);
   if (retreivedEntity == null) {
     throw new NotFoundException();
   }
   MetamodelUtils utils =
       new MetamodelUtils<T, ID>(
           (Class<T>) ClassUtils.getGenericTypeFromBean(this.service), em.getMetamodel());
   Serializable entityId = utils.getIdFromEntity(entity);
   if ((entityId != null) && !id.equals(this.getIdFromEntity(retreivedEntity))) {
     throw new WebApplicationException(Response.Status.CONFLICT);
   }
   if (null == entityId) {
     utils.setIdForEntity(entity, id);
   }
   return this.service.update(entity);
 }