use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.
the class GetUserListTask method getResultModel.
/**
* get DbUserInfoList
* @return DbUserInfoList
*/
public DbUserInfoList getResultModel() {
DbUserInfoList dbUserInfoList = new DbUserInfoList();
dbUserInfoList.setDbname(databaseInfo.getDbName());
buildUserInfo(dbUserInfoList);
finish();
return dbUserInfoList;
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.
the class GetUserListTask method buildUserInfo.
/**
*
* Build the database user information
*
* @param dbUserInfoList DbUserInfoList
* @throws SQLException The exception
*/
private void buildUserInfo(DbUserInfoList dbUserInfoList) {
Map<String, String> oidMap = new HashMap<String, String>();
Map<String, List<String>> groupMap = new HashMap<String, List<String>>();
String sql = "SELECT db_user, name, groups FROM db_user";
// [TOOLS-2425]Support shard broker
sql = databaseInfo.wrapShardQuery(sql);
try {
stmt = connection.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
String oidStr = rs.getString(1);
String name = rs.getString(2);
CUBRIDResultSetProxy cubridRS = (CUBRIDResultSetProxy) rs;
Object[] objs = (Object[]) cubridRS.getCollection(3);
List<String> groups = new ArrayList<String>();
for (Object obj : objs) {
if (obj != null && obj.getClass() == CUBRIDOIDProxy.getCUBRIDOIDClass(cubridRS.getJdbcVersion())) {
groups.add((new CUBRIDOIDProxy(obj)).getOidString());
}
}
if (name != null) {
name = name.toLowerCase(Locale.getDefault());
}
oidMap.put(oidStr, name);
groupMap.put(name, groups);
DbUserInfo dbUserInfo = new DbUserInfo();
dbUserInfo.setDbName(databaseInfo.getDbName());
dbUserInfo.setName(name);
dbUserInfo.addAuthorization(new HashMap<String, String>());
dbUserInfoList.addUser(dbUserInfo);
}
} catch (SQLException ex) {
errorMsg = ex.getMessage();
} finally {
QueryUtil.freeQuery(stmt, rs);
}
// get the group user
if (dbUserInfoList.getUserList() != null) {
for (DbUserInfo userInfo : dbUserInfoList.getUserList()) {
UserGroup userGroup = userInfo.getGroups();
if (userGroup == null) {
userGroup = new UserGroup();
userInfo.addGroups(userGroup);
}
List<String> groupOIDList = groupMap.get(userInfo.getName());
for (String groupOID : groupOIDList) {
String groupUser = oidMap.get(groupOID);
if (groupUser != null) {
userInfo.getGroups().addGroup(groupUser);
}
}
}
}
//get the member user
// for (DbUserInfo userInfo : dbUserInfoList.getUserList()) {
// List<String> groupNameList = userInfo.getGroupList();
// for (String groupName : groupNameList) {
// User groupUser = catalog.getUserByName(groupName);
// if (groupUser != null) {
// ((CUBRIDUser) groupUser).addMember(user.getName());
// }
// }
// }
}
use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.
the class UserEditor method loadData.
/**
*
* Load data
*
* @return <code>true</code> if it is successfully;<code>false</code>
* otherwise
*/
public boolean loadData() {
final CommonQueryTask<DbUserInfoList> userTask = new CommonQueryTask<DbUserInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbUserInfoList(), database.getDatabaseInfo().getCharSet());
userTask.setDbName(database.getName());
final GetAllClassListTask classInfoTask = new GetAllClassListTask(database.getDatabaseInfo());
final GetAllPartitionClassTask partitionTask = new GetAllPartitionClassTask(database.getDatabaseInfo());
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
if (t instanceof GetAllClassListTask) {
allClassInfoList = ((GetAllClassListTask) t).getAllClassInfoList();
} else {
t.execute();
}
if (t instanceof CommonQueryTask) {
userListInfo = ((CommonQueryTask<DbUserInfoList>) t).getResultModel();
}
if (t instanceof GetAllPartitionClassTask) {
partitionClassMap = ((GetAllPartitionClassTask) t).getPartitionClassMap();
}
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
Display.getDefault().syncExec(new Runnable() {
public void run() {
initial();
}
});
return Status.OK_STATUS;
}
};
taskJobExecutor.addTask(userTask);
taskJobExecutor.addTask(classInfoTask);
taskJobExecutor.addTask(partitionTask);
String jobName = Messages.viewUserInfoJobName + " - " + userName + "@" + database.getName() + "@" + database.getServer().getName();
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
return true;
}
Aggregations