Search in sources :

Example 6 with IsDBAUserTask

use of com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask in project cubrid-manager by CUBRID.

the class CubridWorkbenchContrItem method connectDatabaseWithErrMsg.

/**
	 * Connect the database
	 *
	 * @param dbInfo DatabaseInfo
	 * @param showErrMsg boolean
	 * @return string error messages
	 */
public static String connectDatabaseWithErrMsg(DatabaseInfo dbInfo, boolean showErrMsg) {
    if (dbInfo == null || dbInfo.getServerInfo() == null || dbInfo.getAuthLoginedDbUserInfo() == null) {
        return "";
    }
    final String USER_DBA = "dba";
    DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
    String dbUser = dbUserInfo.getName();
    String dbPassword = dbUserInfo.getNoEncryptPassword();
    if (dbUser == null || dbUser.trim().length() == 0 || dbPassword == null) {
        return Messages.errMultiDatabaseLoginNoUsername;
    }
    LoginDatabaseTaskExecutor taskExcutor = new LoginDatabaseTaskExecutor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dbInfo.getServerInfo(), dbInfo.getDbName(), dbUser, dbPassword, showErrMsg);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    /*For [TOOLS-3516]*/
    if (dbInfo.getAuthLoginedDbUserInfo() != null && CompatibleUtil.isNeedCheckDbaAuthorityByJDBC(dbInfo)) {
        IsDBAUserTask checkTask = new IsDBAUserTask(dbInfo);
        checkTask.execute();
        if (checkTask.isSuccess()) {
            dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(checkTask.isDBAUser());
        } else {
            dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(USER_DBA.equals(dbUser.toLowerCase()));
        }
    }
    /*Modify*/
    CMDBNodePersistManager.getInstance().fireModifyDatabase(dbInfo, dbInfo);
    return taskExcutor.getErrMsg();
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IsDBAUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask) LoginDatabaseTaskExecutor(com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoginDatabaseTaskExecutor)

Example 7 with IsDBAUserTask

use of com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask in project cubrid-manager by CUBRID.

the class LoginDatabaseDialog method connect.

/**
	 * Execute task and login database
	 */
private boolean connect() {
    final String dbUser = userNameText.getText();
    final String dbPassword = passwordText.getText();
    database.getDatabaseInfo().setJdbcAttrs(attrText.getText());
    final DatabaseInfo dbInfo = database.getDatabaseInfo();
    database.setAutoSavePassword(isSavePassword);
    TaskExecutor taskExcutor = new LoginDatabaseTaskExecutor(getShell(), dbInfo.getServerInfo(), dbInfo.getDbName(), dbUser, dbPassword, true);
    new ExecTaskWithProgress(taskExcutor).exec(true, true);
    if (!taskExcutor.isSuccess() && passwordText != null && !passwordText.isDisposed()) {
        passwordText.selectAll();
        passwordText.setFocus();
    }
    if (taskExcutor.isSuccess()) {
        saveBrokerInfo();
    }
    /*For [TOOLS-3516]*/
    if (dbInfo.getAuthLoginedDbUserInfo() != null && CompatibleUtil.isNeedCheckDbaAuthorityByJDBC(dbInfo)) {
        IsDBAUserTask checkTask = new IsDBAUserTask(dbInfo);
        checkTask.execute();
        if (checkTask.isSuccess()) {
            dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(checkTask.isDBAUser());
        } else {
            dbInfo.getAuthLoginedDbUserInfo().setDbaAuthority(USER_DBA.equals(dbUser.toLowerCase()));
        }
    }
    return taskExcutor.isSuccess();
}
Also used : TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) IsDBAUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask)

Aggregations

IsDBAUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask)7 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)3 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)2 ConnectDatabaseExecutor (com.cubrid.common.ui.spi.util.ConnectDatabaseExecutor)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 LoginDatabaseTaskExecutor (com.cubrid.cubridmanager.ui.cubrid.database.dialog.LoginDatabaseTaskExecutor)2 CQBDbConnectionLoader (com.cubrid.cubridmanager.ui.spi.model.loader.CQBDbConnectionLoader)2 CUBRIDConnectionProxy (com.cubrid.jdbc.proxy.driver.CUBRIDConnectionProxy)2 SQLException (java.sql.SQLException)2 PartInitException (org.eclipse.ui.PartInitException)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 CubridNodeLoader (com.cubrid.common.ui.spi.model.CubridNodeLoader)1 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)1 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)1