papyhardcore

Add element

Sep 4th, 2014
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. @POST
  2.     @Path("/add")
  3.     public Response add(@FormParam("name") String name, @FormParam("description") String description){
  4.         if(name != null){
  5.             Role r_to_rec = new Role();
  6.             r_to_rec.setName(name);
  7.             if(description != null){
  8.                r_to_rec.setDescription(description);
  9.             }
  10.             if(r_to_rec.add()){
  11.                 return Response.status(201).build();
  12.             }else{
  13.                 return Response.status(418).build();
  14.             }
  15.         }else{
  16.             return Response.status(404).build();
  17.         }
  18.  
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment