public class UsersAndRoles
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
| protected DbHelper | dbHelperThe db helper. | 
| protected org.apache.log4j.Logger | loggerThe logger. | 
| protected static java.lang.String | PROP_FILEThe Constant PROP_FILE. | 
| protected static TraceLogBuffer | traceThe trace. | 
| Constructor and Description | 
|---|
| UsersAndRoles()Default ctor. | 
| UsersAndRoles(java.lang.String host,
             java.lang.String database,
             java.lang.String driver,
             java.lang.String user,
             java.lang.String password)Connect to the database. | 
| Modifier and Type | Method and Description | 
|---|---|
| DashInfoObject | addDashboard(DashInfoObject dio)Insert a user dashboard (Standalone). | 
| protected int | addDashboard(java.lang.String name,
            int owner,
            byte[] bytes,
            int published)Insert a dashboard (Standalone). | 
| DashInfoObject | addGroupDashboard(DashInfoObject dio)Insert a group dashboard (Standalone). | 
| SlideShowInfoObject | addSlideShow(SlideShowInfoObject ssio)Adds the slide show. | 
| protected int | addSlideShow(java.lang.String name,
            int owner,
            java.util.ArrayList<DashInfoObject> views,
            boolean published)Adds the slide show. | 
| boolean | addUser(UserInfoObject user)Add a user to the table. | 
| boolean | addUserRole(int userID,
           int roleID)Standalone (Connect/Disconnect) Add a relationship between a user and a role. | 
| protected boolean | addUserRolePrivate(int userID,
                  int roleID)Add a relationship between a user and a role. | 
| UserInfoObject | attemptAutoLogin()Attempt auto login. | 
| protected RoleTree | buildRoleHierarchy()Build a java tree based on the information in the role table (Standalone). | 
| void | checkForColumn(java.lang.String columnName,
              java.lang.String tableName,
              java.lang.String properties)Check to see that a column in a table exists. | 
| protected void | connect()Connect to the database using the properties file or default data | 
| protected void | connect(java.lang.String host,
       java.lang.String database,
       java.lang.String driver,
       java.lang.String user,
       java.lang.String password)Connect to the database | 
| void | createDatabase()(Standalone) Create database. | 
| void | createTables()(Standalone) Create all the tables for this database. | 
| java.lang.String | deleteDashboard(DashInfoObject dio)Delete dashboard. | 
| boolean | deleteDashboard(int id)Delete dashboard. | 
| boolean | deleteRoleDashboards(int roleId)Delete role dashboards. | 
| boolean | deleteSlideShow(int id)Delete slide show. | 
| boolean | deleteUser(int id)Delete the user information, based on id | 
| protected void | disconnect()Disconnect from the database. | 
| void | dropDatabase()(Standalone) Create database. | 
| void | dropTables()(Standalone) Delete all the tables in this database. | 
| java.util.List<RoleInfoObject> | getAllRoles()return all roles and related data (users and tables) from database | 
| protected DbTable | getAllRolesTable()Return a DbTable with all role information (Not Standalone). | 
| java.util.List<TableInfoObject> | getAllTables()return all Tables and related data (users and roles) from database | 
| java.util.List<UserInfoObject> | getAllUsers()return all users and related data (roles and tables) from database | 
| java.util.List<UserInfoObject> | getAllUsersInfo()return all users with roles and table information | 
| java.util.List<UserInfoObject> | getAllUsersRoles()return all users and roles | 
| DashInfoObject | getDashboard(int id)(Standalone). | 
| FlexTreeObject | getDashboardTree(java.lang.String mode)(Standalone) Get a tree that organizes the dashboards by user. | 
| DashInfoObject | getGroupDashboard(int id)(Standalone). | 
| FlexTreeObject | getGroupDashboardTree(UserInfoObject uio)(Standalone) Get a tree that organizes the dashboards by role visible to user. | 
| private java.lang.String | getLoginByDN(java.lang.String userDN)Gets the login by Distinguished Name. | 
| int | getRoleId(java.lang.String name)Get the UID for a role by name (Standalone). | 
| RoleInfoObject | getRoleRoot()(Standalone) get the Role Tree. | 
| protected java.util.List<RoleInfoObject> | getRolesByTable(int tableId)return all roles matching table id | 
| protected java.util.List<RoleInfoObject> | getRolesByUser(int userId)return all roles related to the UserId | 
| java.util.List<java.lang.String> | getRoleTables(RoleInfoObject role)Gets the role tables. | 
| FlexTreeObject | getRoleTree()Deprecated.   | 
| SlideShowInfoObject | getSlideShow(int id)Gets the slide show. | 
| FlexTreeObject | getSlideShowTree(java.lang.String mode)Gets the slide show tree. | 
| protected java.util.List<TableInfoObject> | getTablesByRole(int roleId)Gets the tables by role. | 
| protected java.util.List<TableInfoObject> | getTablesByUser(int userId)return all tables matching user ID | 
| FlexTreeObject | getTablesTree(java.lang.String mode)(Standalone) Get a tree that organises the dashboards. | 
| protected UserInfoObject | getUIO(java.lang.String login)Gets the UserInfoObject associated with a login. | 
| FlexTreeObject | getUserDashboardTree(int id,
                    java.lang.String mode)(Standalone). | 
