Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // HTTP Get Method
- @GET
- // Path: http://localhost/<appln-folder-name>/event/registerEvent?
- @Path("/getuserinfo")
- // Produces JSON as response
- @Produces(MediaType.APPLICATION_JSON)
- // Query parameters are parameters: http://localhost/<appln-folder-name>/
- public String getUserInfo(@QueryParam("idclient") int idc){
- String response = "";
- List <String> info = getInformation(idc);
- User user = new User();
- user.setId(idc);
- user.setNickname(info.get(0));
- user.setEmail(info.get(1));
- user.setPassword(info.get(2));
- Gson gson = new Gson();
- response = gson.toJson(user);
- return response;
- }
- private List<String> getInformation(int idClient){
- List <String> lista = new LinkedList<>();
- if(Utility.isNotNull(idClient)){
- try{
- String nickname = DBConnection.getUserName(idClient);
- String email = DBConnection.getUserEmail(idClient);
- String pass = DBConnection.getUserPassword(idClient);
- if(Utility.isNotNull(nickname) && Utility.isNotNull(email) && Utility.isNotNull(pass)){
- lista.add(nickname);
- lista.add(email);
- lista.add(pass);
- }
- }catch (SQLException e) {
- e.printStackTrace();
- }catch (Exception e) {
- e.printStackTrace();
- }
- }
- return lista;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement