Ejemplo n.º 1
0
  public String save() {
    try {
      // before check
      roleChecker.check(model);

      // after invoke
      Role dest = null;

      if (id > 0) {
        dest = roleManager.get(id);
        beanMapper.copy(model, dest);
      } else {
        dest = model;
      }

      if (id == 0) {
        dest.setGlobalId(scopeConnector.findGlobalId(ScopeHolder.getGlobalCode()));
        dest.setLocalId(
            scopeConnector.findLocalId(ScopeHolder.getGlobalCode(), ScopeHolder.getLocalCode()));
      }

      dest.setName(roleDefManager.get(roleDefId).getName());
      dest.setRoleDef(roleDefManager.get(roleDefId));

      roleManager.save(dest);

      addActionMessage(messages.getMessage("core.success.save", "保存成功"));
    } catch (CheckRoleException ex) {
      addActionMessage(ex.getMessage());

      return INPUT;
    }

    return RELOAD;
  }
Ejemplo n.º 2
0
  public String input() {
    if (id > 0) {
      model = roleManager.get(id);
    }

    Long localId =
        scopeConnector.findLocalId(ScopeHolder.getGlobalCode(), ScopeHolder.getLocalCode());
    roleDefs = roleDefManager.find("from RoleDef where localId=?", localId);

    List<LocalScopeDTO> localScopeDtos = scopeConnector.findSharedLocalScopes();

    for (LocalScopeDTO localScopeDto : localScopeDtos) {
      roleDefs.addAll(roleDefManager.find("from RoleDef where localId=?", localScopeDto.getId()));
    }

    List<Role> roles = roleManager.findBy("localId", localId);
    List<RoleDef> removedRoleDefs = new ArrayList<RoleDef>();

    for (Role role : roles) {
      for (RoleDef roleDef : roleDefs) {
        if (roleDef.getId().equals(role.getRoleDef().getId())) {
          removedRoleDefs.add(roleDef);

          break;
        }
      }
    }

    roleDefs.removeAll(removedRoleDefs);

    return INPUT;
  }
Ejemplo n.º 3
0
  public String list() {
    List<PropertyFilter> propertyFilters =
        PropertyFilter.buildFromHttpRequest(ServletActionContext.getRequest());
    Long localId =
        scopeConnector.findLocalId(ScopeHolder.getGlobalCode(), ScopeHolder.getLocalCode());
    propertyFilters.add(new PropertyFilter("EQL_localId", Long.toString(localId)));
    page = roleManager.pagedQuery(page, propertyFilters);

    return SUCCESS;
  }
Ejemplo n.º 4
0
  public void checkName() throws Exception {
    Long localId =
        scopeConnector.findLocalId(ScopeHolder.getGlobalCode(), ScopeHolder.getLocalCode());
    String hql = "from Role where localId=" + localId + " and name=?";
    Object[] params = {name};

    if (id != 0L) {
      hql = "from Role where localId=" + localId + " and name=? and id<>?";
      params = new Object[] {name, id};
    }

    boolean result = roleManager.findUnique(hql, params) == null;
    ServletActionContext.getResponse().getWriter().write(Boolean.toString(result));
  }