Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. // HTTP Get Method
  2. @GET
  3. // Path: http://localhost/<appln-folder-name>/event/registerEvent?
  4. @Path("/getuserinfo")
  5. // Produces JSON as response
  6. @Produces(MediaType.APPLICATION_JSON)
  7. // Query parameters are parameters: http://localhost/<appln-folder-name>/
  8. public String getUserInfo(@QueryParam("idclient") int idc){
  9. String response = "";
  10. List <String> info = getInformation(idc);
  11. User user = new User();
  12. user.setId(idc);
  13. user.setNickname(info.get(0));
  14. user.setEmail(info.get(1));
  15. user.setPassword(info.get(2));
  16. Gson gson = new Gson();
  17. response = gson.toJson(user);
  18. return response;
  19. }
  20.  
  21.  
  22. private List<String> getInformation(int idClient){
  23. List <String> lista = new LinkedList<>();
  24. if(Utility.isNotNull(idClient)){
  25. try{
  26. String nickname = DBConnection.getUserName(idClient);
  27. String email = DBConnection.getUserEmail(idClient);
  28. String pass = DBConnection.getUserPassword(idClient);
  29. if(Utility.isNotNull(nickname) && Utility.isNotNull(email) && Utility.isNotNull(pass)){
  30. lista.add(nickname);
  31. lista.add(email);
  32. lista.add(pass);
  33. }
  34. }catch (SQLException e) {
  35. e.printStackTrace();
  36. }catch (Exception e) {
  37. e.printStackTrace();
  38. }
  39. }
  40. return lista;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement