Search in sources :

Example 6 with ServerType

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

the class UserAuthGeneralInfoPage method createControl.

/**
	 * Create the control for this page
	 * 
	 * @param parent the parent composite
	 */
public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    layout.marginHeight = 10;
    layout.marginWidth = 10;
    composite.setLayout(layout);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(gridData);
    Label userIdLabel = new Label(composite, SWT.LEFT);
    userIdLabel.setText(com.cubrid.cubridmanager.ui.host.Messages.lblUserName);
    userIdLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    userIdText = new Text(composite, SWT.LEFT | SWT.BORDER);
    userIdText.setTextLimit(32);
    userIdText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    userIdText.addModifyListener(this);
    Label passwordLabel = new Label(composite, SWT.LEFT);
    passwordLabel.setText(com.cubrid.cubridmanager.ui.host.Messages.lblPassword);
    passwordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordText = new Text(composite, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordText.setTextLimit(32);
    passwordText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    passwordText.addModifyListener(this);
    Label newPasswordLabel = new Label(composite, SWT.LEFT);
    newPasswordLabel.setText(com.cubrid.cubridmanager.ui.host.Messages.lblPasswordConfirm);
    newPasswordLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    passwordConfirmText = new Text(composite, SWT.LEFT | SWT.PASSWORD | SWT.BORDER);
    passwordConfirmText.setTextLimit(32);
    passwordConfirmText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    passwordConfirmText.addModifyListener(this);
    ServerType serverType = server.getServerInfo().getServerType();
    if (serverType == ServerType.BOTH || serverType == ServerType.DATABASE) {
        Label dbCreationAuthLabel = new Label(composite, SWT.LEFT);
        dbCreationAuthLabel.setText(Messages.lblDbAuth);
        dbCreationAuthLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        dbCreationAuthCombo = new Combo(composite, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
        dbCreationAuthCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    }
    if (serverType == ServerType.BOTH || serverType == ServerType.BROKER) {
        Label brokerLabel = new Label(composite, SWT.LEFT);
        brokerLabel.setText(Messages.lblBrokerAuth);
        brokerLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        brokerAuthCombo = new Combo(composite, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
        brokerAuthCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    }
    Label statusMonitorLabel = new Label(composite, SWT.LEFT);
    statusMonitorLabel.setText(Messages.lblMonitorAuth);
    statusMonitorLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    statusMonitorAuthCombo = new Combo(composite, SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    statusMonitorAuthCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
    initial();
    if (userInfo == null) {
        setTitle(Messages.titleAddUser);
        setMessage(Messages.msgAddUser);
    } else {
        setTitle(Messages.titleEditUser);
        setMessage(Messages.msgEidtUser);
    }
    setControl(composite);
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo)

Example 7 with ServerType

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

the class UserManagementWizard method performFinish.

/**
	 * Called when user clicks Finish
	 * 
	 * @return boolean
	 */
public boolean performFinish() {
    final String userId = generalInfoPage.getUserId();
    final String password = generalInfoPage.getPassword();
    final String dbCreationAuth = generalInfoPage.getDbCreationAuth();
    final String brokerAuth = generalInfoPage.getBrokerAuth();
    final String statusMonitorAuth = generalInfoPage.getStatusMonitorAuth();
    final List<DatabaseInfo> authDatabaselist = new ArrayList<DatabaseInfo>();
    final Shell shell = getShell();
    final String taskName = Messages.bind(Messages.updateUserTaskName, userId);
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(shell, msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
            }
            ServerUserInfo loginedUserInfo = server.getServerInfo().getLoginedUserInfo();
            if (userInfo == null) {
                userInfo = new ServerUserInfo(userId, password);
            } else {
                userInfo.setPassword(password);
            }
            if (userInfo.getUserName().equals(loginedUserInfo.getUserName())) {
                loginedUserInfo.setPassword(password);
            }
            if (!userInfo.isAdmin()) {
                if (dbCreationAuth.equals(DbCreateAuthType.AUTH_NONE.getText())) {
                    userInfo.setDbCreateAuthType(DbCreateAuthType.AUTH_NONE);
                } else if (dbCreationAuth.equals(DbCreateAuthType.AUTH_ADMIN.getText())) {
                    userInfo.setDbCreateAuthType(DbCreateAuthType.AUTH_ADMIN);
                }
                if (brokerAuth.equals(CasAuthType.AUTH_NONE.getText())) {
                    userInfo.setCasAuth(CasAuthType.AUTH_NONE);
                } else if (brokerAuth.equals(CasAuthType.AUTH_ADMIN.getText())) {
                    userInfo.setCasAuth(CasAuthType.AUTH_ADMIN);
                } else if (brokerAuth.equals(CasAuthType.AUTH_MONITOR.getText())) {
                    userInfo.setCasAuth(CasAuthType.AUTH_MONITOR);
                }
                if (statusMonitorAuth.equals(StatusMonitorAuthType.AUTH_NONE.getText())) {
                    userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_NONE);
                } else if (statusMonitorAuth.equals(StatusMonitorAuthType.AUTH_ADMIN.getText())) {
                    userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_ADMIN);
                } else if (statusMonitorAuth.equals(StatusMonitorAuthType.AUTH_MONITOR.getText())) {
                    userInfo.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_MONITOR);
                }
                userInfo.removeAllDatabaseInfo();
                userInfo.setDatabaseInfoList(authDatabaselist);
            }
            return true;
        }
    };
    if (userInfo != null && userInfo.isAdmin()) {
        ChangeCMUserPasswordTask changeCMUserPasswordTask = new ChangeCMUserPasswordTask(server.getServerInfo());
        changeCMUserPasswordTask.setUserName(userId);
        changeCMUserPasswordTask.setPassword(password);
        taskExcutor.addTask(changeCMUserPasswordTask);
    } else if (userInfo != null && !userInfo.isAdmin()) {
        DeleteCMUserTask deleteCMUserTask = new DeleteCMUserTask(server.getServerInfo());
        deleteCMUserTask.setUserId(userId);
        taskExcutor.addTask(deleteCMUserTask);
    }
    if (userInfo == null || !userInfo.isAdmin()) {
        AddCMUserTask addCMUserTask = new AddCMUserTask(server.getServerInfo());
        addCMUserTask.setUserId(userId);
        addCMUserTask.setPassword(password);
        addCMUserTask.setDbcreate(dbCreationAuth);
        addCMUserTask.setCasAuth(brokerAuth);
        addCMUserTask.setStautsMonitorAuth(statusMonitorAuth);
        taskExcutor.addTask(addCMUserTask);
    }
    ServerType serverType = server.getServerInfo().getServerType();
    if ((userInfo == null || !userInfo.isAdmin()) && (serverType == ServerType.BOTH || serverType == ServerType.DATABASE)) {
        List<Map<String, Object>> dbAuthInfoList = authDbInfoPage.getDbAuthInfoList();
        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 (dbAuthInfoList != null && !dbAuthInfoList.isEmpty()) {
            int size = dbAuthInfoList.size();
            for (int i = 0; i < size; i++) {
                Map<String, Object> map = dbAuthInfoList.get(i);
                String allowConnectedStr = (String) map.get("1");
                if ("Yes".equals(allowConnectedStr)) {
                    String dbName = (String) map.get("0");
                    dbNameList.add(dbName);
                    String dbUser = (String) map.get("2");
                    dbUserList.add(dbUser);
                    String brokerIP = (String) map.get("3");
                    String brokerPort = (String) map.get("4");
                    String port = "";
                    if (brokerPort.matches("^\\d+$")) {
                        port = brokerPort;
                    } else {
                        port = brokerPort.substring(brokerPort.indexOf("[") + 1, brokerPort.indexOf("/"));
                    }
                    dbBrokerPortList.add(brokerIP + "," + port);
                    dbPasswordList.add("");
                    DatabaseInfo databaseInfo = new DatabaseInfo(dbName, server.getServerInfo());
                    databaseInfo.setBrokerPort(brokerPort);
                    databaseInfo.setBrokerIP(brokerIP);
                    DbUserInfo dbUserInfo = new DbUserInfo();
                    dbUserInfo.setName(dbUser);
                    databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
                    authDatabaselist.add(databaseInfo);
                }
            }
        }
        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 updateTask = new UpdateCMUserTask(server.getServerInfo());
        updateTask.setCmUserName(userId);
        updateTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
        updateTask.setCasAuth(brokerAuth);
        updateTask.setDbCreator(dbCreationAuth);
        updateTask.setStatusMonitorAuth(statusMonitorAuth);
        taskExcutor.addTask(updateTask);
    }
    new ExecTaskWithProgress(taskExcutor).exec(true, true);
    return taskExcutor.isSuccess();
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ChangeCMUserPasswordTask(com.cubrid.cubridmanager.core.common.task.ChangeCMUserPasswordTask) ArrayList(java.util.ArrayList) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DeleteCMUserTask(com.cubrid.cubridmanager.core.common.task.DeleteCMUserTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) Map(java.util.Map) AddCMUserTask(com.cubrid.cubridmanager.core.common.task.AddCMUserTask)

