use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class ChangeSlaveDbAction method isSupported.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public boolean isSupported(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
return database.isDistributorDb();
}
return false;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class ConfigureReplicationParamAction method isSupported.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public boolean isSupported(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
return database.isDistributorDb();
}
return false;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class MonitorReplicationPerfAction method isSupported.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public boolean isSupported(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
return database.isDistributorDb();
}
return false;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class StopReplicationAgentAction method isSupportedNode.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public static boolean isSupportedNode(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
if (!database.isDistributorDb()) {
return false;
}
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
if (replInfo != null && replInfo.getDistInfo() != null) {
return replInfo.getDistInfo().isAgentActive();
}
return false;
}
return false;
}
use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.
the class FinishTask method call.
public Integer call() {
ProgressBar bar = (ProgressBar) item.getData(MultiHostConnectionDialog.KEY_BAR);
MonitorDashboardPreference monPref = new MonitorDashboardPreference();
boolean isRunUpdateCmUserTask = false;
BrokerInfos brokerInfos = null;
int size = tasks.size();
int taskIdx = 1;
for (ITask task : tasks) {
if (task instanceof MonitoringTask) {
if (!serverInfo.isConnected()) {
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
MonitoringTask monitoringTask = (MonitoringTask) task;
serverInfo = monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
if (serverInfo.isConnected()) {
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
} else {
CMHostNodePersistManager.getInstance().removeServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName());
}
}
} else if ((task instanceof UpdateCMUserTask)) {
updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
} else {
task.execute();
}
final String msg = task.getErrorMsg();
if (msg != null && msg.length() > 0) {
item.setText(3, msg);
disConnect();
isFinished = true;
updateIcon();
return 1;
}
if (task instanceof GetEnvInfoTask) {
GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
serverInfo.setEnvInfo(envInfo);
String clientVersion = getClientVerion();
if (!isClientSupport(clientVersion)) {
item.setText(3, Messages.bind(Messages.errNoSupportServerVersion, clientVersion));
disConnect();
isFinished = true;
updateIcon();
return 2;
}
String jdbcVersion = serverInfo.getJdbcDriverVersion();
if (serverInfo.validateJdbcVersion(jdbcVersion)) {
if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
serverInfo.setJdbcDriverVersion(ServerInfo.getAutoDetectJdbcVersion(serverInfo.getFullServerVersionKey()));
}
} else {
if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(jdbcVersion)) {
item.setText(3, Messages.errNoSupportDriver);
} else {
item.setText(3, Messages.errSelectSupportDriver);
}
disConnect();
isFinished = true;
updateIcon();
return 3;
}
} else if (task instanceof GetDatabaseListTask) {
GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
if (databaseInfoList != null) {
allDatabaseInfoList.addAll(databaseInfoList);
}
} else if (task instanceof GetCMConfParameterTask) {
GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
ServerType serverType = ServerType.BOTH;
if (confParameters != null) {
String target = confParameters.get(CubridManagerConfParaConstants.CM_TARGET);
if (target != null) {
if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
serverType = ServerType.BOTH;
} else if (target.indexOf("broker") >= 0) {
serverType = ServerType.BROKER;
} else if (target.indexOf("server") >= 0) {
serverType = ServerType.DATABASE;
}
}
}
if (serverInfo != null) {
serverInfo.setServerType(serverType);
}
} else if (task instanceof CommonQueryTask) {
CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
brokerInfos = getBrokerTask.getResultModel();
if (serverInfo != null) {
serverInfo.setBrokerInfos(brokerInfos);
}
} else if (task instanceof GetCMUserListTask) {
if (serverInfo != null && serverInfo.isConnected()) {
GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
ServerUserInfo userInfo = serverUserInfoList.get(i);
if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
serverInfo.setLoginedUserInfo(userInfo);
break;
}
}
List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
if (databaseInfoList != null) {
authDatabaseList.addAll(databaseInfoList);
}
isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
if (isRunUpdateCmUserTask) {
serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
}
}
} else if (task instanceof GetCubridConfParameterTask) {
GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setCubridConfParaMap(confParas);
}
} else if (task instanceof GetBrokerConfParameterTask) {
GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo != null) {
serverInfo.setBrokerConfParaMap(confParas);
}
} else if (task instanceof FinishTask) {
isSuccess = true;
server.getLoader().setLoaded(false);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
}
bar.setSelection(taskIdx++ / size * 100);
if (isCanceled()) {
isFinished = true;
updateIcon();
return 4;
}
}
bar.setSelection(100);
item.setText(3, Messages.msgConneted);
isFinished = true;
return 0;
}
Aggregations