Package com.commafeed.frontend.model

Examples of com.commafeed.frontend.model.UserModel


  @Path("/profile")
  @GET
  @UnitOfWork
  @ApiOperation(value = "Retrieve user's profile", response = UserModel.class)
  public Response get(@SecurityCheck User user) {
    UserModel userModel = new UserModel();
    userModel.setId(user.getId());
    userModel.setName(user.getName());
    userModel.setEmail(user.getEmail());
    userModel.setEnabled(!user.isDisabled());
    userModel.setApiKey(user.getApiKey());
    for (UserRole role : userRoleDAO.findAll(user)) {
      if (role.getRole() == Role.ADMIN) {
        userModel.setAdmin(true);
      }
    }
    return Response.ok(userModel).build();
  }
View Full Code Here


  @UnitOfWork
  @ApiOperation(value = "Get user information", notes = "Get user information", response = UserModel.class)
  public Response getUser(@SecurityCheck(Role.ADMIN) User user, @ApiParam(value = "user id", required = true) @PathParam("id") Long id) {
    Preconditions.checkNotNull(id);
    User u = userDAO.findById(id);
    UserModel userModel = new UserModel();
    userModel.setId(u.getId());
    userModel.setName(u.getName());
    userModel.setEmail(u.getEmail());
    userModel.setEnabled(!u.isDisabled());
    for (UserRole role : userRoleDAO.findAll(u)) {
      if (role.getRole() == Role.ADMIN) {
        userModel.setAdmin(true);
      }
    }
    return Response.ok(userModel).build();
  }
View Full Code Here

  public Response getUsers(@SecurityCheck(Role.ADMIN) User user) {
    Map<Long, UserModel> users = Maps.newHashMap();
    for (UserRole role : userRoleDAO.findAll()) {
      User u = role.getUser();
      Long key = u.getId();
      UserModel userModel = users.get(key);
      if (userModel == null) {
        userModel = new UserModel();
        userModel.setId(u.getId());
        userModel.setName(u.getName());
        userModel.setEmail(u.getEmail());
        userModel.setEnabled(!u.isDisabled());
        userModel.setCreated(u.getCreated());
        userModel.setLastLogin(u.getLastLogin());
        users.put(key, userModel);
      }
      if (role.getRole() == Role.ADMIN) {
        userModel.setAdmin(true);
      }
    }
    return Response.ok(users.values()).build();
  }
View Full Code Here

TOP

Related Classes of com.commafeed.frontend.model.UserModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.