Esempio n. 1
0
  // 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;
  }
Esempio n. 2
0
 // Return the list of comments
 @GET
 @Path("/list")
 @Produces(MediaType.APPLICATION_JSON)
 @JsonView({ServiceObjectView.TicketView.class})
 public List<Ticket> listTicket() {
   try {
     TicketExample example = new TicketExample();
     return ticketService.list(example);
   } catch (Exception e) {
     throw new WebApplicationException(500);
   }
 }
Esempio n. 3
0
  // 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;
  }