Search in sources :

Example 1 with DbUserInfoList

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.

the class GetUserInfoTaskTest method testUpdateMessage.

public void testUpdateMessage() {
    // test get user list
    final CommonQueryTask<DbUserInfoList> userTask = new CommonQueryTask<DbUserInfoList>(serverInfo930, CommonSendMsg.getCommonDatabaseSendMsg(), new DbUserInfoList());
    userTask.setDbName(databaseInfo930.getDbName());
    userTask.execute();
    assertEquals(null, userTask.getErrorMsg());
    assertEquals(true, userTask.getResultModel() != null);
    List<DbUserInfo> userListInfo = userTask.getResultModel().getUserList();
    String newUserName = getUserName(userListInfo, "a");
    // test add user 
    UpdateAddUserTask task = new UpdateAddUserTask(serverInfo930, true);
    UserSendObj userSendObj = new UserSendObj();
    userSendObj.setDbname(databaseInfo930.getDbName());
    userSendObj.setUsername(newUserName);
    userSendObj.setUserpass("123456");
    userSendObj.addGroups("public");
    task.setUserSendObj(userSendObj);
    task.execute();
    task.getUserSendObj();
    task.isSuccess();
    task.setUserName("dba");
    task.setDbName(testDbName930);
    assertEquals(null, task.getErrorMsg());
    // test edit user 
    task = new UpdateAddUserTask(serverInfo930, false);
    userSendObj = new UserSendObj();
    userSendObj.setDbname(databaseInfo930.getDbName());
    userSendObj.setUsername(newUserName);
    userSendObj.setUserpass("223456");
    userSendObj.addGroups("public");
    task.setUserSendObj(userSendObj);
    task.execute();
    assertEquals(null, task.getErrorMsg());
    // test delete user
    CommonUpdateTask commonTask = new CommonUpdateTask(CommonTaskName.DELETE_USER_TASK_NAME, serverInfo930, CommonSendMsg.getDeleteUserMSGItems());
    commonTask.setDbName(databaseInfo930.getDbName());
    commonTask.setUserName(newUserName);
    commonTask.execute();
    assertEquals(null, commonTask.getErrorMsg());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) UpdateAddUserTask(com.cubrid.cubridmanager.core.cubrid.user.task.UpdateAddUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) UserSendObj(com.cubrid.cubridmanager.core.cubrid.database.model.UserSendObj) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)

Example 2 with DbUserInfoList

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.

the class DatabaseInfoTest method testGetDbUserInfoList.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#getDbUserInfoList()}
	 * .
	 */
public void testGetDbUserInfoList() {
    DbUserInfoList dbUserInfoList = new DbUserInfoList();
    bean.setDbUserInfoList(dbUserInfoList);
    assertTrue(bean.getDbUserInfoList() != null);
}
Also used : DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)

Example 3 with DbUserInfoList

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.

the class DatabaseModelTest method testModelDatabaseInfo.

