use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method loadSevers.
/**
*
* Load added host from plugin preference
*
*/
protected void loadSevers() {
synchronized (this) {
// serverList.clear();
boolean isHasLocalHost = false;
boolean alreadyAddedLocalhostDefault = false;
IXMLMemento memento = PersistUtils.getXMLMemento(ApplicationUtil.CM_UI_PLUGIN_ID, SERVER_XML_CONTENT);
// For compatible for the version before 8.4.0
URL url = Platform.getInstanceLocation().getURL();
File file = new File(url.getFile());
String optionsPath = file.getAbsolutePath() + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator;
//Load global preference setting
QueryOptions.load(optionsPath, null);
if (memento != null) {
alreadyAddedLocalhostDefault = memento.getBoolean("alreadyAddedLocalhostDefault");
}
isHasLocalHost = loadServers(memento, true, optionsPath);
if (!isHasLocalHost && !alreadyAddedLocalhostDefault) {
String id = "localhost";
String name = "localhost";
int port = 8001;
String userName = "admin";
ServerInfo serverInfo = new ServerInfo();
serverInfo.setServerName(name);
serverInfo.setHostAddress(name);
serverInfo.setHostMonPort(port);
serverInfo.setHostJSPort(port + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword("");
CubridServer server = new CubridServer(id, name, "icons/navigator/host.png", "icons/navigator/host_connected.png");
server.setServerInfo(serverInfo);
server.setType(NodeType.SERVER);
server.setLoader(new CubridServerLoader());
serverList.add(0, server);
ServerManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
/*Save the server list*/
saveServers();
}
}
}
use of com.cubrid.cubridmanager.ui.spi.model.loader.CubridServerLoader in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method loadServers.
private boolean loadServers(List<CubridServer> servers, IXMLMemento memento, boolean isLoadOptions, String optionPath, boolean allowDuplicate) {
boolean isHasLocalHost = false;
IXMLMemento[] children = memento == null ? null : memento.getChildren("host");
for (int i = 0; children != null && i < children.length; i++) {
String id = children[i].getString("id");
String name = children[i].getString("name");
if ("localhost".equals(name)) {
isHasLocalHost = true;
}
String address = children[i].getString("address");
String port = children[i].getString("port");
String user = children[i].getString("user");
String userPasword = children[i].getString("password");
String jdbcDriver = children[i].getString("jdbcDriver");
boolean savePassword = children[i].getBoolean("savePassword");
String strSoTimeOut = children[i].getString("soTimeOut");
int soTimeOut = StringUtil.intValue(strSoTimeOut, SocketTask.SOCKET_IO_TIMEOUT_MSEC);
// duplicate entry check: memento -- current workspace
if (!allowDuplicate) {
if (getServer(id) != null && isContainedByHostAddress(address, port, null)) {
continue;
}
}
String strCheckCert = children[i].getString("isCheckCert");
ServerInfo serverInfo = new ServerInfo();
serverInfo.setServerName(name);
serverInfo.setHostAddress(address);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(user);
serverInfo.setUserPassword(CipherUtils.decrypt(userPasword));
serverInfo.setJdbcDriverVersion(jdbcDriver);
serverInfo.setSoTimeOut(soTimeOut);
if (!StringUtil.isEmpty(strCheckCert)) {
serverInfo.setCheckCertStatus(StringUtil.booleanValue(strCheckCert));
}
CubridServer server = new CubridServer(id, name, "icons/navigator/host.png", "icons/navigator/host_connected.png");
server.setServerInfo(serverInfo);
server.setType(NodeType.SERVER);
server.setLoader(new CubridServerLoader());
server.setAutoSavePassword(savePassword);
if (isLoadOptions) {
QueryOptions.load(optionPath, serverInfo);
}
servers.add(server);
ServerManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
}
return isHasLocalHost;
}
Aggregations