⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdbmuseridentitystore.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                      int profileId = rs.getInt("PROFILE_ID");                      String profileName = rs.getString("PROFILE_NAME");                      String description = rs.getString("DESCRIPTION");                                            insertStmt = con.prepareStatement(insert);                      insertStmt.setInt(1, userId);                      insertStmt.setInt(2, profileId);                      insertStmt.setString(3, profileName);                      insertStmt.setString(4, description);                                            log.debug("RDBMUserIdentityStore::updateUser(USER_ID=" + userId + ", PROFILE_ID=" + profileId + ", PROFILE_NAME=" + profileName + ", DESCRIPTION=" + description + "): " + insert);                      insertStmt.executeUpdate();                                        }                  rs.close();                  queryStmt.close();                  insertStmt.close();                                                      // Update UP_USER_UA_MAP                  delete =                      "DELETE FROM UP_USER_UA_MAP " +                      "WHERE USER_ID=?";                  deleteStmt = con.prepareStatement(delete);                  deleteStmt.setInt(1, userId);                  log.debug("RDBMUserIdentityStore::updateUser(USER_ID=" + userId + "): " + delete);                  deleteStmt.executeUpdate();                                    deleteStmt.close();                                                      query =                      "SELECT USER_ID, USER_AGENT, PROFILE_ID " +                      "FROM UP_USER_UA_MAP WHERE USER_ID=?";                  queryStmt = con.prepareStatement(query);                  queryStmt.setInt(1, templateUser.getUserId());                  log.debug("RDBMUserIdentityStore::updateUser(USER_ID=" + templateUser.getUserId() + "): " + query);                  rs = queryStmt.executeQuery();                                    while (rs.next()) {                      insert =                          "INSERT INTO UP_USER_UA_MAP (USER_ID, USER_AGENT, PROFILE_ID) " +                          "VALUES(?, ?, ?)";                                            String userAgent = rs.getString("USER_AGENT");                      String profileId = rs.getString("PROFILE_ID");                                            insertStmt = con.prepareStatement(insert);                      insertStmt.setInt(1, userId);                      insertStmt.setString(2, userAgent);                      insertStmt.setString(3, profileId);                                            log.debug("RDBMUserIdentityStore::updateUser(USER_ID=" + userId + ", USER_AGENT=" + userAgent + ", PROFILE_ID=" + profileId + "): " + insert);                      insertStmt.executeUpdate();                    }                  rs.close();                  queryStmt.close();                  insertStmt.close();                  // If we made it all the way though, commit the transaction                  if (RDBMServices.supportsTransactions)                      con.commit();                                                                        }              finally {                  try { rs.close(); } catch (Exception e) {}              }                                        }          finally {              try { deleteStmt.close(); } catch (Exception e) {}              try { queryStmt.close(); } catch (Exception e) {}              try { insertStmt.close(); } catch (Exception e) {}          }      }      catch (SQLException sqle) {          if (RDBMServices.supportsTransactions)              con.rollback();          throw new AuthorizationException("SQL database error while retrieving user's portal UID", sqle);                 }      finally {          try { RDBMServices.releaseConnection(con); } catch (Exception e) {}      }             return;  }    protected int addNewUser(int newUID, IPerson person, TemplateUser templateUser) throws Exception {      // Copy template user's groups memberships      IGroupMember me = GroupService.getGroupMember(person.getEntityIdentifier());                      IGroupMember template = GroupService.getEntity(templateUser.getUserName(), Class.forName("org.jasig.portal.security.IPerson"));      Iterator templateGroups = template.getContainingGroups();      while (templateGroups.hasNext()) {          IEntityGroup eg = (IEntityGroup)templateGroups.next();          if (eg.isEditable()) {              eg.addMember(me);              eg.updateMembers();          }      }            int uPortalUID = -1;      Connection con = null;      try {          con = RDBMServices.getConnection();          // Turn off autocommit if the database supports it          if (RDBMServices.supportsTransactions)              con.setAutoCommit(false);                  PreparedStatement queryStmt = null;          PreparedStatement insertStmt = null;          try {              // Add to UP_USER              String insert =                  "INSERT INTO UP_USER (USER_ID, USER_NAME, USER_DFLT_USR_ID, USER_DFLT_LAY_ID, NEXT_STRUCT_ID, LST_CHAN_UPDT_DT)" +                  "VALUES (?, ?, ?, ?, null, null)";                            String userName = person.getAttribute(IPerson.USERNAME).toString();                            insertStmt = con.prepareStatement(insert);              insertStmt.setInt(1, newUID);              insertStmt.setString(2, userName);              insertStmt.setInt(3, templateUser.getUserId());              insertStmt.setInt(4, templateUser.getDefaultLayoutId());                            log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + newUID + ", USER_NAME=" + userName + ", USER_DFLT_USR_ID=" + templateUser.getUserId() + ", USER_DFLT_LAY_ID=" + templateUser.getDefaultLayoutId() + "): " + insert);              insertStmt.executeUpdate();              insertStmt.close();              insertStmt = null;                                          // Start copying...              ResultSet rs = null;              String query = null;              try {                                   // Add to UP_USER_PARAM                  query =                      "SELECT USER_ID, USER_PARAM_NAME, USER_PARAM_VALUE " +                      "FROM UP_USER_PARAM " +                      "WHERE USER_ID=?";                  queryStmt = con.prepareStatement(query);                  queryStmt.setInt(1, templateUser.getUserId());                  log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + templateUser.getUserId() + "): " + query);                  rs = queryStmt.executeQuery();                                    while (rs.next()) {                      insert =                           "INSERT INTO UP_USER_PARAM (USER_ID, USER_PARAM_NAME, USER_PARAM_VALUE) " +                          "VALUES(?, ?, ?)";                                  String userParamName = rs.getString("USER_PARAM_NAME");                      String userParamValue = rs.getString("USER_PARAM_VALUE");                                            insertStmt = con.prepareStatement(insert);                      insertStmt.setInt(1, newUID);                      insertStmt.setString(2, userParamName);                      insertStmt.setString(3, userParamValue);                                            log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + newUID + ", USER_PARAM_NAME=" + userParamName + ", USER_PARAM_VALUE=" + userParamValue + "): " + insert);                      insertStmt.executeUpdate();                                          }                  rs.close();                  queryStmt.close();                  if (insertStmt != null) {                    insertStmt.close();                    insertStmt = null;                  }                                   // Add to UP_USER_PROFILE                                      query =                      "SELECT USER_ID, PROFILE_ID, PROFILE_NAME, DESCRIPTION " +                      "FROM UP_USER_PROFILE " +                      "WHERE USER_ID=?";                  queryStmt = con.prepareStatement(query);                  queryStmt.setInt(1, templateUser.getUserId());                  log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + templateUser.getUserId() + "): " + query);                  rs = queryStmt.executeQuery();                                    while (rs.next()) {                      insert =                          "INSERT INTO UP_USER_PROFILE (USER_ID, PROFILE_ID, PROFILE_NAME, DESCRIPTION, LAYOUT_ID, STRUCTURE_SS_ID, THEME_SS_ID) " +                          "VALUES(?, ?, ?, ?, NULL, NULL, NULL)";                                              int profileId = rs.getInt("PROFILE_ID");                      String profileName = rs.getString("PROFILE_NAME");                      String description = rs.getString("DESCRIPTION");                                            insertStmt = con.prepareStatement(insert);                      insertStmt.setInt(1, newUID);                      insertStmt.setInt(2, profileId);                      insertStmt.setString(3, profileName);                      insertStmt.setString(4, description);                                            log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + newUID + ", PROFILE_ID=" + profileId + ", PROFILE_NAME=" + profileName + ", DESCRIPTION=" + description + "): " + insert);                      insertStmt.executeUpdate();                                        }                  rs.close();                  queryStmt.close();                  if (insertStmt != null) {                    insertStmt.close();                    insertStmt = null;                  }                                    query =                      "SELECT USER_ID, USER_AGENT, PROFILE_ID " +                      "FROM UP_USER_UA_MAP WHERE USER_ID=?";                  queryStmt = con.prepareStatement(query);                  queryStmt.setInt(1, templateUser.getUserId());                  log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + templateUser.getUserId() + "): " + query);                  rs = queryStmt.executeQuery();                                    while (rs.next()) {                      insert =                          "INSERT INTO UP_USER_UA_MAP (USER_ID, USER_AGENT, PROFILE_ID) " +                          "VALUES(?, ?, ?)";                                            String userAgent = rs.getString("USER_AGENT");                      String profileId = rs.getString("PROFILE_ID");                                            insertStmt = con.prepareStatement(insert);                      insertStmt.setInt(1, newUID);                      insertStmt.setString(2, userAgent);                      insertStmt.setString(3, profileId);                                            log.debug("RDBMUserIdentityStore::addNewUser(USER_ID=" + newUID + ", USER_AGENT=" + userAgent + ", PROFILE_ID=" + profileId + "): " + insert);                      insertStmt.executeUpdate();                    }                  rs.close();                  rs = null;                  queryStmt.close();                  queryStmt = null;                  if (insertStmt != null) {                    insertStmt.close();                    insertStmt = null;                  }                                    // If we made it all the way though, commit the transaction                  if (RDBMServices.supportsTransactions)                      con.commit();                                    uPortalUID = newUID;                                                    } finally {                  try { if (rs != null) rs.close(); } catch (Exception e) {}              }                                        } finally {              try { if (queryStmt != null) queryStmt.close(); } catch (Exception e) {}              try { if (insertStmt != null) insertStmt.close(); } catch (Exception e) {}          }      } catch (SQLException sqle) {          if (RDBMServices.supportsTransactions)              con.rollback();          throw new AuthorizationException("SQL database error while retrieving user's portal UID", sqle);                 } finally {          try { RDBMServices.releaseConnection(con); } catch (Exception e) {}      }             return uPortalUID;  }  protected class PortalUser {      String userName;      int userId;      int defaultUserId;      public String getUserName() { return userName; }      public int getUserId() { return userId; }      public int getDefaultUserId() { return defaultUserId; }      public void setUserName(String userName) { this.userName = userName; }      public void setUserId(int userId) { this.userId = userId; }      public void setDefaultUserId(int defaultUserId) { this.defaultUserId = defaultUserId; }  }        protected class TemplateUser {      String userName;      int userId;      int defaultLayoutId;      public String getUserName() { return userName; }      public int getUserId() { return userId; }      public int getDefaultLayoutId() { return defaultLayoutId; }      public void setUserName(String userName) { this.userName = userName; }      public void setUserId(int userId) { this.userId = userId; }      public void setDefaultLayoutId(int defaultLayoutId) { this.defaultLayoutId = defaultLayoutId; }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -