Source:
public void updateHybridRoleListOfUser(String user, String[] deletedRoles, String[] addRoles) throws UserStoreException { String sqlStmt1 = HybridJDBCConstants.REMOVE_ROLE_FROM_USER_SQL; String sqlStmt2 = HybridJDBCConstants.ADD_ROLE_TO_USER_SQL; Connection dbConnection = null; try { user = UserCoreUtil.addDomainToName(user, getMyDomainName()); String domain = UserCoreUtil.extractDomainFromName(user); dbConnection = getDBConnection(); String type = DatabaseCreator.getDatabaseType(dbConnection); if (UserCoreConstants.MSSQL_TYPE.equals(type)) { sqlStmt2 = HybridJDBCConstants.ADD_ROLE_TO_USER_SQL_MSSQL; } if (domain!=null){ domain = domain.toUpperCase(); } if (deletedRoles != null && deletedRoles.length > 0) { DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt1, deletedRoles, tenantId, UserCoreUtil.removeDomainFromName(user), tenantId, tenantId, domain); } if (addRoles != null && addRoles.length > 0) { if (UserCoreConstants.OPENEDGE_TYPE.equals(type)) { sqlStmt2 = HybridJDBCConstants.ADD_ROLE_TO_USER_SQL_OPENEDGE; DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2, user, tenantId, addRoles, tenantId); } else { DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2, addRoles, tenantId, UserCoreUtil.removeDomainFromName(user), tenantId, tenantId, domain); } } dbConnection.commit(); } catch (SQLException e) { String errorMessage = "Error occurred while updating Hybrid role list of user :"+user; throw new UserStoreException(errorMessage, e); } catch (Exception e) { String errorMessage = "Error occurred while getting database type from db connection"; throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection); } if (deletedRoles != null && deletedRoles.length > 0) { userRealm.getAuthorizationManager().clearUserAuthorization(user); } }

Target:
public void updateHybridRoleListOfUser(String user, String[] deletedRoles, String[] addRoles) throws UserStoreException { String sqlStmt1 = HybridJDBCConstants.REMOVE_ROLE_FROM_USER_SQL; String sqlStmt2 = HybridJDBCConstants.ADD_ROLE_TO_USER_SQL; Connection dbConnection = null; try { user = UserCoreUtil.addDomainToName(user, getMyDomainName()); String domain = UserCoreUtil.extractDomainFromName(user); dbConnection = getDBConnection(); String type = DatabaseCreator.getDatabaseType(dbConnection); if (UserCoreConstants.MSSQL_TYPE.equals(type)) { sqlStmt2 = HybridJDBCConstants.ADD_ROLE_TO_USER_SQL_MSSQL; } if (domain!=null){ domain = domain.toUpperCase(); } if (deletedRoles != null && deletedRoles.length > 0) { DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt1, deletedRoles, tenantId, UserCoreUtil.removeDomainFromName(user), tenantId, tenantId, domain); } if (addRoles != null && addRoles.length > 0) { if (UserCoreConstants.OPENEDGE_TYPE.equals(type)) { sqlStmt2 = HybridJDBCConstants.ADD_ROLE_TO_USER_SQL_OPENEDGE; DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2, user, tenantId, addRoles, tenantId); } else { DatabaseUtil.udpateUserRoleMappingInBatchMode(dbConnection, sqlStmt2, addRoles, tenantId, UserCoreUtil.removeDomainFromName(user), tenantId, tenantId, domain); } } dbConnection.commit(); } catch (SQLException e) { String errorMessage = "Error occurred while updating Hybrid role list of user : " + user; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } catch (Exception e) { String errorMessage = "Error occurred while getting database type from db connection"; if (log.isDebugEnabled()) { log.debug(errorMessage, e); } throw new UserStoreException(errorMessage, e); } finally { DatabaseUtil.closeAllConnections(dbConnection); } if (deletedRoles != null && deletedRoles.length > 0) { userRealm.getAuthorizationManager().clearUserAuthorization(user); } }