use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class PermissionDaoTest method assertGetAllForEntityResult.
/**
* Ensures a call to {@link PermissionDao#getAllForEntity(Guid)} works properly
*/
private static void assertGetAllForEntityResult(List<Permission> result) {
assertNotNull(result);
assertFalse(result.isEmpty());
for (Permission permission : result) {
assertEquals(VM_ENTITY_ID, permission.getObjectId());
}
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class UserPermissionListModel method onAddRoleToUser.
private void onAddRoleToUser() {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
List<Role> roles = model.getRole().getSelectedItems();
// adGroup/user
DbUser user = getEntity();
List<ActionParametersBase> permissionParamsList = new ArrayList<>();
roles.forEach(role -> {
PermissionsOperationsParameters permissionParams = new PermissionsOperationsParameters();
Permission perm = new Permission(user.getId(), role.getId(), null, null);
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());
permissionParams.setPermission(perm);
permissionParams.setGroup(group);
} else {
permissionParams.setPermission(perm);
permissionParams.setUser(user);
}
permissionParamsList.add(permissionParams);
});
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.AddSystemPermission, permissionParamsList, 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 GetPermissionsByAdElementIdQueryTest method testQueryExecution.
@Test
public void testQueryExecution() {
// Prepare the query parameters
Guid adElementGuid = Guid.newGuid();
when(getQueryParameters().getId()).thenReturn(adElementGuid);
// Create expected result
Permission expected = new Permission();
expected.setAdElementId(adElementGuid);
// Mock the Daos
when(permissionDaoMock.getAllForAdElement(adElementGuid, getQuery().getEngineSessionSeqId(), getQueryParameters().isFiltered())).thenReturn(Collections.singletonList(expected));
getQuery().executeQueryCommand();
// Assert the query's results
@SuppressWarnings("unchecked") List<Permission> actual = getQuery().getQueryReturnValue().getReturnValue();
assertEquals("Wrong number of returned permissions", 1, actual.size());
assertEquals("Wrong returned permissions", expected, actual.get(0));
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class GetPermissionsToConsumeQuotaByQuotaIdQueryTest method mockDaoForQuery.
/**
* Initialize Dao to be used in query.
*/
private void mockDaoForQuery() {
returnedPermissions = new ArrayList<>();
Permission permissions = new Permission();
returnedPermissions.add(permissions);
when(getQueryParameters().getId()).thenReturn(quotaId);
when(permissionDao.getConsumedPermissionsForQuotaId(quotaId)).thenReturn(returnedPermissions);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class GetPermissionsForObjectQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
Guid objectId = getParameters().getObjectId();
List<Permission> perms;
if (getParameters().getDirectOnly()) {
perms = dao.getAllForEntity(objectId, getEngineSessionSeqId(), getParameters().isFiltered(), getParameters().getAllUsersWithPermission());
} else {
perms = dao.getTreeForEntity(objectId, getParameters().getVdcObjectType(), getEngineSessionSeqId(), getParameters().isFiltered());
}
getQueryReturnValue().setReturnValue(perms);
}
Aggregations