// delete user Type @DELETE @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @JsonView({ServiceObjectView.ApiResultView.class}) public ApiResult delete(@PathParam("id") String id) { ApiResult result = new ApiResult(); try { ticketService.delete(Integer.parseInt(id)); } catch (Exception e) { result.setCode(ApiResult.ERROR); result.setReason(e.getMessage()); result.setData(e.getMessage()); if (WebApplicationException.class.isInstance(e)) { throw (WebApplicationException) e; } else { throw new WebApplicationException(500); } } return result; }
// Create new user type @POST @Produces(MediaType.APPLICATION_JSON) @JsonView({ServiceObjectView.ApiResultView.class}) public ApiResult add(Ticket ticket) { ApiResult result = new ApiResult(); try { ticketService.add(ticket); } catch (Exception e) { result.setCode(ApiResult.ERROR); result.setReason(e.getMessage()); result.setData(e.getMessage()); if (WebApplicationException.class.isInstance(e)) { throw (WebApplicationException) e; } else { throw new WebApplicationException(500); } } return result; }