use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class HostListModel method updateConfigureLocalStorageCommandAvailability.
public void updateConfigureLocalStorageCommandAvailability() {
if (hasAdminSystemPermission == null) {
DbUser dbUser = Frontend.getInstance().getLoggedInUser();
if (dbUser == null) {
hasAdminSystemPermission = false;
updateConfigureLocalStorageCommandAvailability1();
return;
}
Frontend.getInstance().runQuery(QueryType.GetPermissionsByAdElementId, new IdQueryParameters(dbUser.getId()), new AsyncQuery<QueryReturnValue>(response -> {
if (response == null || !response.getSucceeded()) {
hasAdminSystemPermission = false;
updateConfigureLocalStorageCommandAvailability1();
} else {
ArrayList<Permission> permissions = response.getReturnValue();
for (Permission permission : permissions) {
if (permission.getObjectType() == VdcObjectType.System && permission.getRoleType() == RoleType.ADMIN) {
hasAdminSystemPermission = true;
break;
}
}
updateConfigureLocalStorageCommandAvailability1();
}
}, true));
} else {
updateConfigureLocalStorageCommandAvailability1();
}
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class DbUserDaoTest method testUpdateLastAdminCheckStatus.
@Test
public void testUpdateLastAdminCheckStatus() {
// Getting a nonAdmin user that is defined in the fixtures
DbUser nonAdminUser = dbFacade.getDbUserDao().getByUsernameAndDomain("userportal2@testportal.redhat.com", "testportal.redhat.com");
assertNotNull(nonAdminUser);
assertFalse(nonAdminUser.isAdmin());
// execute and validate when not admin
dao.updateLastAdminCheckStatus(nonAdminUser.getId());
nonAdminUser = dbFacade.getDbUserDao().get(nonAdminUser.getId());
assertFalse(nonAdminUser.isAdmin());
Permission perms = new Permission();
perms.setRoleType(RoleType.ADMIN);
// An available role from the fixtures
perms.setRoleId(ADMIN_ROLE_TYPE_FROM_FIXTURE_ID);
perms.setAdElementId(nonAdminUser.getId());
perms.setObjectId(SYSTEM_OBJECT_ID);
perms.setObjectType(VdcObjectType.System);
// Save the permission to the DB and make sure it has been saved
dbFacade.getPermissionDao().save(perms);
assertNotNull(dbFacade.getPermissionDao().get(perms.getId()));
// execute and validate when admin
dao.updateLastAdminCheckStatus(nonAdminUser.getId());
nonAdminUser = dbFacade.getDbUserDao().get(nonAdminUser.getId());
assertTrue(nonAdminUser.isAdmin());
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class PermissionListModel method onAdd.
private void onAdd() {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (model.getSearchType() != AdSearchType.EVERYONE && model.getSelectedItems() == null) {
cancel();
return;
}
ArrayList<DbUser> items = new ArrayList<>();
if (model.getSearchType() == AdSearchType.EVERYONE) {
DbUser tempVar = new DbUser();
tempVar.setId(ApplicationGuids.everyone.asGuid());
items.add(tempVar);
} else {
for (Object item : model.getItems()) {
EntityModel entityModel = (EntityModel) item;
if (entityModel.getIsSelected()) {
items.add((DbUser) entityModel.getEntity());
}
}
}
Role role = model.getRole().getSelectedItem();
// adGroup/user
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (DbUser user : items) {
Permission perm = new Permission(user.getId(), role.getId(), getEntityGuid(), getObjectType());
if (user.isGroup()) {
DbGroup group = new DbGroup();
group.setId(user.getId());
group.setExternalId(user.getExternalId());
group.setName(user.getFirstName());
group.setDomain(user.getDomain());
group.setNamespace(user.getNamespace());
PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
tempVar3.setPermission(perm);
tempVar3.setGroup(group);
list.add(tempVar3);
} else {
PermissionsOperationsParameters tempVar4 = new PermissionsOperationsParameters();
tempVar4.setPermission(perm);
tempVar4.setUser(user);
list.add(tempVar4);
}
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.AddPermission, list, result -> {
AdElementListModel localModel = (AdElementListModel) result.getState();
localModel.stopProgress();
cancel();
}, model);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class SystemPermissionListModel method onAttach.
private void onAttach() {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (model.getSelectedItems() == null) {
cancel();
return;
}
ArrayList<DbUser> items = new ArrayList<>();
for (Object item : model.getItems()) {
EntityModel entityModel = (EntityModel) item;
if (entityModel.getIsSelected()) {
items.add((DbUser) entityModel.getEntity());
}
}
Role role = model.getRole().getSelectedItem();
ArrayList<ActionParametersBase> list = new ArrayList<>();
for (DbUser user : items) {
Permission perm = new Permission(user.getId(), role.getId(), null, null);
if (user.isGroup()) {
DbGroup group = new DbGroup();
group.setId(user.getId());
group.setName(user.getFirstName());
group.setDomain(user.getDomain());
group.setExternalId(user.getExternalId());
group.setNamespace(user.getNamespace());
PermissionsOperationsParameters tempVar2 = new PermissionsOperationsParameters();
tempVar2.setPermission(perm);
tempVar2.setGroup(group);
list.add(tempVar2);
} else {
PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
tempVar3.setPermission(perm);
tempVar3.setUser(user);
list.add(tempVar3);
}
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.AddSystemPermission, list, result -> {
AdElementListModel localModel = (AdElementListModel) result.getState();
localModel.stopProgress();
cancel();
}, model);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class RolePermissionsRemoveConfirmationPopupView method addItemText.
@Override
protected void addItemText(Object item) {
// We assume that the objects passed in are of type permissions.
Permission permissions = (Permission) item;
addItemLabel(messages.roleOnUser(permissions.getRoleName(), permissions.getOwnerName()));
}
Aggregations