@GET @Path("{id}/{password}") @Produces("text/plain") public String find(@PathParam("id") String id, @PathParam("password") String password) { User usr = super.find(id); if (usr != null) { if (password.equals(usr.getPassword())) { return "yes"; } } return "no"; }
@POST @Consumes({"application/json"}) @Produces("application/json") public String createUser(User entity) { try { Query q = getEntityManager().createQuery("SELECT u FROM User u WHERE u.username = :username"); q.setParameter("username", entity.getUsername()); User user = (User) q.getSingleResult(); if (user != null) return "no"; } catch (NoResultException ex) { System.out.println("User non presente"); } catch (Exception ex) { ex.printStackTrace(); } try { super.create(entity); return "yes"; } catch (Exception ex) { ex.printStackTrace(); return "no"; } }