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;
}
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;
}
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());
}
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());
}
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());
}
Aggregations