use of com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask in project cubrid-manager by CUBRID.
the class EditUserDialog method buttonPressed.
/**
* When press button,call it
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
if (!valid()) {
return;
}
boolean isChangePassword = false;
if (newFlag) {
isChangePassword = true;
} else if (changePwdBtn.getSelection()) {
isChangePassword = true;
}
String password = null;
if (isChangePassword) {
password = pwdText.getText();
if (password == null) {
password = "";
}
}
this.inputtedPassword = password;
boolean isNoDbaAuthUser = database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName().equalsIgnoreCase(userName) && !database.getDatabaseInfo().getAuthLoginedDbUserInfo().isDbaAuthority();
String taskName = Messages.bind(Messages.addOrUpdateUserTaskName, userNameText.getText());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
ITask task = null;
boolean isDropAndCreateUser = false;
if (isNoDbaAuthUser) {
if (isChangePassword) {
task = new ChangeDbUserPwdTask(database.getDatabaseInfo());
ChangeDbUserPwdTask changeDbUserPwdTask = (ChangeDbUserPwdTask) task;
changeDbUserPwdTask.setDbUserName(userName);
changeDbUserPwdTask.setNewPwd(password);
taskExecutor.addTask(changeDbUserPwdTask);
} else {
super.buttonPressed(IDialogConstants.CANCEL_ID);
return;
}
} else {
if (newFlag) {
List<String> groupList = new ArrayList<String>();
for (int i = 0; i < userGroupTable.getItemCount(); i++) {
groupList.add(userGroupTable.getItem(i).getText(0));
}
List<String> memberList = new ArrayList<String>();
for (Map<String, String> map : memberListData) {
memberList.add(map.get("0").toLowerCase(Locale.getDefault()));
}
task = new CreateUserTask(database.getDatabaseInfo(), userNameText.getText(), pwdText.getText(), groupList, memberList);
taskExecutor.addTask(task);
} else {
if (!groupChange()) {
task = new DropUserTask(database.getDatabaseInfo(), userName);
taskExecutor.addTask(task);
List<String> groupList = new ArrayList<String>();
for (int i = 0; i < userGroupTable.getItemCount(); i++) {
groupList.add(userGroupTable.getItem(i).getText(0));
}
List<String> memberList = new ArrayList<String>();
for (Map<String, String> map : memberListData) {
memberList.add(map.get("0").toLowerCase(Locale.getDefault()));
}
task = new CreateUserTask(database.getDatabaseInfo(), userNameText.getText(), pwdText.getText(), groupList, memberList);
taskExecutor.addTask(task);
isDropAndCreateUser = true;
} else if (isChangePassword) {
task = new ChangeDbUserPwdTask(database.getDatabaseInfo());
ChangeDbUserPwdTask changeDbUserPwdTask = (ChangeDbUserPwdTask) task;
changeDbUserPwdTask.setDbUserName(userName);
changeDbUserPwdTask.setNewPwd(password);
taskExecutor.addTask(task);
}
}
}
task = new UpdateAddUserJdbcTask(database.getDatabaseInfo(), userNameText.getText(), classGrantMap, authListData, authListDataOld, isDBAGroup(), isDropAndCreateUser);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess() && isChangePassword && database.getDatabaseInfo().getAuthLoginedDbUserInfo().getName().equalsIgnoreCase(userName)) {
database.getDatabaseInfo().getAuthLoginedDbUserInfo().setNoEncryptPassword(password);
}
if (taskExecutor.isSuccess()) {
String message = null;
if (newFlag) {
message = Messages.msgAddUserSuccess;
} else {
message = Messages.msgModifyUserSuccess;
}
CommonUITool.openInformationBox(Messages.msgInformation, message);
} else {
return;
}
}
super.buttonPressed(buttonId);
}
use of com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask in project cubrid-manager by CUBRID.
the class DeleteUserAction method doRun.
public void doRun(ISchemaNode node) {
// FIXME move this logic to core module
CubridDatabase database = node.getDatabase();
if (database == null || node == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
String childId = database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridNodeLoader.USERS_FOLDER_ID;
ICubridNode folderNode = database.getChild(childId);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
// if (database.getDatabaseInfo().isHAMode()) {
// CommonUITool.openErrorBox(com.cubrid.cubridmanager.ui.common.Messages.errNoSupportInHA);
// return;
// }
TaskExecutor taskExecutor = new CommonTaskExec(CommonTaskName.DELETE_USER_TASK_NAME);
DropUserTask task = new DropUserTask(database.getDatabaseInfo(), node.getName());
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
if (navigatorView != null) {
TreeViewer treeViewer = navigatorView.getViewer();
if (treeViewer != null) {
//refresh user folder count label
CubridNodeChangedEvent event = new CubridNodeChangedEvent(folderNode, CubridNodeChangedEventType.NODE_REFRESH);
CubridNodeManager.getInstance().fireCubridNodeChanged(event);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node.getParent());
CommonUITool.openInformationBox(com.cubrid.common.ui.common.Messages.titleSuccess, Messages.msgDeleteUserSuccess);
}
}
}
}
Aggregations