Search in sources :

Example 51 with TreeNode

use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.

the class GetDbBackupInfoTask method getDbBackupInfo.

/**
	 * 
	 * Get database backup information
	 * 
	 * @return DbBackupInfo the instance of DbBackupInfo
	 */
public DbBackupInfo getDbBackupInfo() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    DbBackupInfo dbBackupInfo = new DbBackupInfo();
    String dbDir = response.getValue("dbdir");
    dbBackupInfo.setDbDir(dbDir);
    String freeSpace = response.getValue("freespace");
    dbBackupInfo.setFreeSpace(freeSpace);
    for (int i = 0; i < response.childrenSize(); i++) {
        TreeNode node = response.getChildren().get(i);
        if (node == null) {
            continue;
        }
        String levelName = node.getValue("open");
        if (levelName == null || levelName.trim().length() <= 0) {
            continue;
        }
        if (levelName.indexOf("level") >= 0) {
            String path = node.getValue("path");
            String size = node.getValue("size");
            String date = node.getValue("data");
            DbBackupHistoryInfo dbBackupHistoryInfo = new DbBackupHistoryInfo(levelName, path, size, date);
            dbBackupInfo.addDbBackupHistoryInfo(dbBackupHistoryInfo);
        }
    }
    return dbBackupInfo;
}
Also used : DbBackupHistoryInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupHistoryInfo) DbBackupInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo) TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode)

Example 52 with TreeNode

use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.

the class GetDbUnloadInfoTask method getDbUnloadInfoList.

/**
	 * 
	 * Get database unload information list
	 * 
	 * @return List<DbUnloadInfo>
	 */
public List<DbUnloadInfo> getDbUnloadInfoList() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    List<DbUnloadInfo> dbUnloadInfoList = new ArrayList<DbUnloadInfo>();
    for (int i = 0; i < response.childrenSize(); i++) {
        TreeNode treeNode = response.getChildren().get(i);
        if (treeNode != null && treeNode.getValue("open") != null && treeNode.getValue("open").equals("database")) {
            DbUnloadInfo dbUnloadInfo = new DbUnloadInfo();
            String dbName = treeNode.getValue("dbname");
            dbUnloadInfo.setDbName(dbName);
            String[] schemaInfoArr = treeNode.getValues("schema");
            addSchemaDate(dbUnloadInfo, schemaInfoArr);
            String[] objectInfoArr = treeNode.getValues("object");
            addObjectDate(dbUnloadInfo, objectInfoArr);
            String[] indexInfoArr = treeNode.getValues("index");
            addIndexDate(dbUnloadInfo, indexInfoArr);
            String[] triggerInfoArr = treeNode.getValues("trigger");
            addTriggerDate(dbUnloadInfo, triggerInfoArr);
            dbUnloadInfoList.add(dbUnloadInfo);
        }
    }
    return dbUnloadInfoList;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList) DbUnloadInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo)

Example 53 with TreeNode

use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.

the class ParamDumpTask method getContent.

/**
	 * get result from the response.
	 * 
	 * @return LogContentInfo
	 */
public ParamDumpInfo getContent() {
    TreeNode response = getResponse();
    if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
        return null;
    }
    ParamDumpInfo paramDumpInfo = new ParamDumpInfo();
    String dbName = response.getValue("dbname");
    paramDumpInfo.setDbName(dbName);
    int pos1 = 0;
    int pos2 = 0;
    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("client")) {
            paramDumpInfo.setClientData(node.getValueByMap());
            paramDumpInfo.getClientData().remove("service");
            pos1 = node.getValues("service")[0].lastIndexOf(":");
            pos2 = node.getValues("service")[1].lastIndexOf(":");
            paramDumpInfo.addClientData("service" + node.getValues("service")[0].substring(0, pos1), node.getValues("service")[0].substring(pos1 + 1));
            paramDumpInfo.addClientData("service" + node.getValues("service")[1].substring(0, pos2), node.getValues("service")[1].substring(pos2 + 1));
        }
        if (node != null && node.getValue("open") != null && node.getValue("open").equals("server")) {
            paramDumpInfo.setServerData(node.getValueByMap());
            paramDumpInfo.getServerData().remove("service");
            pos1 = node.getValues("service")[0].lastIndexOf(":");
            pos2 = node.getValues("service")[1].lastIndexOf(":");
            paramDumpInfo.addServerData("service" + node.getValues("service")[0].substring(0, pos1), node.getValues("service")[0].substring(pos1 + 1));
            paramDumpInfo.addServerData("service" + node.getValues("service")[1].substring(0, pos2), node.getValues("service")[1].substring(pos2 + 1));
        }
    }
    return paramDumpInfo;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ParamDumpInfo(com.cubrid.cubridmanager.core.cubrid.database.model.ParamDumpInfo)

Example 54 with TreeNode

use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.

the class GetCMConfParameterTask method getConfContents.

