use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class RemoveGroupCommand method executeCommand.
@Override
protected void executeCommand() {
// Get the identifier of the group from the parameters:
Guid id = getParameters().getId();
// TODO: This should be done without invoking the command to avoid the overhead.
for (Permission permission : permissionDao.getAllDirectPermissionsForAdElement(id)) {
PermissionsOperationsParameters param = new PermissionsOperationsParameters(permission);
param.setSessionId(getParameters().getSessionId());
runInternalActionWithTasksContext(ActionType.RemovePermission, param);
}
// Remove the group itself:
dbGroupDao.remove(id);
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class MultiLevelAdministrationHandler method isLastSuperUserGroup.
/**
* Checks if supplied group is the last (or maybe only) with super user privileges.
*
* @param groupId
* the group is
* @return true if group is the last with Super User privileges, otherwise, false
*/
public boolean isLastSuperUserGroup(Guid groupId) {
boolean retValue = false;
// check that there is at least one super-user left in the system
List<Permission> permissions = permissionDao.getAllForRole(PredefinedRoles.SUPER_USER.getId());
if (permissions.size() <= 1) {
// get group role
permissions = permissionDao.getAllForAdElement(groupId);
for (Permission permission : permissions) {
if (permission.getRoleId().equals(PredefinedRoles.SUPER_USER.getId())) {
retValue = true;
break;
}
}
}
return retValue;
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class RemovePermissionCommand method executeCommand.
@Override
protected void executeCommand() {
Permission perms = getParameters().getPermission();
Guid userId = perms.getAdElementId();
// check if vm is from pool and detach it
if (perms.getObjectType().equals(VdcObjectType.VM) && perms.getRoleId().equals(PredefinedRoles.ENGINE_USER.getId())) {
VM vm = vmDao.get(perms.getObjectId());
if (vm != null && vm.getVmPoolId() != null) {
runInternalActionWithTasksContext(ActionType.DetachUserFromVmFromPool, new DetachUserFromVmFromPoolParameters(vm.getVmPoolId(), userId, vm.getId(), true));
}
}
vmStaticDao.incrementDbGeneration(perms.getObjectId());
permissionDao.remove(perms.getId());
dbUserDao.updateLastAdminCheckStatus(userId);
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class PermissionsCommandBase method getPermissionCheckSubjects.
// TODO - this code is shared with addPermissionCommand - check if
// addPermission can extend this command
@Override
public List<PermissionSubject> getPermissionCheckSubjects() {
List<PermissionSubject> permissionList = new ArrayList<>();
Permission permission = getParameters().getPermission();
permissionList.add(new PermissionSubject(permission.getObjectId(), permission.getObjectType(), getActionType().getActionGroup()));
return permissionList;
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class AttachUserToVmFromPoolAndRunCommand method attachUserToVm.
private ActionReturnValue attachUserToVm() {
Permission perm = new Permission(getAdUserId(), PredefinedRoles.ENGINE_USER.getId(), getVmId(), VdcObjectType.VM);
PermissionsOperationsParameters permParams = new PermissionsOperationsParameters(perm);
permParams.setShouldBeLogged(false);
permParams.setParentCommand(getActionType());
permParams.setParentParameters(getParameters());
return runInternalAction(ActionType.AddPermission, permParams, cloneContext().withoutExecutionContext().withoutLock());
}
Aggregations