use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class CMHostNodePersistManager method saveServers.
/**
*
* Save added server to plug-in preference
*
*/
public void saveServers() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("hosts");
memento.putBoolean("alreadyAddedLocalhostDefault", true);
Iterator<CubridServer> iterator = serverList.iterator();
while (iterator.hasNext()) {
CubridServer server = (CubridServer) iterator.next();
IXMLMemento child = memento.createChild("host");
child.putString("id", server.getId());
child.putString("name", server.getLabel());
child.putString("port", String.valueOf(server.getMonPort()));
child.putString("address", server.getHostAddress());
child.putString("user", server.getUserName());
String pwd = server.isAutoSavePassword() ? CipherUtils.encrypt(server.getPassword()) : "";
child.putString("password", pwd);
child.putBoolean("savePassword", server.isAutoSavePassword());
child.putString("jdbcDriver", server.getJdbcDriverVersion());
if (server.getServerInfo() != null) {
child.putInteger("soTimeOut", server.getServerInfo().getSoTimeOut());
child.putString("isCheckCert", String.valueOf(server.getServerInfo().isCheckCertStatus()));
}
}
PersistUtils.saveXMLMemento(ApplicationUtil.CM_UI_PLUGIN_ID, SERVER_XML_CONTENT, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento 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;
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class BatchRunComposite method saveBatchRunList.
public void saveBatchRunList() {
XMLMemento memento = XMLMemento.createWriteRoot("BatchRunList");
for (Iterator<Map<String, String>> it = listData.iterator(); it.hasNext(); ) {
IXMLMemento batchRunXMLMemento = memento.createChild("BatchRun");
Map<String, String> data = it.next();
batchRunXMLMemento.putString("filename", data.get("1"));
batchRunXMLMemento.putString("memo", data.get("2"));
batchRunXMLMemento.putString("regdate", data.get("3"));
batchRunXMLMemento.putString("directory", data.get("4"));
}
PersistUtils.saveXMLMemento(BatchRunComposite.ID, LIST_ID, memento);
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class MonitorDashboardPersistManager method saveDashboard.
/**
*
* Save dash boards
*
*/
public void saveDashboard() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("dashboards");
Iterator<ICubridNode> iterator = monitorDashboardList.iterator();
while (iterator.hasNext()) {
ICubridNode node = (ICubridNode) iterator.next();
if (node instanceof MonitorStatistic) {
continue;
}
Dashboard dashboard = (Dashboard) node.getAdapter(Dashboard.class);
IXMLMemento dashboardChild = memento.createChild("dashboard");
dashboardChild.putString("name", node.getName());
Iterator<HostNode> nodeIte = dashboard.getHostNodeList().iterator();
while (nodeIte.hasNext()) {
//save host node
HostNode hostNode = nodeIte.next();
IXMLMemento hostNodeChild = dashboardChild.createChild("host");
hostNodeChild.putString("aliasname", hostNode.getName());
hostNodeChild.putString("ip", hostNode.getIp());
hostNodeChild.putString("port", hostNode.getPort());
hostNodeChild.putString("username", hostNode.getUserName());
hostNodeChild.putString("password", CipherUtils.encrypt(hostNode.getPassword()));
hostNodeChild.putString("location", hostNode.getLocation().x + "," + hostNode.getLocation().y);
hostNodeChild.putString("visible", hostNode.isVisible() ? "true" : "false");
//save the database node list
List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
Iterator<DatabaseNode> dbNodeIte = dbNodeList.iterator();
while (dbNodeIte.hasNext()) {
DatabaseNode dbNode = (DatabaseNode) dbNodeIte.next();
IXMLMemento databaseNodeChild = hostNodeChild.createChild("database");
databaseNodeChild.putString("aliasname", dbNode.getName());
databaseNodeChild.putString("dbname", dbNode.getDbName());
databaseNodeChild.putString("username", dbNode.getDbUser());
databaseNodeChild.putString("password", CipherUtils.encrypt(dbNode.getDbPassword()));
databaseNodeChild.putString("location", dbNode.getLocation().x + "," + dbNode.getLocation().y);
}
//save broker node list
List<BrokerNode> brokerNodeList = hostNode.getBrokerNodeList();
Iterator<BrokerNode> brokerNodeIte = brokerNodeList.iterator();
while (brokerNodeIte.hasNext()) {
BrokerNode brokerNode = (BrokerNode) brokerNodeIte.next();
IXMLMemento brokerNodeChild = hostNodeChild.createChild("broker");
brokerNodeChild.putString("aliasname", brokerNode.getName());
brokerNodeChild.putString("brokername", brokerNode.getBrokerName());
brokerNodeChild.putString("location", brokerNode.getLocation().x + "," + brokerNode.getLocation().y);
//save the client IP list
ClientNode ipListNode = dashboard.getClientNodeByBroker(brokerNode);
Point point = null;
String clientIpName = null;
if (ipListNode == null) {
brokerNodeChild.putString("show_ip_list", "false");
point = brokerNode.getClientsLocation();
} else {
brokerNodeChild.putString("show_ip_list", ipListNode.isVisible() ? "true" : "false");
point = ipListNode.getLocation();
clientIpName = ipListNode.getName();
}
if (point != null) {
brokerNodeChild.putString("client_ip_location", point.x + "," + point.y);
}
if (clientIpName != null) {
brokerNodeChild.putString("client_ip_name", clientIpName);
}
//save the database list
BrokerDBListNode dbListNode = dashboard.getBrokerDBListNodeByBroker(brokerNode);
String clientDbName = null;
if (dbListNode == null) {
brokerNodeChild.putString("show_db_list", "false");
point = brokerNode.getDatabasesLocation();
} else {
brokerNodeChild.putString("show_db_list", dbListNode.isVisible() ? "true" : "false");
point = dbListNode.getLocation();
clientDbName = dbListNode.getName();
}
if (point != null) {
brokerNodeChild.putString("client_db_location", point.x + "," + point.y);
}
if (clientDbName != null) {
brokerNodeChild.putString("client_db_name", clientDbName);
}
}
}
}
PersistUtils.saveXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_DASHBOARD_XML_CONTENT, memento);
}
}
use of com.cubrid.cubridmanager.core.common.xml.IXMLMemento in project cubrid-manager by CUBRID.
the class MonitorDashboardPersistManager method loadMonitorDashboard.
/**
*
* Load monitor dash board
*
*/
protected void loadMonitorDashboard() {
synchronized (this) {
IXMLMemento memento = PersistUtils.getXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_DASHBOARD_XML_CONTENT);
if (memento != null) {
IXMLMemento[] children = memento.getChildren("dashboard");
for (int i = 0; i < children.length; i++) {
Dashboard dashboard = new Dashboard();
String dashBoardName = children[i].getString("name");
dashboard.setName(dashBoardName);
IXMLMemento[] hostChildren = children[i].getChildren("host");
for (int j = 0; hostChildren != null && j < hostChildren.length; j++) {
//load the host node
String aliasName = hostChildren[j].getString("aliasname");
String userName = hostChildren[j].getString("username");
String password = hostChildren[j].getString("password");
String ip = hostChildren[j].getString("ip");
String port = hostChildren[j].getString("port");
String location = hostChildren[j].getString("location");
String visible = hostChildren[j].getString("visible");
HostNode hostNode = new HostNode();
if (aliasName == null || aliasName.trim().length() == 0) {
aliasName = ip + ":" + port;
}
hostNode.setName(aliasName);
hostNode.setIp(ip);
hostNode.setPort(port);
hostNode.setUserName(userName);
hostNode.setPassword(CipherUtils.decrypt(password));
if (location != null && location.trim().length() > 0) {
String[] locations = location.split(",");
hostNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
}
if ("true".equals(visible)) {
hostNode.setVisible(true);
} else {
hostNode.setVisible(false);
}
dashboard.addNode(hostNode);
//load the database node list
IXMLMemento[] databaseChildren = hostChildren[j].getChildren("database");
for (int k = 0; databaseChildren != null && k < databaseChildren.length; k++) {
aliasName = databaseChildren[k].getString("aliasname");
String dbName = databaseChildren[k].getString("dbname");
String dbUserName = databaseChildren[k].getString("username");
String dbPassword = databaseChildren[k].getString("password");
String dbLocation = databaseChildren[k].getString("location");
if (aliasName == null || aliasName.trim().length() == 0) {
aliasName = dbName;
}
DatabaseNode databaseNode = new DatabaseNode();
databaseNode.setName(aliasName);
databaseNode.setDbUser(dbUserName);
databaseNode.setDbPassword(CipherUtils.decrypt(dbPassword));
databaseNode.setDbName(dbName);
databaseNode.setParent(hostNode);
hostNode.addDbNode(databaseNode);
if (dbLocation != null && dbLocation.trim().length() > 0) {
String[] locations = dbLocation.split(",");
databaseNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
}
}
//load the broker node list
IXMLMemento[] brokerChildren = hostChildren[j].getChildren("broker");
for (int k = 0; brokerChildren != null && k < brokerChildren.length; k++) {
aliasName = brokerChildren[k].getString("aliasname");
String brokerName = brokerChildren[k].getString("brokername");
String brokerLocation = brokerChildren[k].getString("location");
if (aliasName == null || aliasName.trim().length() == 0) {
aliasName = brokerName;
}
BrokerNode brokerNode = new BrokerNode();
brokerNode.setName(aliasName);
brokerNode.setBrokerName(brokerName);
brokerNode.setParent(hostNode);
hostNode.addBrokerNode(brokerNode);
//load the client IP list
String clientIpName = brokerChildren[k].getString("client_ip_name");
String clientIpLocation = brokerChildren[k].getString("client_ip_location");
String showIpList = brokerChildren[k].getString("show_ip_list");
if (brokerLocation != null && brokerLocation.trim().length() > 0) {
String[] locations = brokerLocation.split(",");
brokerNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
}
String[] locations = clientIpLocation == null ? new String[] { "0", "0" } : clientIpLocation.split(",");
ClientNode ipListNode = new ClientNode();
ipListNode.setBrokerNode(brokerNode);
ipListNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
if (clientIpName != null && clientIpName.trim().length() > 0) {
ipListNode.setName(clientIpName);
}
if ("true".equals(showIpList)) {
ipListNode.setVisible(true);
} else {
ipListNode.setVisible(false);
}
dashboard.addClientNode(ipListNode);
//load the client database list
String clientDbName = brokerChildren[k].getString("client_db_name");
String clientDbLocation = brokerChildren[k].getString("client_db_location");
String showDbList = brokerChildren[k].getString("show_db_list");
locations = clientDbLocation == null ? new String[] { "0", "0" } : clientDbLocation.split(",");
BrokerDBListNode dbListNode = new BrokerDBListNode();
dbListNode.setBrokerNode(brokerNode);
dbListNode.setLocation(new Point(Integer.parseInt(locations[0]), Integer.parseInt(locations[1])));
if (clientDbName != null && clientDbName.trim().length() > 0) {
dbListNode.setName(clientDbName);
}
if ("true".equals(showDbList)) {
dbListNode.setVisible(true);
} else {
dbListNode.setVisible(false);
}
dashboard.addBrokerDBListNode(dbListNode);
}
}
DefaultCubridNode dashboardNode = new DefaultCubridNode(dashBoardName, dashBoardName, "icons/navigator/status_item.png");
dashboardNode.setType(CubridNodeType.MONITOR_DASHBOARD);
dashboardNode.setEditorId(MonitorDashboardEditor.ID);
dashboardNode.setModelObj(dashboard);
monitorDashboardList.add(dashboardNode);
}
}
}
}
Aggregations