Ejemplo n.º 1
0
 @GET
 @Path("/all")
 @Produces(MediaType.APPLICATION_JSON)
 public Response getAllUsers(@CookieParam("name") String uid) {
   int userid = Sessions.uid(uid);
   if (Factory.getInstance().getUserDAO().getById(userid).getAccess() == 2) {
     UserDAO userDAO = Factory.getInstance().getUserDAO();
     try {
       ArrayList<UserDTO> users = (ArrayList<UserDTO>) GetListDTO.getListUserDTO(userDAO.getAll());
       log.info("GetUser ALL: success");
       return Response.ok(new GenericEntity<ArrayList<UserDTO>>(users) {}).build();
     } catch (Exception e) {
       log.info("GetUser ALL: exception");
       return null;
     }
   }
   return Response.status(400).entity("not access").build();
 }
Ejemplo n.º 2
0
  @GET
  @Path("/mylogin")
  @Produces(MediaType.APPLICATION_JSON)
  public Response editUser(@CookieParam(value = "name") String uid) {

    UserDAO userDAO = Factory.getInstance().getUserDAO();
    SessionDAO sessionDAO = Factory.getInstance().getSessionDAO();

    UserEntity user = userDAO.getById(sessionDAO.haveKey(uid));
    UserDTO userDTO = new UserDTO(user);
    if (user == null) {

      return Response.ok().status(400).build();
    }
    System.out.println(user.getLogin());

    return Response.ok().entity(userDTO).build();
  }
Ejemplo n.º 3
0
 @GET
 @Path("/id")
 @Produces(MediaType.APPLICATION_JSON)
 public Response getUserInfo(@QueryParam("id") int id) {
   UserDAO userDAO = Factory.getInstance().getUserDAO();
   try {
     UserDTO user = new UserDTO(userDAO.getById(id));
     log.info("GetUser ID: success");
     return Response.ok().entity(user).build();
   } catch (Exception e) {
     log.info("GetUser ID: exception");
     return Response.ok().status(400).build();
   }
 }