use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class ActionSupportUtil method hasAdminPermissionOnStopState.
/**
* Whether having cubrid manager's administrative permissions on stop state
*
* @param obj ISchemaNode or ISchemaNode[]
* @return boolean
*/
public static boolean hasAdminPermissionOnStopState(Object obj) {
if (!ActionSupportUtil.hasAdminPermission(obj)) {
return false;
}
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (database == null) {
return false;
}
if (database.getRunningType() != DbRunningType.STANDALONE) {
return false;
}
return true;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode 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.common.ui.spi.model.ISchemaNode 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.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class ShowDatabaseDashboardAction method isSupported.
/**
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj the object
* @return <code>true</code> if support this object;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (obj instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (CubridNodeType.DATABASE.equals(node.getType()) && database.isLogined()) {
return true;
}
}
return false;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class StartDatabaseAction method doRun.
public void doRun(ISchemaNode[] schemaArray) {
if (schemaArray == null || schemaArray.length == 0) {
return;
}
List<ISchemaNode> startList = new ArrayList<ISchemaNode>();
/*Judge start job is running*/
for (ISchemaNode node : schemaArray) {
if (!isSupported(node)) {
setEnabled(false);
return;
}
CubridDatabase database = node.getDatabase();
final JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStartDbWithJob, dbName));
continue;
}
startList.add(database);
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null && startList.size() > 0) {
final TreeViewer treeViewer = navigationView.getViewer();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ITask task = taskList.get(i);
final CubridDatabase database = (CubridDatabase) task.getData("dbName");
if (!isSupported(database)) {
continue;
}
monitor.subTask(Messages.bind(Messages.startDbTaskName, database.getName()));
task.execute();
if (openErrorBox(shell, task.getErrorMsg(), monitor) || monitor.isCanceled()) {
return false;
}
openWarningBox(shell, task.getWarningMsg(), monitor);
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.CS);
display.syncExec(new Runnable() {
public void run() {
treeViewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (ISchemaNode schemaNode : startList) {
CubridDatabase database = schemaNode.getDatabase();
if (!isSupported(database)) {
setEnabled(false);
return;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
task.putData("dbName", database);
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
Aggregations