use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class QuotaPermissionListModel method syncSearch.
@Override
protected void syncSearch() {
GetPermissionsForObjectParameters tempVar = new GetPermissionsForObjectParameters();
tempVar.setObjectId(getEntityGuid());
tempVar.setVdcObjectType(getObjectType());
tempVar.setDirectOnly(false);
tempVar.setRefresh(getIsQueryFirstTime());
tempVar.setRefresh(getIsQueryFirstTime());
Frontend.getInstance().runQuery(QueryType.GetPermissionsForObject, tempVar, new AsyncQuery<QueryReturnValue>(returnValue -> {
ArrayList<Permission> list = returnValue.getReturnValue();
ArrayList<Permission> newList = new ArrayList<>();
for (Permission permission : list) {
if (!permission.getRoleId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
newList.add(permission);
}
}
setItems(newList);
}));
setIsQueryFirstTime(false);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class QuotaUserListModel method onAdd.
public void onAdd() {
AdElementListModel model = (AdElementListModel) getWindow();
if (model.getProgress() != null) {
return;
}
if (model.getSelectedItems() == null && model.getSearchType() != AdSearchType.EVERYONE) {
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());
}
}
}
model.startProgress();
ArrayList<ActionParametersBase> list = new ArrayList<>();
PermissionsOperationsParameters permissionParams;
for (DbUser user : items) {
Permission perm = new Permission(user.getId(), ApplicationGuids.quotaConsumer.asGuid(), getEntity().getId(), VdcObjectType.Quota);
permissionParams = new PermissionsOperationsParameters();
if (user.isGroup()) {
DbGroup group = new DbGroup();
group.setId(user.getId());
group.setExternalId(user.getExternalId());
group.setName(user.getFirstName());
group.setDomain(user.getDomain());
permissionParams.setGroup(group);
} else {
permissionParams.setUser(user);
}
permissionParams.setPermission(perm);
list.add(permissionParams);
}
Frontend.getInstance().runMultipleAction(ActionType.AddPermission, list, result -> {
QuotaUserListModel localModel = (QuotaUserListModel) result.getState();
localModel.stopProgress();
cancel();
}, model);
cancel();
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class PermissionDaoTest method testGet.
/**
* Ensures that the right permission is retrieved.
*/
@Test
public void testGet() {
Permission result = dao.get(EXISTING_PERMISSION_ID);
assertNotNull(result);
assertEquals(EXISTING_PERMISSION_ID, result.getId());
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class PermissionDaoTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
dao = dbFacade.getPermissionDao();
new_permissions = new Permission(AD_ELEMENT_ID, ROLE_ID, FixturesTool.DATA_CENTER, VdcObjectType.StoragePool);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class PermissionDaoTest method testGetAllForRoleAndAdElementAndObject.
/**
* Ensures that a null object is returned when the role is invalid.
*/
@Test
public void testGetAllForRoleAndAdElementAndObject() {
Permission result = dao.getForRoleAndAdElementAndObject(ROLE_ID, AD_ELEMENT_ID, VM_ENTITY_ID);
assertNotNull(result);
assertEquals(ROLE_ID, result.getRoleId());
assertEquals(AD_ELEMENT_ID, result.getAdElementId());
assertEquals(VM_ENTITY_ID, result.getObjectId());
}
Aggregations