@SuppressWarnings({ "unchecked", "rawtypes" })
public void testModelDatabaseInfo() {
    DatabaseInfo bean = new DatabaseInfo(testDbName, serverInfo);
    bean.setDbName("dbName");
    assertEquals(bean.getDbName(), "dbName");
    bean.setLogined(true);
    assertTrue(bean.isLogined());
    bean.setDbDir("dbDir");
    assertEquals(bean.getDbDir(), "dbDir");
    bean.setRunningType(DbRunningType.CS);
    assertEquals(bean.getRunningType(), DbRunningType.CS);
    DbUserInfoList dbUserInfoList = new DbUserInfoList();
    bean.setDbUserInfoList(dbUserInfoList);
    assertTrue(bean.getDbUserInfoList() != null);
    DbUserInfo dbUserInfo = new DbUserInfo();
    bean.addDbUserInfo(dbUserInfo);
    bean.removeDbUserInfo(dbUserInfo);
    bean.setAuthLoginedDbUserInfo(dbUserInfo);
    assertEquals(bean.getAuthLoginedDbUserInfo(), dbUserInfo);
    bean.setBrokerPort("brokerPort");
    assertEquals(bean.getBrokerPort(), "brokerPort");
    bean.setTriggerList(new ArrayList());
    assertEquals(bean.getTriggerList() != null, true);
    bean.setUserTableInfoList(new ArrayList());
    assertEquals(bean.getUserTableInfoList() != null, true);
    bean.setUserViewInfoList(new ArrayList());
    assertEquals(bean.getUserViewInfoList() != null, true);
    bean.setSysTableInfoList(new ArrayList());
    assertEquals(bean.getSysTableInfoList() != null, true);
    bean.setSysViewInfoList(new ArrayList());
    assertEquals(bean.getSysViewInfoList() != null, true);
    bean.setPartitionedTableMap(new HashMap());
    assertEquals(bean.getPartitionedTableMap() != null, true);
    bean.setBackupPlanInfoList(new ArrayList());
    assertEquals(bean.getBackupPlanInfoList() != null, true);
    bean.setQueryPlanInfoList(new ArrayList());
    assertEquals(bean.getQueryPlanInfoList() != null, true);
    bean.setDbSpaceInfoList(new DbSpaceInfoList());
    assertEquals(bean.getDbSpaceInfoList() != null, true);
    bean.setDbUserInfoList(new DbUserInfoList());
    assertEquals(bean.getDbUserInfoList() != null, true);
    bean.setSpProcedureInfoList(new ArrayList());
    assertEquals(bean.getSpProcedureInfoList() != null, true);
    bean.setSpFunctionInfoList(new ArrayList());
    assertEquals(bean.getSpFunctionInfoList() != null, true);
    bean.setSerialInfoList(new ArrayList());
    assertEquals(bean.getSerialInfoList() != null, true);
    bean.setServerInfo(serverInfo);
    assertEquals(bean.getServerInfo() != null, true);
    bean.clear();
    bean.setLogined(true);
    assertEquals(bean.isLogined(), true);
    bean.addDbUserInfo(new DbUserInfo());
    bean.removeDbUserInfo(new DbUserInfo());
    bean.getClassInfoList();
    bean.addPartitionedTableList("dbname", null);
    bean.addBackupPlanInfo(new BackupPlanInfo());
    bean.removeBackupPlanInfo(new BackupPlanInfo());
    bean.removeAllBackupPlanInfo();
    bean.addQueryPlanInfo(new QueryPlanInfo());
    bean.removeQueryPlanInfo(new QueryPlanInfo());
    bean.removeAllQueryPlanInfo();
    bean.addSpaceInfo(new DbSpaceInfo());
    bean.removeSpaceInfo(new DbSpaceInfo());
    bean.getSpInfoList();
    bean.getSchemaInfo("tableName");
    bean.putSchemaInfo(new SchemaInfo());
    bean.clearSchemas();
    bean.getErrorMessage();
    bean.setDbUserInfoList(null);
    assertEquals(bean.getDbUserInfoList(), null);
    bean.addDbUserInfo(new DbUserInfo());
    bean.removeDbUserInfo(new DbUserInfo());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) HashMap(java.util.HashMap) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ArrayList(java.util.ArrayList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 4 with DbUserInfoList

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.

the class GetUserListTaskTest method testGetUserListTask.

public void testGetUserListTask() throws Exception {
    GetUserListTask task = new GetUserListTask(databaseInfo);
    task.execute();
    DbUserInfoList dbUserInfoList = task.getResultModel();
    assertNotNull(dbUserInfoList);
    Connection connection = null;
    try {
        connection = JDBCConnectionManager.getConnection(databaseInfo, true);
        task = new GetUserListTask(databaseInfo, connection);
        task.execute();
        List<String> allUsersList = task.getAllDbUserList();
        assertNotNull(allUsersList);
    } catch (SQLException ex) {
    } finally {
        QueryUtil.freeQuery(connection);
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)

Example 5 with DbUserInfoList

use of com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList in project cubrid-manager by CUBRID.

the class CQBDbUsersFolderLoader 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;
        }
        CubridDatabase database = ((ISchemaNode) parent).getDatabase();
        if (database.getRunningType() == DbRunningType.STANDALONE) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        DatabaseInfo databaseInfo = database.getDatabaseInfo();
        DbUserInfoList dbUserInfoList = new DbUserInfoList();
        GetUserListTask task = new GetUserListTask(database.getDatabaseInfo());
        parent.removeAllChild();
        try {
            dbUserInfoList = task.getResultModel();
        } catch (Exception e) {
            LOGGER.error("load user failed", e);
        }
        DbUserInfo latestDLoginedbUserInfo = databaseInfo.getAuthLoginedDbUserInfo();
        List<DbUserInfo> dbUserList = dbUserInfoList == null ? null : dbUserInfoList.getUserList();
        formatUserList(dbUserList);
        for (int i = 0; dbUserList != null && dbUserList.size() > i; i++) {
            DbUserInfo dbUserInfo = dbUserList.get(i);
            if (dbUserInfo.getName().equals(latestDLoginedbUserInfo.getName())) {
                dbUserInfo.setDbaAuthority(latestDLoginedbUserInfo.isDbaAuthority());
            // databaseInfo.setAuthLoginedDbUserInfo(dbUserInfo);
            }
            String id = parent.getId() + NODE_SEPARATOR + dbUserInfo.getName();
            ICubridNode dbUserInfoNode = new DefaultSchemaNode(id, dbUserInfo.getName(), "icons/navigator/user_item.png");
            dbUserInfoNode.setType(NodeType.USER);
            dbUserInfoNode.setModelObj(dbUserInfo);
            dbUserInfoNode.setContainer(false);
            dbUserInfoNode.setEditorId(CQBUserEditor.ID);
            parent.addChild(dbUserInfoNode);
        }
        databaseInfo.setDbUserInfoList(dbUserInfoList);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) GetUserListTask(com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) DbUserInfoList(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

DbUserInfoList (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)13 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)4 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)4 GetUserListTask (com.cubrid.cubridmanager.core.cubrid.user.task.GetUserListTask)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)3 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)3 GetAllPartitionClassTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllPartitionClassTask)3 Connection (java.sql.Connection)3 ArrayList (java.util.ArrayList)3 ITask (com.cubrid.common.core.task.ITask)2 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)2 EditUserDialog (com.cubrid.common.ui.cubrid.user.dialog.EditUserDialog)2 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)2 GetUserAuthorizationsTask (com.cubrid.cubridmanager.core.cubrid.user.task.GetUserAuthorizationsTask)2 SQLException (java.sql.SQLException)2