| private java.lang.String | getUserDNfromSession(flex.messaging.FlexSession mySession)Retrieves the user's Distinguished Name from the session. | 
| UserInfoObject | getUserInfo(java.lang.String login)Gets the UserInfoObject associated with a login. | 
| UserInfoObject | getUserInfo(java.lang.String login,
           boolean updateDN)Gets the UserInfoObject associated with a login. | 
| java.util.List<java.lang.String> | getUserRoles(UserInfoObject user)Gets the user roles. | 
| protected java.util.List<UserInfoObject> | getUsersByRole(int roleId)returns all users matching role ID | 
| protected java.util.List<UserInfoObject> | getUsersByTable(int tableId)return all users matching table ID | 
| java.util.List<java.lang.String> | getUserTables(UserInfoObject user)returns list of tables matching users roles. | 
| java.lang.String | getVersion()Simple method just to make sure that everything is working. | 
| static void | main(java.lang.String[] args)The main method. | 
| void | printTable(java.lang.String tableName)Print out the values of a table in the databse. | 
| protected void | saveSlides(java.sql.Connection conn,
          int ssID,
          java.util.ArrayList<DashInfoObject> slides)Save slides. | 
| void | setRoleRoot(RoleInfoObject root)Clear and repopulate the role table. | 
| private boolean | setUserDN(java.lang.String loginID,
         java.lang.String userDN)Updates the user_DN entry in the database. | 
| DashInfoObject | updateDashboard(DashInfoObject dio)(Standalone) Update an existing dashboard. | 
| RoleInfoObject | updateRoleRelation(RoleInfoObject role)Update role relation. | 
| boolean | updateRoleRoot(RoleInfoObject newRoot)Update the current role tree based on the passed-in root. | 
| boolean | updateRoleTree(RoleInfoObject newRoot,
              RoleInfoObject oldRoot)Update the old role tree based on the new role tree. | 
| SlideShowInfoObject | updateSlideShow(SlideShowInfoObject ssio)Update slide show. | 
| TableInfoObject | updateTableRelation(TableInfoObject table)Update table relation. | 
| void | updateTables()(Standalone) Create new tables that have been added to the database lately. | 
| boolean | updateUser(UserInfoObject user)Standalone (connect and disconnect). | 
| boolean | updateUserPreferences(UserInfoObject user)Standalone method to update user's xml that contains their preferences. | 
| UserInfoObject | updateUserRelation(UserInfoObject user)update user related data (roles and tables) | 
| void | useConsoleLogger()Use console logger. | 
protected DbHelper dbHelper
protected static TraceLogBuffer trace
protected static final java.lang.String PROP_FILE
protected org.apache.log4j.Logger logger
public UsersAndRoles()
public UsersAndRoles(java.lang.String host,
             java.lang.String database,
             java.lang.String driver,
             java.lang.String user,
             java.lang.String password)
              throws java.lang.Exception
host - the hostdatabase - the databasedriver - the driveruser - the userpassword - the passwordjava.lang.Exception - the exceptionpublic void useConsoleLogger()
public java.lang.String getVersion()
public java.util.List<UserInfoObject> getAllUsers()
public java.util.List<RoleInfoObject> getAllRoles()
public java.util.List<TableInfoObject> getAllTables()
public java.util.List<UserInfoObject> getAllUsersRoles()
public java.util.List<UserInfoObject> getAllUsersInfo()
protected java.util.List<RoleInfoObject> getRolesByUser(int userId)
userId - - User Id to matchprotected java.util.List<RoleInfoObject> getRolesByTable(int tableId)
tableId - - table ID to matchprotected java.util.List<TableInfoObject> getTablesByUser(int userId)
userId - - user id to matchprotected java.util.List<UserInfoObject> getUsersByRole(int roleId)
roleId - - role ID to matchprotected java.util.List<UserInfoObject> getUsersByTable(int tableId)
tableId - - table ID to matchpublic UserInfoObject updateUserRelation(UserInfoObject user)
user - - user information to updateprotected UserInfoObject getUIO(java.lang.String login)
login - the loginpublic UserInfoObject getUserInfo(java.lang.String login)
login - the loginpublic UserInfoObject getUserInfo(java.lang.String login, boolean updateDN)
login - the loginupdateDN - the Distinguished Name flagpublic boolean addUser(UserInfoObject user)
user - the userpublic boolean deleteUser(int id)
id - the id of the user to deletepublic boolean updateUser(UserInfoObject user)
user - the userpublic boolean updateUserPreferences(UserInfoObject user)
user - the userpublic DashInfoObject addDashboard(DashInfoObject dio)
dio - - DashInfoObjectpublic DashInfoObject addGroupDashboard(DashInfoObject dio)
dio - - DashInfoObjectprotected int addDashboard(java.lang.String name,
               int owner,
               byte[] bytes,
               int published)
