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();
}
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();
}
Aggregations