Package org.beangle.ems.security

Examples of org.beangle.ems.security.User


public class HomeAction extends SecurityActionSupport {

  private MenuService menuService;

  public String index() {
    User user = entityDao.get(User.class, getUserId());
    List<MenuProfile> profiles = menuService.getProfiles(user);
    if (profiles.isEmpty()) {
      put("menus", Collections.EMPTY_LIST);
    } else {
      MenuProfile profile = menuService.getProfile(user, getLong("security.menuProfileId"));
View Full Code Here


  private UserDashboardHelper userDashboardHelper;

  public String dashboard() {
    Long userId = getLong("user.id");
    User managed = null;
    if (null != userId) {
      managed = entityDao.get(User.class, userId);
    } else {
      String username = get("user.name");
      if (null != username) managed = userService.get(username);
    }
    User me = entityDao.get(User.class, getUserId());
    if (null != managed) {
      if (me.equals(managed) || userService.isManagedBy(me, managed)) {
        userDashboardHelper.buildDashboard(managed);
        return forward();
      } else {
        return forward(ERROR);
      }
View Full Code Here

    }
    return forward();
  }

  protected OqlBuilder<User> getQueryBuilder() {
    User manager = entityDao.get(User.class, getUserId());
    OqlBuilder<User> userQuery = OqlBuilder.from(getEntityName(), "user");
    // 查询用户组
    StringBuilder sb = new StringBuilder("exists(from user.members m where ");
    List<Object> params = CollectUtils.newArrayList();
    boolean queryGroup = false;
View Full Code Here

  /**
   * 保存用户信息
   */
  protected String saveAndForward(Entity<?> entity) {
    User user = (User) entity;
    if (entityDao.duplicate(User.class, user.getId(), "name", user.getName())) {
      addFlashMessageNow("security.error.usernameNotAvaliable", user.getName());
      return forward(new Action(this, "edit"));
    }
    String errorMsg = "";
    // 检验用户合法性
    errorMsg = checkUser(user);
    if (StringUtils.isNotEmpty(errorMsg)) { return forward(new Action("edit"), errorMsg); }
    processPassword(user);
    if (!user.isPersisted()) {
      User creator = userService.get(getUserId());
      userService.createUser(creator, user);
    } else {
      userService.saveOrUpdate(user);
    }
    updateUserGroup(user);
View Full Code Here

  public int updateState(final User manager, Long[] ids, final boolean enabled) {
    assert (null == ids || ids.length < 1);
    @SuppressWarnings("unchecked")
    List<User> users = (List<User>) CollectionUtils.select(getUsers(ids), new Predicate() {
      public boolean evaluate(Object object) {
        User one = (User) object;
        return isManagedBy(manager, one) && !manager.equals(one) && (one.isEnabled() != enabled);
      }
    });

    for (int i = 0; i < users.size(); i++) {
      User cur = users.get(i);
      cur.setEnabled(enabled);
    }
    if (!users.isEmpty()) {
      entityDao.saveOrUpdate(users);
      publish(new UserStatusEvent(users, enabled));
    }
View Full Code Here

    for (GroupMember gm : userMembers) {
      memberMap.put(gm.getGroup(), gm);
    }
    Set<GroupMember> newMembers = CollectUtils.newHashSet();
    Set<GroupMember> removedMembers = CollectUtils.newHashSet();
    User manager = entityDao.get(User.class, getUserId());
    Collection<GroupMember> members = userService.getGroupMembers(manager, GroupMember.Ship.GRANTER);
    for (GroupMember member : members) {
      GroupMember myMember = memberMap.get(member.getGroup());
      boolean isMember = getBool("member" + member.getGroup().getId());
      boolean isGranter = getBool("granter" + member.getGroup().getId());
View Full Code Here

    }
    entityDao.execute(Operation.saveOrUpdate(newMembers).remove(removedMembers));
  }

  protected void editSetting(Entity<?> entity) {
    User user = (User) entity;
    User manager = entityDao.get(User.class, getUserId());
    Collection<GroupMember> members = userService.getGroupMembers(manager, GroupMember.Ship.GRANTER);
    Set<GroupMember> userMembers = user.getMembers();
    Map<Group, GroupMember> memberMap = CollectUtils.newHashMap();
    for (GroupMember gm : userMembers) {
      memberMap.put(gm.getGroup(), gm);
View Full Code Here

   *
   * @return
   */
  public String remove() {
    Long[] userIds = getEntityIds();
    User creator = userService.get(getUserId());
    List<User> toBeRemoved = userService.getUsers(userIds);
    StringBuilder sb = new StringBuilder();
    User removed = null;
    int success = 0;
    int expected = toBeRemoved.size();
    try {
      for (User one : toBeRemoved) {
        removed = one;
        // 不能删除自己
        if (!one.getId().equals(getUserId())) {
          userService.removeUser(creator, one);
          success++;
        } else {
          addFlashError("security.info.cannotRemoveSelf");
          expected--;
        }
      }
    } catch (Exception e) {
      sb.append(',').append(removed.getName());
    }
    if (sb.length() > 0) {
      sb.deleteCharAt(0);
      addFlashMessage("security.info.userRemovePartial", success, sb);
    } else if (expected == success && success > 0) {
View Full Code Here

   */
  public String activate() {
    Long[] userIds = getEntityIds();
    String isActivate = get("isActivate");
    int successCnt;
    User manager = userService.get(getUserId());
    String msg = "security.info.freeze.success";
    if (StringUtils.isNotEmpty(isActivate) && "false".equals(isActivate)) {
      successCnt = userService.updateState(manager, userIds, false);
    } else {
      msg = "security.info.activate.success";
View Full Code Here

  }

  public String info() throws Exception {
    String name = get("name");
    if (StringUtils.isNotBlank(name)) {
      User user = userService.get(name);
      if (null != user) {
        put("user", user);
        return forward(new Action((Class<?>) null, "dashboard", "&user.id=" + user.getId()));
      } else {
        return null;
      }
    } else {
      return super.info();
View Full Code Here

TOP

Related Classes of org.beangle.ems.security.User

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.