use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method setDbData.
/**
* Set Server Database Info
*/
private void setDbData(ServiceDashboardInfo sDashInfo, List<DatabaseInfo> databaseInfoList) {
int databaseOn = 0, databaseOff = 0;
if (databaseInfoList != null) {
for (DatabaseInfo dbInfo : databaseInfoList) {
if (dbInfo.getRunningType() == DbRunningType.CS)
databaseOn += 1;
}
databaseOff = databaseInfoList.size() - databaseOn;
}
sDashInfo.setDatabaseOn(databaseOn);
sDashInfo.setDatabaseOff(databaseOff);
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class SetDistributorDbInfoDialog method checkDatabaseExist.
/**
* Check whether the database exist
*
* @param dbName the database name
* @return <code>true</code> if already exist;<code>false</code> otherwise
*/
private boolean checkDatabaseExist(String dbName) {
boolean isDatabaseExist = false;
List<DatabaseInfo> databaseInfoList = hostNode.getDatabaseInfoList();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
DatabaseInfo databaseInfo = databaseInfoList.get(i);
if (dbName.equalsIgnoreCase(databaseInfo.getDbName())) {
isDatabaseExist = true;
break;
}
}
if (!isDatabaseExist) {
List<LeafNode> childNodeList = hostNode.getChildNodeList();
for (int i = 0; childNodeList != null && i < childNodeList.size(); i++) {
LeafNode node = childNodeList.get(i);
if (dbName.equalsIgnoreCase(node.getName()) && !dbName.equals(distributorNode.getDbName())) {
isDatabaseExist = true;
break;
}
}
}
return isDatabaseExist;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class SetHostInfoDialog method connect.
/**
* connect the host
*
* @param buttonId int
*/
private void connect(final int buttonId) {
final String ip = ipText.getText();
final String port = portText.getText();
final String userName = userNameText.getText();
final String password = passwordText.getText();
boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
if (isConnected && hostInfo != null) {
ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
if (!serverInfo.getLoginedUserInfo().isAdmin()) {
CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
return;
}
hostInfo.setIp(ip);
hostInfo.setPort(port);
hostInfo.setUserName(userName);
hostInfo.setPassword(password);
hostInfo.setName(ip + ":" + port);
List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
hostInfo.setDatabaseInfoList(databaseInfoList);
hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
setReturnCode(buttonId);
close();
return;
}
if (!isConnected) {
final ServerInfo serverInfo = new ServerInfo();
serverInfo.setHostAddress(ip);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
taskExcutor.addTask(monitoringTask);
GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
taskExcutor.addTask(getEnvInfoTask);
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
taskExcutor.addTask(getCMConfParameterTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
taskExcutor.addTask(getDatabaseListTask);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class SelectDatabasePage method modifyText.
/**
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
* @param event ModifyEvent
*/
public void modifyText(ModifyEvent event) {
String mdbName = masterDbNameCombo.getText();
String dbaPassword = dbaPasswordText.getText();
String serverPort = serverPortText.getText();
boolean isValidPassword = dbaPassword.length() >= 4 && dbaPassword.indexOf(" ") < 0;
boolean isValidDbName = ValidateUtil.isValidDBName(mdbName);
boolean isLogined = false;
if (isValidDbName && databaseInfoList != null) {
for (int i = 0; i < databaseInfoList.size(); i++) {
DatabaseInfo dbInfo = databaseInfoList.get(i);
if (mdbName.equalsIgnoreCase(dbInfo.getDbName())) {
isLogined = dbInfo.isLogined() && !dbInfo.getAuthLoginedDbUserInfo().getName().equalsIgnoreCase("dba");
if (dbInfo.isLogined() && isValidPassword) {
isValidPassword = dbaPassword.equals(dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword());
}
break;
}
}
}
boolean isValidPort = ValidateUtil.isNumber(serverPort);
if (isValidPort) {
int portVal = Integer.parseInt(serverPort);
if (portVal < 1024 || portVal > 65535) {
isValidPort = false;
}
}
boolean isValidHost = host != null && host.isValid();
if (!isValidHost) {
setErrorMessage(Messages.errInvalidHostInfo);
setPageComplete(false);
return;
}
if (!isMdbExist) {
setErrorMessage(Messages.bind(Messages.errNoMdb, mdbName));
setPageComplete(false);
return;
}
if (isLogined) {
setErrorMessage(Messages.bind(Messages.errInvalidDbUser, mdbName));
setPageComplete(false);
return;
}
if (!isValidDbName) {
setErrorMessage(Messages.errDatabaseName);
setPageComplete(false);
return;
}
if (!isValidPassword) {
setErrorMessage(Messages.errDbaPassword);
setPageComplete(false);
return;
}
if (!isValidPort) {
setErrorMessage(Messages.errReplServerPort);
setPageComplete(false);
return;
}
setErrorMessage(null);
setPageComplete(true);
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method setDbCollation.
private void setDbCollation(CubridDatabase database) {
DatabaseInfo databaseInfo = database.getDatabaseInfo();
boolean supportCharset = CompatibleUtil.isSupportCreateDBByCharset(databaseInfo);
if (!supportCharset || !databaseInfo.getServerInfo().isConnected()) {
return;
}
GetDbCollationTask getDbCollationTask = new GetDbCollationTask(databaseInfo);
getDbCollationTask.execute();
if (getDbCollationTask.isSuccess()) {
databaseInfo.setCollation(getDbCollationTask.getCollation());
}
}
Aggregations