Example 8 with ServerType

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

the class UserManagementTableViewerSorter method deleteUser.

/**
	 * 
	 * Execute task and delete user
	 * 
	 * @param userInfoMapArr the user info map
	 */
@SuppressWarnings("rawtypes")
private void deleteUser(final Map[] userInfoMapArr) {
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            monitor.beginTask(Messages.delUserTaskName, IProgressMonitor.UNKNOWN);
            for (ITask task : taskList) {
                task.execute();
                final String msg = task.getErrorMsg();
                if (openErrorBox(getShell(), msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof DeleteCMUserTask) {
                    DeleteCMUserTask deleteCMUserTask = (DeleteCMUserTask) task;
                    String userId = deleteCMUserTask.getUserId();
                    for (int i = 0; i < userInfoMapArr.length; i++) {
                        String id = (String) userInfoMapArr[i].get("0");
                        if (userId.equals(id)) {
                            serverUserInfoTableList.remove(userInfoMapArr[i]);
                            ServerType serverType = server.getServerInfo().getServerType();
                            if (serverType == ServerType.BOTH) {
                                serverUserInfoList.remove(userInfoMapArr[i].get("4"));
                            } else {
                                serverUserInfoList.remove(userInfoMapArr[i].get("3"));
                            }
                            break;
                        }
                    }
                }
            }
            return true;
        }
    };
    for (int i = 0; userInfoMapArr != null && i < userInfoMapArr.length; i++) {
        DeleteCMUserTask deleteTask = new DeleteCMUserTask(server.getServerInfo());
        Map map = userInfoMapArr[i];
        deleteTask.setUserId((String) map.get("0"));
        taskExcutor.addTask(deleteTask);
    }
    new ExecTaskWithProgress(taskExcutor).exec(true, true);
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) DeleteCMUserTask(com.cubrid.cubridmanager.core.common.task.DeleteCMUserTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with ServerType

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

the class UserManagementTableViewerSorter method initialTableModel.

/**
	 * 
	 * Initial the table model of user list table
	 * 
	 */
private void initialTableModel() {
    ServerType serverType = server.getServerInfo().getServerType();
    for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
        ServerUserInfo userInfo = serverUserInfoList.get(i);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("0", userInfo.getUserName());
        if (serverType == ServerType.BOTH) {
            map.put("1", userInfo.getDbCreateAuthType().getText());
            map.put("2", userInfo.getCasAuth().getText());
            map.put("3", userInfo.getStatusMonitorAuth().getText());
            map.put("4", userInfo);
        }
        if (serverType == ServerType.DATABASE) {
            map.put("1", userInfo.getDbCreateAuthType().getText());
            map.put("2", userInfo.getStatusMonitorAuth().getText());
            map.put("3", userInfo);
        } else if (serverType == ServerType.BROKER) {
            map.put("1", userInfo.getCasAuth().getText());
            map.put("2", userInfo.getStatusMonitorAuth().getText());
            map.put("3", userInfo);
        }
        serverUserInfoTableList.add(map);
    }
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) HashMap(java.util.HashMap) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 10 with ServerType

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

the class ServerConfigPropertyPage method initial.

/**
	 * initial the page content
	 */
private void initial() {
    CubridServer server = node.getServer();
    ServerInfo serverInfo = server == null ? null : server.getServerInfo();
    if (server != null && serverInfo != null) {
        hostNameInfoLabel.setText(server.getLabel());
        hostAddressInfoLabel.setText(server.getHostAddress());
        portInfoLabel.setText(server.getMonPort());
        userNameInfoLabel.setText(server.getUserName());
        jdbcInfoLabel.setText(server.getJdbcDriverVersion());
        ServerType serverType = serverInfo.getServerType();
        String type = "server,broker";
        if (serverType == ServerType.BROKER) {
            type = "broker";
        } else if (serverType == ServerType.DATABASE) {
            type = "server";
        }
        serverTypeInfoLabel.setText(type);
    }
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Aggregations

ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)26 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)10 Map (java.util.Map)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)7 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)6 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)6 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)6 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)6 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)6 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)6 HashMap (java.util.HashMap)6 ITask (com.cubrid.common.core.task.ITask)5 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)5 ArrayList (java.util.ArrayList)5 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)4 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)4 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)3