Search in sources :

Example 6 with UpdateCMUserTask

use of com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask in project cubrid-manager by CUBRID.

the class ConnectHostExecutor method updateCMUserAuthInfo.

/**
	 * Construct the CM user authorization information
	 *
	 * @param task the UpdateCMUserTask object
	 * @param isRunUpdateCmUserTask whether update CM user task
	 */
private void updateCMUserAuthInfo(ITask task, boolean isRunUpdateCmUserTask) {
    if (isRunUpdateCmUserTask && serverInfo != null && serverInfo.isConnected()) {
        UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        updateCMUserTask.setCasAuth(userInfo.getCasAuth().getText());
        updateCMUserTask.setDbCreator(userInfo.getDbCreateAuthType().getText());
        updateCMUserTask.setStatusMonitorAuth(userInfo.getStatusMonitorAuth().getText());
        List<String> dbNameList = new ArrayList<String>();
        List<String> dbUserList = new ArrayList<String>();
        List<String> dbPasswordList = new ArrayList<String>();
        List<String> dbBrokerPortList = new ArrayList<String>();
        if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
            int size = authDatabaseList.size();
            for (int i = 0; i < size; i++) {
                DatabaseInfo databaseInfo = authDatabaseList.get(i);
                dbNameList.add(databaseInfo.getDbName());
                dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
                dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
                String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                dbPasswordList.add(password == null ? "" : password);
            }
        }
        String[] dbNameArr = new String[dbNameList.size()];
        String[] dbUserArr = new String[dbUserList.size()];
        String[] dbPasswordArr = new String[dbPasswordList.size()];
        String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
        updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
        updateCMUserTask.execute();
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ArrayList(java.util.ArrayList) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 7 with UpdateCMUserTask

use of com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask in project cubrid-manager by CUBRID.

the class ConnectHostJobExecutor method exec.

/**
	 * Execute to connect host
	 * 
	 * @param monitor the IProgressMonitor
	 * @return <code>true</code> if successful;<code>false</code>otherwise;
	 */
@SuppressWarnings("unchecked")
public IStatus exec(final IProgressMonitor monitor) {
    monitor.subTask(Messages.bind(com.cubrid.cubridmanager.ui.mondashboard.Messages.jobConnectHost, serverInfo.getHostAddress()));
    isContinue = true;
    boolean isRunUpdateCmUserTask = false;
    BrokerInfos brokerInfos = null;
    errorMsg = null;
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            IStatus status = connectHost((MonitoringTask) task);
            if (Status.OK_STATUS != status) {
                return status;
            }
        } else if ((task instanceof UpdateCMUserTask)) {
            updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
        } else if ((task instanceof GetHeartbeatNodeInfoTask) && !CompatibleUtil.isSupportHA(serverInfo)) {
            continue;
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
        if (!hostNode.isConnecting()) {
            return Status.CANCEL_STATUS;
        }
        if (msg != null && msg.length() > 0) {
            disConnect();
            if (isPing) {
                errorMsg = msg;
                return Status.CANCEL_STATUS;
            }
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetEnvInfoTask) {
            GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
            EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
            serverInfo.setEnvInfo(envInfo);
            String clientVersion = Version.buildVersionId.substring(0, Version.buildVersionId.lastIndexOf("."));
            if (!CompatibleUtil.isSupportCMServer(serverInfo, clientVersion)) {
                disConnect();
                errorMsg = Messages.bind(Messages.errNoSupportServerVersion, clientVersion);
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
            if (!serverInfo.validateJdbcVersion(serverInfo.getJdbcDriverVersion())) {
                disConnect();
                if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(serverInfo.getJdbcDriverVersion())) {
                    errorMsg = Messages.errNoSupportDriver;
                } else {
                    errorMsg = Messages.errSelectSupportDriver;
                }
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
        } 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(ConfConstants.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 GetHeartbeatNodeInfoTask) {
            GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = (GetHeartbeatNodeInfoTask) task;
            haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
        }
        if (monitor.isCanceled() || !isContinue) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
    }
    return Status.OK_STATUS;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Map(java.util.Map) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 8 with UpdateCMUserTask

use of com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask in project cubrid-manager by CUBRID.

the class ConnectHostJobExecutor method updateCMUserAuthInfo.

/**
	 * 
	 * Construct the CM user authorization information
	 * 
	 * @param task the UpdateCMUserTask object
	 * @param isRunUpdateCmUserTask whether update CM user task
	 */
private void updateCMUserAuthInfo(ITask task, boolean isRunUpdateCmUserTask) {
    if (isRunUpdateCmUserTask && serverInfo != null && serverInfo.isConnected()) {
        UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        updateCMUserTask.setCasAuth(userInfo.getCasAuth().getText());
        updateCMUserTask.setDbCreator(userInfo.getDbCreateAuthType().getText());
        updateCMUserTask.setStatusMonitorAuth(userInfo.getStatusMonitorAuth().getText());
        List<String> dbNameList = new ArrayList<String>();
        List<String> dbUserList = new ArrayList<String>();
        List<String> dbPasswordList = new ArrayList<String>();
        List<String> dbBrokerPortList = new ArrayList<String>();
        if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
            int size = authDatabaseList.size();
            for (int i = 0; i < size; i++) {
                DatabaseInfo databaseInfo = authDatabaseList.get(i);
                dbNameList.add(databaseInfo.getDbName());
                dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
                dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
                String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                dbPasswordList.add(password == null ? "" : password);
            }
        }
        String[] dbNameArr = new String[dbNameList.size()];
        String[] dbUserArr = new String[dbUserList.size()];
        String[] dbPasswordArr = new String[dbPasswordList.size()];
        String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
        updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
        updateCMUserTask.execute();
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ArrayList(java.util.ArrayList) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 9 with UpdateCMUserTask

use of com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask in project cubrid-manager by CUBRID.

the class SetupEnvTestCase method loginTestDatabase930.

protected void loginTestDatabase930() {
    if (databaseInfo930.isLogined()) {
        return;
    }
    LoginDatabaseTask loginDatabaseTask = new LoginDatabaseTask(serverInfo930);
    loginDatabaseTask.setCMUser(userName930);
    loginDatabaseTask.setDbName(testDbName930);
    loginDatabaseTask.setDbUser(dbaUserName930);
    loginDatabaseTask.setDbPassword(dbaPassword930);
    loginDatabaseTask.execute();
    assertEquals(null, loginDatabaseTask.getErrorMsg());
    DbUserInfo dbUserInfo = loginDatabaseTask.getLoginedDbUserInfo();
    dbUserInfo.setNoEncryptPassword(dbaPassword930);
    databaseInfo930.setLogined(true);
    databaseInfo930.setAuthLoginedDbUserInfo(dbUserInfo);
    UpdateCMUserTask updateCMUserTask = new UpdateCMUserTask(serverInfo930);
    updateCMUserTask.setCmUserName(userName930);
    ServerUserInfo userInfo = serverInfo930.getLoginedUserInfo();
    updateCMUserTask.setCasAuth(userInfo.getCasAuth().getText());
    updateCMUserTask.setDbCreator(userInfo.getDbCreateAuthType().getText());
    updateCMUserTask.setStatusMonitorAuth(userInfo.getStatusMonitorAuth().getText());
    List<String> dbNameList = new ArrayList<String>();
    List<String> dbUserList = new ArrayList<String>();
    List<String> dbPasswordList = new ArrayList<String>();
    List<String> dbBrokerPortList = new ArrayList<String>();
    List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
    if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
        int size = authDatabaseList.size();
        for (int i = 0; i < size; i++) {
            DatabaseInfo databaseInfo = authDatabaseList.get(i);
            dbNameList.add(databaseInfo.getDbName());
            dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
            dbBrokerPortList.add(databaseInfo.getBrokerIP() + "," + databaseInfo.getBrokerPort());
            String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
            dbPasswordList.add(password == null ? "" : password);
        }
    }
    String[] dbNameArr = new String[dbNameList.size()];
    String[] dbUserArr = new String[dbUserList.size()];
    String[] dbPasswordArr = new String[dbPasswordList.size()];
    String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
    updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
    updateCMUserTask.execute();
    assertEquals(null, updateCMUserTask.getErrorMsg());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ArrayList(java.util.ArrayList) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 10 with UpdateCMUserTask

use of com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask in project cubrid-manager by CUBRID.

the class SetupEnvTestCase method loginTestDatabase831.

protected void loginTestDatabase831() {
    if (databaseInfo831.isLogined()) {
        return;
    }
    LoginDatabaseTask loginDatabaseTask = new LoginDatabaseTask(serverInfo831);
    loginDatabaseTask.setCMUser(userName831);
    loginDatabaseTask.setDbName(testDbName831);
    loginDatabaseTask.setDbUser(dbaUserName831);
    loginDatabaseTask.setDbPassword(dbaPassword831);
    loginDatabaseTask.execute();
    assertEquals(null, loginDatabaseTask.getErrorMsg());
    DbUserInfo dbUserInfo = loginDatabaseTask.getLoginedDbUserInfo();
    dbUserInfo.setNoEncryptPassword(dbaPassword831);
    databaseInfo831.setLogined(true);
    databaseInfo831.setAuthLoginedDbUserInfo(dbUserInfo);
    UpdateCMUserTask updateCMUserTask = new UpdateCMUserTask(serverInfo831);
    updateCMUserTask.setCmUserName(userName831);
    ServerUserInfo userInfo = serverInfo831.getLoginedUserInfo();
    updateCMUserTask.setCasAuth(userInfo.getCasAuth().getText());
    updateCMUserTask.setDbCreator(userInfo.getDbCreateAuthType().getText());
    updateCMUserTask.setStatusMonitorAuth(userInfo.getStatusMonitorAuth().getText());
    List<String> dbNameList = new ArrayList<String>();
    List<String> dbUserList = new ArrayList<String>();
    List<String> dbPasswordList = new ArrayList<String>();
    List<String> dbBrokerPortList = new ArrayList<String>();
    List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
    if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
        int size = authDatabaseList.size();
        for (int i = 0; i < size; i++) {
            DatabaseInfo databaseInfo = authDatabaseList.get(i);
            dbNameList.add(databaseInfo.getDbName());
            dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
            dbBrokerPortList.add(databaseInfo.getBrokerIP() + "," + databaseInfo.getBrokerPort());
            String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
            dbPasswordList.add(password == null ? "" : password);
        }
    }
    String[] dbNameArr = new String[dbNameList.size()];
    String[] dbUserArr = new String[dbUserList.size()];
    String[] dbPasswordArr = new String[dbPasswordList.size()];
    String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
    updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
    updateCMUserTask.execute();
    assertEquals(null, updateCMUserTask.getErrorMsg());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ArrayList(java.util.ArrayList) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Aggregations

UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)15 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)13 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)12 ArrayList (java.util.ArrayList)12 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)7 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)7 ITask (com.cubrid.common.core.task.ITask)6 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)5 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)5 LoginDatabaseTask (com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask)5 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)5 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)4 List (java.util.List)4 Map (java.util.Map)4 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)3