Search in sources :

Example 46 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class CubridServerLoader method load.

/**
	 *
	 * Load children object for parent
	 *
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        parent.setEditorId(HostDashboardEditor.ID);
        CubridServer server = parent.getServer();
        if (!server.isConnected()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        ServerType serverType = server.getServerInfo().getServerType();
        // add database folder
        if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
            String databaseFolderId = parent.getId() + NODE_SEPARATOR + DATABASE_FOLDER_ID;
            ICubridNode databaseFolder = parent.getChild(databaseFolderId);
            if (databaseFolder == null) {
                databaseFolder = new DefaultCubridNode(databaseFolderId, DATABASE_FOLDER_NAME, "icons/navigator/database_group.png");
                databaseFolder.setType(NodeType.DATABASE_FOLDER);
                databaseFolder.setContainer(true);
                ICubridNodeLoader loader = new CubridDatabasesFolderLoader();
                loader.setLevel(getLevel());
                databaseFolder.setLoader(loader);
                parent.addChild(databaseFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    databaseFolder.getChildren(monitor);
                }
            } else {
                if (databaseFolder.getLoader() != null && databaseFolder.getLoader().isLoaded()) {
                    databaseFolder.getLoader().setLoaded(false);
                    databaseFolder.getChildren(monitor);
                }
            }
        }
        ServerUserInfo userInfo = parent.getServer().getServerInfo().getLoginedUserInfo();
        // add broker folder
        if ((serverType == ServerType.BOTH || serverType == ServerType.BROKER) && userInfo != null && (CasAuthType.AUTH_ADMIN == userInfo.getCasAuth() || CasAuthType.AUTH_MONITOR == userInfo.getCasAuth())) {
            String brokerFolderId = parent.getId() + NODE_SEPARATOR + BROKER_FOLDER_ID;
            ICubridNode brokerFolder = parent.getChild(brokerFolderId);
            if (brokerFolder == null) {
                brokerFolder = new CubridBrokerFolder(brokerFolderId, BROKER_FOLDER_NAME, "icons/navigator/broker_group.png");
                ((CubridBrokerFolder) brokerFolder).setStartedIconPath("icons/navigator/broker_service_started.png");
                brokerFolder.setContainer(true);
                brokerFolder.setViewId(BrokerEnvStatusView.ID);
                ICubridNodeLoader loader = new CubridBrokersFolderLoader();
                loader.setLevel(getLevel());
                brokerFolder.setLoader(loader);
                parent.addChild(brokerFolder);
                if (getLevel() == DEFINITE_LEVEL) {
                    brokerFolder.getChildren(monitor);
                }
            } else {
                if (brokerFolder.getLoader() != null && brokerFolder.getLoader().isLoaded()) {
                    brokerFolder.getLoader().setLoaded(false);
                    brokerFolder.getChildren(monitor);
                }
            }
        }
        //			#2 Remove the legacy monitoring menu
        //			// add monitor folder
        //			if (userInfo != null
        //					&& (StatusMonitorAuthType.AUTH_ADMIN == userInfo.getStatusMonitorAuth() || StatusMonitorAuthType.AUTH_MONITOR == userInfo.getStatusMonitorAuth())) {
        //				String monitroingId = parent.getId() + NODE_SEPARATOR
        //						+ MONITORING_FOLDER_ID;
        //				ICubridNode monitoringFolder = parent.getChild(monitroingId);
        //				if (monitoringFolder == null) {
        //					monitoringFolder = new DefaultCubridNode(monitroingId,
        //							MONITORING_FOLDER_NAME,
        //							"icons/navigator/status_group.png");
        //					monitoringFolder.setType(CubridNodeType.MONITOR_FOLDER);
        //					monitoringFolder.setContainer(true);
        //					ICubridNodeLoader loader = new CubridMonitorFolderLoader();
        //					loader.setLevel(getLevel());
        //					monitoringFolder.setLoader(loader);
        //					parent.addChild(monitoringFolder);
        //					if (getLevel() == DEFINITE_LEVEL) {
        //						monitoringFolder.getChildren(monitor);
        //					}
        //				} else {
        //					if (monitoringFolder.getLoader() != null
        //							&& monitoringFolder.getLoader().isLoaded()) {
        //						monitoringFolder.getLoader().setLoaded(false);
        //						monitoringFolder.getChildren(monitor);
        //					}
        //				}
        //			}
        // add logs folder
        String logsFolderId = parent.getId() + NODE_SEPARATOR + LOGS_FOLDER_ID;
        ICubridNode logsFolder = parent.getChild(logsFolderId);
        if (logsFolder == null) {
            logsFolder = new DefaultCubridNode(logsFolderId, LOGS_FOLDER_NAME, "icons/navigator/log_group_big.png");
            logsFolder.setType(CubridNodeType.LOGS_FOLDER);
            logsFolder.setContainer(true);
            ICubridNodeLoader loader = new CubridLogsFolderLoader();
            loader.setLevel(getLevel());
            logsFolder.setLoader(loader);
            parent.addChild(logsFolder);
            if (getLevel() == DEFINITE_LEVEL) {
                logsFolder.getChildren(monitor);
            }
        } else {
            if (logsFolder.getLoader() != null && logsFolder.getLoader().isLoaded()) {
                logsFolder.getLoader().setLoaded(false);
                logsFolder.getChildren(monitor);
            }
        }
        if (server.isConnected() && CompatibleUtil.isSupportHA(server.getServerInfo())) {
            getHostStatus(server);
        }
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridBrokerFolder(com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder) CubridLogsFolderLoader(com.cubrid.cubridmanager.ui.spi.model.loader.logs.CubridLogsFolderLoader)

Example 47 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class CubridDatabaseLogFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        List<DatabaseInfo> databaseInfoList = userInfo.getDatabaseInfoList();
        if (databaseInfoList == null || databaseInfoList.size() <= 0) {
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
        oldNodeList.addAll(parent.getChildren());
        parent.removeAllChild();
        for (int i = 0; i < databaseInfoList.size() && !monitor.isCanceled(); i++) {
            DatabaseInfo databaseInfo = databaseInfoList.get(i);
            String id = parent.getId() + NODE_SEPARATOR + databaseInfo.getDbName();
            ICubridNode logDatabaseNode = isContained(oldNodeList, id);
            if (logDatabaseNode == null) {
                logDatabaseNode = new DefaultCubridNode(id, databaseInfo.getDbName(), "icons/navigator/folder.png");
                logDatabaseNode.setType(CubridNodeType.LOGS_SERVER_DATABASE_FOLDER);
                logDatabaseNode.setModelObj(databaseInfo);
                logDatabaseNode.setContainer(true);
                ICubridNodeLoader loader = new CubridDatabaseLogLoader();
                loader.setLevel(getLevel());
                logDatabaseNode.setLoader(loader);
                parent.addChild(logDatabaseNode);
                if (getLevel() == DEFINITE_LEVEL) {
                    logDatabaseNode.getChildren(monitor);
                }
            } else {
                parent.addChild(logDatabaseNode);
                if (logDatabaseNode.getLoader() != null && logDatabaseNode.getLoader().isLoaded()) {
                    logDatabaseNode.getLoader().setLoaded(false);
                    logDatabaseNode.getChildren(monitor);
                }
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 48 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class CubridSystemMonitorFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        if (userInfo == null || StatusMonitorAuthType.AUTH_NONE == userInfo.getStatusMonitorAuth()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        String hostSystemId = parent.getId() + NODE_SEPARATOR + HOST_SYSTEM_ID;
        ICubridNode hostSystemNode = new DefaultCubridNode(hostSystemId, Messages.msgHostSystemMonitorName, "icons/navigator/status_item.png");
        hostSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
        hostSystemNode.setViewId(HostSystemMonitorViewPart.ID);
        hostSystemNode.setContainer(false);
        parent.addChild(hostSystemNode);
        if (CompatibleUtil.isSupportDBSystemMonitor(serverInfo)) {
            String dbSystemId = parent.getId() + NODE_SEPARATOR + DB_SYSTEM_ID;
            ICubridNode dbSystemNode = new DefaultCubridNode(dbSystemId, Messages.msgDbSystemMonitorName, "icons/navigator/status_item.png");
            dbSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
            dbSystemNode.setViewId(DbSystemMonitorViewPart.ID);
            dbSystemNode.setContainer(false);
            parent.addChild(dbSystemNode);
        }
    }
    Collections.sort(parent.getChildren());
    setLoaded(true);
    CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 49 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class CubridMonitorFolderLoader method load.

/**
	 *
	 * Load children object for parent
	 *
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        if (userInfo == null || StatusMonitorAuthType.AUTH_NONE == userInfo.getStatusMonitorAuth()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        //add status node
        if (CompatibleUtil.isSupportBrokerOrDBStatusMonitor(serverInfo)) {
            String brokerStatusId = parent.getId() + NODE_SEPARATOR + BROKER_STATUS_ID;
            ICubridNode brokerStatusNode = new DefaultCubridNode(brokerStatusId, Messages.msgBrokerStatusMonitorName, "icons/navigator/status_item.png");
            brokerStatusNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
            brokerStatusNode.setViewId(BrokerStatusMonitorViewPart.ID);
            brokerStatusNode.setContainer(false);
            parent.addChild(brokerStatusNode);
            String dbStatusId = parent.getId() + NODE_SEPARATOR + DB_STATUS_ID;
            ICubridNode dbStautsNode = new DefaultCubridNode(dbStatusId, Messages.msgDbStatusMonitorName, "icons/navigator/status_item.png");
            dbStautsNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
            dbStautsNode.setViewId(DbStatusDumpMonitorViewPart.ID);
            dbStautsNode.setContainer(false);
            parent.addChild(dbStautsNode);
            createTempStatusNode(parent);
        } else {
            if (!loadStatusTempInfoTask(parent, monitor, serverInfo)) {
                return;
            }
        }
        //add system node
        if (CompatibleUtil.isSupportSystemMonitor(serverInfo)) {
            String hostSystemId = parent.getId() + NODE_SEPARATOR + HOST_SYSTEM_ID;
            ICubridNode hostSystemNode = new DefaultCubridNode(hostSystemId, Messages.msgHostSystemMonitorName, "icons/navigator/status_item.png");
            hostSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
            hostSystemNode.setViewId(HostSystemMonitorViewPart.ID);
            hostSystemNode.setContainer(false);
            parent.addChild(hostSystemNode);
            if (CompatibleUtil.isSupportDBSystemMonitor(serverInfo)) {
                String dbSystemId = parent.getId() + NODE_SEPARATOR + DB_SYSTEM_ID;
                ICubridNode dbSystemNode = new DefaultCubridNode(dbSystemId, Messages.msgDbSystemMonitorName, "icons/navigator/status_item.png");
                dbSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
                dbSystemNode.setViewId(DbSystemMonitorViewPart.ID);
                dbSystemNode.setContainer(false);
                parent.addChild(dbSystemNode);
            }
        }
        //add monitor statistic node
        if (CompatibleUtil.isSupportMonitorStatistic(serverInfo)) {
            List<MonitorStatistic> childList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(serverInfo.getServerName());
            for (MonitorStatistic node : childList) {
                if (node == null) {
                    continue;
                }
                parent.addChild(node);
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 50 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo 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)

Aggregations

ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)101 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)33 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)23 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)21 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)19 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 ArrayList (java.util.ArrayList)16 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)12 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)10 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)10 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)8 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)8 CubridBrokerFolder (com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)8 Map (java.util.Map)8 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 ITask (com.cubrid.common.core.task.ITask)6 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)6 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)6 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)6