@POST @Path("/create") @Consumes({"application/x-www-form-urlencoded", "application/xml", "application/json"}) public void createUser( @FormParam("firstName") String firstName, @FormParam("lastName") String lastName, @FormParam("username") String username, @FormParam("password") String password, @FormParam("role") String role) { if (checkPassword(password)) { List<Login> users = em.createNamedQuery("Login.findAll").getResultList(); int id = users.get(users.size() - 1).getUserid(); id++; Login newUser = new Login(id, username, password, firstName, lastName); int roleID = Integer.parseInt(role); Userroles newRole = new Userroles(roleID); newUser.setRoleid(newRole); super.create(newUser); try { ProduceSender ps = new ProduceSender(); ps.publish(); } catch (JMSException ex) { Logger.getLogger(LoginFacadeREST.class.getName()).log(Level.SEVERE, null, ex); } catch (NamingException ex) { Logger.getLogger(LoginFacadeREST.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(LoginFacadeREST.class.getName()).log(Level.SEVERE, null, ex); } } else { throw new WebApplicationException( Response.status(400) .entity( "Password must contain capital letter and number and be 8 characters long <a href=\"https://localhost:8100/JerseyRestApplication/createUserForm.html\">Create User</a>") .build()); } }
@POST @Override @Consumes({"application/xml", "application/json"}) public void create(Login entity) { super.create(entity); }