use of org.ovirt.engine.core.common.businessentities.aaa.DbUser 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.aaa.DbUser 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.aaa.DbUser in project ovirt-engine by oVirt.
the class CommandBaseTest method testConstructor.
/**
* Testing the constructor, which adds the user id to the thread local container
*/
@Test
public void testConstructor() {
DbUser user = mock(DbUser.class);
when(user.getId()).thenReturn(Guid.EVERYONE);
// Mock the session
sessionDataContainer.setUser(session, user);
// Create a command
command.postConstruct();
// Check the session
assertEquals("wrong user id on command", user.getId(), command.getUserId());
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class CommandBaseTest method setupEnvironment.
@Before
public void setupEnvironment() {
CorrelationIdTracker.clean();
DbUser user = mock(DbUser.class);
when(engineSessionDao.remove(anyLong())).thenReturn(1);
sessionDataContainer.setUser(session, user);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class BackendAssignedPermissionsResource method map.
/**
* injects user/group base on permission owner type
* @param entity the permission to map
* @param user the permission owner
* @return permission
*/
public Permission map(org.ovirt.engine.core.common.businessentities.Permission entity, DbUser user) {
Permission template = new Permission();
if (entity.getAdElementId() != null) {
if (isUser(user)) {
template.setUser(new User());
template.getUser().setId(entity.getAdElementId().toString());
} else {
template.setGroup(new Group());
template.getGroup().setId(entity.getAdElementId().toString());
}
}
return map(entity, template);
}
Aggregations