Search in sources :

Example 1 with DropUserTask

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);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ITask(com.cubrid.common.core.task.ITask) ArrayList(java.util.ArrayList) CreateUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.CreateUserTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ChangeDbUserPwdTask(com.cubrid.cubridmanager.core.cubrid.user.task.ChangeDbUserPwdTask) DropUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) UpdateAddUserJdbcTask(com.cubrid.cubridmanager.core.cubrid.user.task.UpdateAddUserJdbcTask)

Example 2 with DropUserTask

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);
            }
        }
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DropUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 DropUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.DropUserTask)2 ITask (com.cubrid.common.core.task.ITask)1 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ChangeDbUserPwdTask (com.cubrid.cubridmanager.core.cubrid.user.task.ChangeDbUserPwdTask)1 CreateUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.CreateUserTask)1 UpdateAddUserJdbcTask (com.cubrid.cubridmanager.core.cubrid.user.task.UpdateAddUserJdbcTask)1 ArrayList (java.util.ArrayList)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1