/**
	 * 
	 * Get cm.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;
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode) ArrayList(java.util.ArrayList)

Example 55 with TreeNode

use of com.cubrid.cubridmanager.core.common.socket.TreeNode in project cubrid-manager by CUBRID.

the class GetCMUserListTask method buildDbAuthInfo.

/**
	 * 
	 * Create database authorization information
	 * 
	 * @param node the TreeNode
	 * @param userInfo the ServerUserInfo
	 */
private void buildDbAuthInfo(TreeNode node, ServerUserInfo userInfo) {
    for (int k = 0; k < node.childrenSize(); k++) {
        TreeNode subNode1 = node.getChildren().get(k);
        if (subNode1.getValue("open") == null || !subNode1.getValue("open").trim().equals("dbauth")) {
            continue;
        }
        String[] dbNameArr = subNode1.getValues("dbname");
        String[] dbUserIdArr = subNode1.getValues("dbid");
        String[] dbPasswordArr = subNode1.getValues("dbpasswd");
        String[] dbBrokerAddressArr = subNode1.getValues("dbbrokeraddress");
        /*
			 * As the old interface data format is not strict, as follows:
			 * ****************************************************************
			 * old format:
			 * open:userlist
			 * open:user
			 * @id:fc921dcd5f775887b0d11859b4ad209562d214d78beac3c12ef3d968d4662378
			 * @passwd:86cdee95f45773a5c823601fdf6083c81e91c1cf239a99add914ba8b1c53f9f9
			 * open:dbauth
			 * dbname:db1
			 * @dbid:f48a619ab401fdfb2321c53e73fcd36923f57d1af229a45a5c5b3b8f122826cb
			 * dbbrokeraddress:localhost,30000
			 * dbname:demodb
			 * @dbid:ae58889474d0ea3ed327866b1037bd0d833b52be4720c3dce3264341f2a55cdd
			 * dbbrokeraddress:localhost,30000
			 * close:dbauth
			 * casauth:admin
			 * dbcreate:admin
			 * statusmonitorauth:admin
			 * close:user
			 * close:userlist
			 * ****************************************************************
			 * new format:
			 *    "userlist" : [
			 *       {
			 *          "user" : [
			 *             {
			 *                "@id" : "admin",
			 *                "@passwd" : "Admin",
			 *                "casauth" : "admin",
			 *                "dbauth" : [
			 *                   {
			 *                      "auth_info" : [
			 *                         {
			 *                            "@dbid" : "dba",
			 *                            "dbbrokeraddress" : "localhost,30000",
			 *                            "dbname" : "db1"
			 *                         },
			 *                         {
			 *                            "@dbid" : "dba",
			 *                            "dbbrokeraddress" : "localhost,30000",
			 *                            "dbname" : "demodb"
			 *                         }
			 *                      ]
			 *                   }
			 *                ],
			 *                "dbcreate" : "admin",
			 *                "statusmonitorauth" : "admin"
			 *             }
			 *          ]
			 * ****************************************************************
			 * Thus here to add additional judgment operation
			 */
        if (null == dbNameArr) {
            int length = subNode1.childrenSize();
            dbNameArr = new String[length];
            dbUserIdArr = new String[length];
            dbPasswordArr = new String[length];
            dbBrokerAddressArr = new String[length];
            for (int i = 0; i < length; i++) {
                TreeNode subNode2 = subNode1.getChildren().get(i);
                if (subNode2.getValue("open") == null || !subNode2.getValue("open").trim().equals("auth_info")) {
                    continue;
                }
                dbNameArr[i] = subNode2.getValue("dbname");
                dbUserIdArr[i] = subNode2.getValue("dbid");
                dbPasswordArr[i] = subNode2.getValue("dbpasswd");
                dbBrokerAddressArr[i] = subNode2.getValue("dbbrokeraddress");
            }
        }
        // end
        buildDatabaseInfo(dbNameArr, dbUserIdArr, dbPasswordArr, dbBrokerAddressArr, userInfo);
    }
}
Also used : TreeNode(com.cubrid.cubridmanager.core.common.socket.TreeNode)

Aggregations

TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)142 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)7 Map (java.util.Map)6 Trigger (com.cubrid.common.core.common.model.Trigger)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)2 DbBackupInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DbBackupInfo)2 DbUnloadInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DbUnloadInfo)2 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)2 GetExecuteCasRunnerResultInfo (com.cubrid.cubridmanager.core.logs.model.GetExecuteCasRunnerResultInfo)2 ManagerLogInfoList (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfoList)2 ManagerLogInfos (com.cubrid.cubridmanager.core.logs.model.ManagerLogInfos)2 DbProcessStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.DbProcessStatusInfo)2 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)2 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)2 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)2 ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)2 TransFileProgressInfo (com.cubrid.cubridmanager.core.replication.model.TransFileProgressInfo)2 CasAuthType (com.cubrid.cubridmanager.core.common.model.CasAuthType)1