use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class NodeUtil method findDatabaseInfo.
public static DatabaseInfo findDatabaseInfo(ISchemaNode schemaNode) {
if (schemaNode == null) {
LOGGER.error("The schemaNode is a null.");
return null;
}
CubridDatabase cubridDatabase = schemaNode.getDatabase();
if (cubridDatabase == null) {
LOGGER.error("The cubridDatabase is a null.");
return null;
}
final DatabaseInfo databaseInfo = cubridDatabase.getDatabaseInfo();
if (databaseInfo == null) {
LOGGER.error("The databaseInfo is a null.");
return null;
}
return databaseInfo;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class NodeUtil method validNode.
public static boolean validNode(ISchemaNode schemaNode) {
if (schemaNode == null) {
LOGGER.error("The schemaNode is a null.");
return false;
}
CubridDatabase cubridDatabase = schemaNode.getDatabase();
if (cubridDatabase == null) {
LOGGER.error("The cubridDatabase is a null.");
return false;
}
final DatabaseInfo databaseInfo = cubridDatabase.getDatabaseInfo();
if (databaseInfo == null) {
LOGGER.error("The databaseInfo is a null.");
return false;
}
return true;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo 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.database.model.DatabaseInfo 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.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CopyAndDeleteTaskTest method testCopyDataBase.
public void testCopyDataBase() {
// task:copydb
// token:8ec1ab8a91333c78403a39727783958b5f3f25c536c9d92f88b7d31a95a5fadf7926f07dd201b6aa
// srcdbname:aaa
// destdbname:dss
// destdbpath:C:\CUBRID\databases\dss
// exvolpath:C:\CUBRID\databases\dss
// logpath:C:\CUBRID\databases\
// overwrite:n
// move:n
// advanced:on
// open:volume
// C|/CUBRID/databases/aaa/aaa:C|\CUBRID\databases\dss/dss
// C|/CUBRID/databases/aaa/aaa_x001:C|\CUBRID\databases\dss/dss_x001
// C|/CUBRID/databases/aaa/aaa_x002:C|\CUBRID\databases\dss/dss_x002
// close:volume
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
getDatabaseListTask.execute();
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
DatabaseInfo databaseInfo = null;
for (DatabaseInfo bean : databaseInfoList) {
if (bean.getRunningType() == DbRunningType.STANDALONE) {
databaseInfo = bean;
break;
}
}
boolean stopDb = false;
if (databaseInfo == null) {
stopDb = true;
databaseInfo = databaseInfoList.get(0);
CommonUpdateTask stopTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
stopTask.setDbName(databaseInfo.getDbName());
//stopTask.execute();
assertEquals(null, stopTask.getErrorMsg());
}
// check dir
CheckDirTask checkDirTask = new CheckDirTask(serverInfo);
checkDirTask.setDirectory(new String[] { serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname });
//checkDirTask.execute();
assertEquals(null, checkDirTask.getErrorMsg());
/* if (checkDirTask.getNoExistDirectory() != null && checkDirTask.getNoExistDirectory().length > 0) {
}*/
CopyDbTask task = new CopyDbTask(serverInfo);
task.setSrcdbname(databaseInfo.getDbName());
task.setDestdbname(newdbname);
task.setDestdbpath(serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname);
task.setExvolpath(serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname);
task.setLogpath(serverPath + getPathSeparator() + "databases" + getPathSeparator() + newdbname);
task.setOverwrite(YesNoType.N);
task.setMove(YesNoType.N);
task.setAdvanced(OnOffType.OFF);
//task.execute();
System.out.println("getErrorMsg:" + task.getErrorMsg());
assertEquals(null, task.getErrorMsg());
if (stopDb) {
CommonUpdateTask startTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
startTask.setDbName(databaseInfo.getDbName());
//startTask.execute();
assertEquals(null, startTask.getErrorMsg());
}
}
Aggregations