예제 #1
0
 private void addPolicyAdminPrivilege(Locale locale) throws EntityExistException {
   Privilege privilege = new Privilege();
   privilege.setType(Privilege.BUSINESS_PRIVILEGE);
   privilege.setIsLeaf(true);
   privilege.setId(Privilege.POLICY_ADMIN_ID);
   privilege.setPid(Privilege.RALASAFE_ADMIN_ID);
   privilege.setDescription(Util.getMessage(locale, ResourceConstants.POLICY_ADMIN_DESCRIPTION));
   privilege.setName(Util.getMessage(locale, ResourceConstants.POLICY_ADMIN));
   privilege.setConstantName("POLICY_ADMIN");
   privilege.setOrderNum(1);
   saver.save(privilege);
 }
예제 #2
0
  public void setTable(Table table) {
    this.table = table;

    if (!Util.isEmpty(table.getIdColumns())) {
      deleteSql = DBUtil.deleteSql(table.getName(), table.getIdColumnNames());
    }
  }
  private void deleteSingleValues(Connection[] conns, TableDeletorImpl[] deletors, Object o) {
    if (Util.isEmpty(deletors)) {
      return;
    }

    for (int i = 0; i < deletors.length; i++) {
      deletors[i].deleteByIdColumns(o);
    }
  }
예제 #4
0
 private void addRalasafeAdminPrivilege(Locale locale) throws EntityExistException {
   Privilege privilege = new Privilege();
   privilege.setType(Privilege.BUSINESS_PRIVILEGE);
   privilege.setIsLeaf(false);
   privilege.setId(Privilege.RALASAFE_ADMIN_ID);
   privilege.setPid(Privilege.BUSINESS_PRIVILEGE_TREE_ROOT_ID);
   privilege.setName(Util.getMessage(locale, ResourceConstants.RALASAFE_ADMIN));
   privilege.setOrderNum(0);
   saver.save(privilege);
 }
예제 #5
0
 private void addRoleAdminPrivilege(Locale locale) throws EntityExistException {
   Privilege privilege = new Privilege();
   privilege.setType(Privilege.BUSINESS_PRIVILEGE);
   privilege.setIsLeaf(true);
   privilege.setId(Privilege.ROLE_ADMIN_ID);
   privilege.setPid(Privilege.RALASAFE_ADMIN_ID);
   privilege.setName(Util.getMessage(locale, ResourceConstants.ROLE_ADMIN));
   privilege.setConstantName("ROLE_ADMIN");
   privilege.setOrderNum(3);
   saver.save(privilege);
 }
예제 #6
0
 private void addAssignRoleToUserPrivilege(Locale locale) throws EntityExistException {
   Privilege privilege = new Privilege();
   privilege.setType(Privilege.BUSINESS_PRIVILEGE);
   privilege.setIsLeaf(true);
   privilege.setId(Privilege.ASSIGN_ROLE_TO_USER_ID);
   privilege.setPid(Privilege.RALASAFE_ADMIN_ID);
   privilege.setName(Util.getMessage(locale, ResourceConstants.ASSIGN_ROLE_TO_USER));
   privilege.setConstantName("ASSIGN_ROLE_TO_USER");
   privilege.setOrderNum(2);
   saver.save(privilege);
 }
예제 #7
0
  public void save(Connection conn, Object o) throws EntityExistException, DBLevelException {
    PreparedStatement pstmt = null;
    try {
      pstmt = conn.prepareStatement(insertSql);
      Column[] columns = table.getColumns();
      for (int i = 0; i < columns.length; i++) {
        Column column = columns[i];
        ColumnAdapter columnAdapter = column.getAdapter();
        columnAdapter.setPreparedStatement(pstmt, i + 1, o);
      }

      pstmt.executeUpdate();
    } catch (SQLException e) {
      logger.error("", e);

      if (conn != null) {
        // violate pk or unique constraints?
        if (!Util.isEmpty(table.getIdColumns())) {
          boolean isExist = selector.isExistByIdColumns(conn, o);
          if (isExist) {
            throw new EntityExistException(o);
          }
        }

        if (!Util.isEmpty(table.getUniqueColumns())) {
          boolean isExist = selector.isExistByUniqueColumns(conn, o);
          if (isExist) {
            throw new EntityExistException(o);
          }
        }

        throw new DBLevelException(e);
      } else {
        throw new DBLevelException(e);
      }
    } finally {
      DBUtil.close(pstmt);
    }
  }
예제 #8
0
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String strUserId = req.getParameter("userId");
    String[] assignRoleIds = req.getParameterValues("roleId");
    Collection roleIds = Util.convert2IntegerCollection(assignRoleIds);

    Object userId = WebUtil.convertUserId(req, strUserId);

    // log
    if (log.isDebugEnabled()) {
      log.debug("userId=" + strUserId + ", assignRoleIds=" + assignRoleIds);
    }

    UserRoleManager userRoleManager = WebUtil.getUserRoleManager(req);
    userRoleManager.assignRoles(userId, roleIds);
  }