name - the nameowner - the ownerbytes - the datapublished - true if published, false otherwisepublic DashInfoObject getDashboard(int id)
id - the idpublic DashInfoObject getGroupDashboard(int id)
id - the idpublic boolean deleteDashboard(int id)
id - the idpublic boolean deleteRoleDashboards(int roleId)
roleId - the role idpublic DashInfoObject updateDashboard(DashInfoObject dio)
dio - the diopublic java.lang.String deleteDashboard(DashInfoObject dio)
dio - the diopublic FlexTreeObject getDashboardTree(java.lang.String mode)
mode - the modepublic FlexTreeObject getTablesTree(java.lang.String mode)
mode - the modepublic FlexTreeObject getUserDashboardTree(int id, java.lang.String mode)
id - the idmode - the modepublic FlexTreeObject getGroupDashboardTree(UserInfoObject uio)
uio - - UserInfoObject with role informationpublic SlideShowInfoObject addSlideShow(SlideShowInfoObject ssio)
ssio - the ssioprotected int addSlideShow(java.lang.String name,
               int owner,
               java.util.ArrayList<DashInfoObject> views,
               boolean published)
name - the nameowner - the ownerviews - the viewspublished - the publishedprotected void saveSlides(java.sql.Connection conn,
              int ssID,
              java.util.ArrayList<DashInfoObject> slides)
                   throws java.lang.Exception
conn - the database connectionssID - the slide show idslides - ArrayListjava.lang.Exception - if the DB prepared statement failspublic boolean deleteSlideShow(int id)
id - the id of the slide showpublic SlideShowInfoObject updateSlideShow(SlideShowInfoObject ssio)
ssio - the SlideShowInfoObjectpublic SlideShowInfoObject getSlideShow(int id)
id - the id of the slide showpublic FlexTreeObject getSlideShowTree(java.lang.String mode)
mode - (unused)protected java.util.List<TableInfoObject> getTablesByRole(int roleId)
roleId - the role idpublic TableInfoObject updateTableRelation(TableInfoObject table)
table - the tablepublic RoleInfoObject updateRoleRelation(RoleInfoObject role)
role - the rolepublic boolean addUserRole(int userID,
                  int roleID)
userID - the user idroleID - the role idprotected boolean addUserRolePrivate(int userID,
                         int roleID)
userID - the user idroleID - the role idpublic int getRoleId(java.lang.String name)
name - the nameprotected DbTable getAllRolesTable()
public FlexTreeObject getRoleTree()
public RoleInfoObject getRoleRoot()
public void setRoleRoot(RoleInfoObject root)
root - the new role rootprotected RoleTree buildRoleHierarchy()
public boolean updateRoleRoot(RoleInfoObject newRoot)
newRoot - the new rootpublic boolean updateRoleTree(RoleInfoObject newRoot, RoleInfoObject oldRoot)
newRoot - the new rootoldRoot - the old rootpublic java.util.List<java.lang.String> getUserTables(UserInfoObject user)
user - the userpublic java.util.List<java.lang.String> getUserRoles(UserInfoObject user)
user - the userpublic java.util.List<java.lang.String> getRoleTables(RoleInfoObject role)
role - the roleprotected void connect()
protected void connect(java.lang.String host,
           java.lang.String database,
           java.lang.String driver,
           java.lang.String user,
           java.lang.String password)
                throws java.lang.Exception
host - the hostdatabase - the databasedriver - the driveruser - the userpassword - the passwordjava.lang.Exception - the exceptionprotected void disconnect()
public void checkForColumn(java.lang.String columnName,
                  java.lang.String tableName,
                  java.lang.String properties)
columnName - the column nametableName - the table nameproperties - the propertiespublic void dropTables()
public void createDatabase()
public void dropDatabase()
public void createTables()
public void updateTables()
public UserInfoObject attemptAutoLogin()
private java.lang.String getUserDNfromSession(flex.messaging.FlexSession mySession)
mySession - the FlexSessionprivate java.lang.String getLoginByDN(java.lang.String userDN)
userDN - the user Distinguished Nameprivate boolean setUserDN(java.lang.String loginID,
                java.lang.String userDN)
loginID - the login iduserDN - the user Distinguished Namepublic void printTable(java.lang.String tableName)
tableName - the table namepublic static void main(java.lang.String[] args)
args - the arguments