use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetCMUserListTask method getServerUserInfoList.
/**
*
* Get server user information list
*
* @return List<ServerUserInfo> A list stored some instance of
* ServerUserInfo
*/
public List<ServerUserInfo> getServerUserInfoList() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
List<ServerUserInfo> serverUserInfoList = new ArrayList<ServerUserInfo>();
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node1 = response.getChildren().get(i);
if (node1.getValue("open") == null) {
continue;
}
if (node1.getValue("open").trim().equals("dblist")) {
serverInfo.removeAllDatabase();
String[] dbNames = node1.getValues("dbname");
// start
if (null == dbNames) {
int length = node1.childrenSize();
dbNames = new String[length];
for (int j = 0; j < length; j++) {
TreeNode subNode2 = node1.getChildren().get(j);
if (subNode2.getValue("open") == null || !subNode2.getValue("open").trim().equals("dbs")) {
continue;
}
dbNames[j] = subNode2.getValue("dbname");
}
}
for (int m = 0; dbNames != null && m < dbNames.length; m++) {
serverInfo.addDatabase(dbNames[m]);
}
} else if (node1.getValue("open").trim().equals("userlist")) {
buildUserInfo(serverUserInfoList, node1);
}
}
return serverUserInfoList;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetCubridConfParameterTask method getConfContents.
/**
*
* Get cubrid.conf parameters
*
* @return List<String> The map that stored configure parameters
*/
public List<String> getConfContents() {
String[] confData = null;
List<String> confContents = new ArrayList<String>();
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node != null && node.getValue("open").equals("conflist")) {
confData = node.getValues("confdata");
}
}
if (confData != null) {
for (String line : confData) {
confContents.add(line);
}
}
return confContents;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class PlanDumpTask method getContent.
/**
* get result from the response.
*
* @return LogContentInfo
*/
public PlanDumpInfo getContent() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
PlanDumpInfo planDumpInfo = new PlanDumpInfo();
String path = response.getValue("path");
planDumpInfo.setPath(path);
for (int i = 0; i < response.childrenSize(); i++) {
TreeNode node = response.getChildren().get(i);
if (node != null && node.getValue("open") != null && node.getValue("open").equals("log")) {
String[] lines = node.getValues("line");
for (int j = 0; j < lines.length; j++) {
String str = lines[j];
if (str != null) {
planDumpInfo.addLine(str);
}
}
}
}
return planDumpInfo;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class GetQueryPlanListTask method getQueryPlanInfoList.
/**
* Get a list that includes the instances of QueryPlanInfo
*
* @return List<QueryPlanInfo> a list that includes the instances of
* QueryPlanInfo
*/
public List<QueryPlanInfo> getQueryPlanInfoList() {
List<QueryPlanInfo> queryPlanInfoList = new ArrayList<QueryPlanInfo>();
if (null != getErrorMsg()) {
return null;
}
TreeNode result = getResponse();
String dbname = result.getValue("dbname");
if (result.childrenSize() > 0) {
TreeNode planListNode = result.getChildren().get(0);
int size = planListNode.childrenSize();
for (int i = 0; i < size; i++) {
TreeNode node = planListNode.getChildren().get(i);
QueryPlanInfo planInfo = new QueryPlanInfo();
SocketTask.setFieldValue(node, planInfo);
planInfo.setDbname(dbname);
queryPlanInfoList.add(planInfo);
}
}
return queryPlanInfoList;
}
use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.
the class TransFileTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/transfile_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
TransFileTask task = new TransFileTask(serverInfo);
task.setResponse(node);
//compare
assertTrue(task.isSuccess());
assertEquals("2563", task.getTransFilePid());
//test exception case 1
task.setResponse(null);
assertTrue(task.getTransFilePid() == null);
//test exception case 2
task.setResponse(node);
task.setErrorMsg("has error");
assertTrue(task.getTransFilePid() == null);
}
Aggregations