コード例 #1
0
  @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());
    }
  }
コード例 #2
0
 @PUT
 @Path("{id}")
 @Consumes({"application/xml", "application/json"})
 public void edit(@PathParam("id") Integer id, Login entity) {
   super.edit(entity);
 }
コード例 #3
0
 @DELETE
 @Path("{id}")
 public void remove(@PathParam("id") Integer id) {
   super.remove(super.find(id));
 }
コード例 #4
0
 @POST
 @Override
 @Consumes({"application/xml", "application/json"})
 public void create(Login entity) {
   super.create(entity);
 }