Search in sources :

Example 16 with DbUserInfo

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

the class ActionSupportUtil method isSupportSinSelCheckDbUser.

/**
	 * 
	 * Return whether support the single selection and the selection type is
	 * equal <code>type</code> and the selection owner is equal to logined
	 * database user
	 * 
	 * @param obj Object
	 * @param type String
	 * @return boolean
	 */
public static boolean isSupportSinSelCheckDbUser(Object obj, String type) {
    if (obj == null) {
        return false;
    }
    Object selectedObj = obj;
    if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        if (objArr.length == 1) {
            selectedObj = objArr[0];
        } else {
            return false;
        }
    }
    if (!(selectedObj instanceof ISchemaNode)) {
        return false;
    }
    ISchemaNode node = (ISchemaNode) selectedObj;
    if (type.equals(node.getType())) {
        ISchemaNode schemaNode = (ISchemaNode) selectedObj;
        CubridDatabase database = schemaNode.getDatabase();
        if (isNotRunningAndNotLogin(database)) {
            return false;
        }
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        if (dbInfo == null) {
            LOGGER.error("The database.getDatabaseInfo() is a null.");
            return false;
        }
        DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
        if (userInfo == null) {
            LOGGER.error("The dbInfo.getAuthLoginedDbUserInfo() is a null.");
            return false;
        }
        if (userInfo.isDbaAuthority()) {
            return true;
        }
        boolean isSameUser = StringUtil.isEqualIgnoreCase(userInfo.getName(), getOwner(schemaNode));
        if (isSameUser) {
            return true;
        }
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 17 with DbUserInfo

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

the class ActionSupportUtil method isSupportMultiSelCheckDbUser.

/**
	 * 
	 * Return whether support the multi selection and all selection type is
	 * equal <code>type</code> and the all selection owner is equal to logined
	 * database user
	 * 
	 * @param obj Object
	 * @param type String
	 * @return boolean
	 */
public static boolean isSupportMultiSelCheckDbUser(Object obj, String type) {
    if (obj instanceof ISchemaNode) {
        ISchemaNode schemaNode = (ISchemaNode) obj;
        if (!type.equals(schemaNode.getType())) {
            return false;
        }
        CubridDatabase database = schemaNode.getDatabase();
        if (isNotRunningAndNotLogin(database)) {
            return false;
        }
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        if (dbInfo == null) {
            LOGGER.error("The database.getDatabaseInfo() is a null.");
            return false;
        }
        DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
        if (userInfo == null) {
            LOGGER.error("The dbInfo.getAuthLoginedDbUserInfo() is a null.");
            return false;
        }
        if (userInfo.isDbaAuthority()) {
            return true;
        }
        boolean isSameUser = StringUtil.isEqualIgnoreCase(userInfo.getName(), getOwner(schemaNode));
        if (isSameUser) {
            return true;
        }
    } else if (obj instanceof Object[]) {
        Object[] objArr = (Object[]) obj;
        if (objArr.length == 0) {
            return false;
        }
        CubridDatabase database = null;
        for (Object object : objArr) {
            //Check every object whether support
            if (!isSupportMultiSelCheckDbUser(object, type)) {
                return false;
            }
            //Check whether they are in the same database
            ISchemaNode node = (ISchemaNode) object;
            CubridDatabase db = node.getDatabase();
            if (database == null) {
                database = db;
            } else if (!database.getId().equals(db.getId())) {
                return false;
            }
        }
        //Check the database whether login and running
        if (isNotRunningAndNotLogin(database)) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 18 with DbUserInfo

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

the class DatabaseInfoTest method testGetAuthLoginedDbUserInfo.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#getAuthLoginedDbUserInfo()}
	 * .
	 */
public void testGetAuthLoginedDbUserInfo() {
    DbUserInfo authDbUserInfo = new DbUserInfo();
    bean.setAuthLoginedDbUserInfo(authDbUserInfo);
    assertNotNull(bean.getAuthLoginedDbUserInfo());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)

Example 19 with DbUserInfo

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

the class DatabaseInfoTest method testAddDbUserInfo.

/**
	 * Test method for
	 * {@link com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo#addDbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)}
	 * .
	 */
public void testAddDbUserInfo() {
    bean.addDbUserInfo(new DbUserInfo());
    bean.removeDbUserInfo(new DbUserInfo());
    bean.setDbUserInfoList(null);
    bean.removeDbUserInfo(new DbUserInfo());
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)

Example 20 with DbUserInfo

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

Aggregations

DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)80 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)36 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)16 ArrayList (java.util.ArrayList)14 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)10 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)10 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 DbUserInfoList (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfoList)8 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)7 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)6 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 IsDBAUserTask (com.cubrid.cubridmanager.core.cubrid.user.task.IsDBAUserTask)6 CQBDbConnectionLoader (com.cubrid.cubridmanager.ui.spi.model.loader.CQBDbConnectionLoader)6 HashMap (java.util.HashMap)6 CubridNodeLoader (com.cubrid.common.ui.spi.model.CubridNodeLoader)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5