thelittlewozniak

Untitled

Dec 28th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. @POST
  2.     @Produces(MediaType.APPLICATION_JSON)
  3.     @Path("CreateUser")
  4.     public Response createUser(@FormParam("firstname") String firstname,@FormParam("lastname") String lastname,@FormParam("email") String email,@FormParam("password") String password,@FormParam("address") String address,@FormParam("birthday") String birthday,@FormParam("registerDate") String registerDate,@FormParam("relationship") String relationship,@FormParam("phoneNumber") String phoneNumber,@FormParam("gender") String gender,@FormParam("interestedIn") String interestedIn){
  5.         Connection conn=GetConnection.getInstance().getConnection();
  6.         User u=new User();
  7.         u.setFirstname(firstname);
  8.         u.setLastname(lastname);
  9.         u.setEmail(email);
  10.         u.setPassword(password);
  11.         u.setAddress(address);
  12.         Date birth=null;
  13.         try {
  14.             birth=new SimpleDateFormat("dd/MM/yyyy").parse(birthday);
  15.         } catch (ParseException e) {
  16.             e.printStackTrace();
  17.         }
  18.         u.setBirthday(birth);
  19.         Date register=null;
  20.         try {
  21.             register=new SimpleDateFormat("dd/MM/yyyy").parse(registerDate);
  22.         } catch (ParseException e) {
  23.             e.printStackTrace();
  24.         }
  25.         u.setRegisterDate(register);
  26.         u.setRelationship(Boolean.parseBoolean(relationship));
  27.         u.setPhoneNumber(Integer.parseInt(phoneNumber));
  28.         u.setGender(Boolean.parseBoolean(gender));
  29.         u.setInterestedIn(Boolean.parseBoolean(interestedIn));
  30.         Boolean test=new DaoUser(conn).create(u);
  31.         Response response=null;
  32.         if(test)
  33.             response=Response.status(Response.Status.OK).entity(true).build();
  34.         else
  35.             response=Response.status(Response.Status.BAD_REQUEST).entity(u).build();
  36.         return response;
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment