Search in sources :

Example 36 with Permission

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);
}
Also used : AdElementListModel(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel) QueryType(org.ovirt.engine.core.common.queries.QueryType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Inject(com.google.inject.Inject) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) Quota(org.ovirt.engine.core.common.businessentities.Quota) GetPermissionsForObjectParameters(org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) Provider(com.google.inject.Provider) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Permission(org.ovirt.engine.core.common.businessentities.Permission) ApplicationGuids(org.ovirt.engine.ui.uicommonweb.auth.ApplicationGuids) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission) GetPermissionsForObjectParameters(org.ovirt.engine.core.common.queries.GetPermissionsForObjectParameters)

Example 37 with Permission

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();
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Permission(org.ovirt.engine.core.common.businessentities.Permission) AdElementListModel(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 38 with Permission

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());
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Test(org.junit.Test)

Example 39 with Permission

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);
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission)

Example 40 with Permission

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());
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Test(org.junit.Test)

Aggregations

Permission (org.ovirt.engine.core.common.businessentities.Permission)59 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)12 Guid (org.ovirt.engine.core.compat.Guid)12 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)9 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)8 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)6 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)5 AdElementListModel (org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel)5 Role (org.ovirt.engine.core.common.businessentities.Role)4 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)3 PermissionTypeColumn (org.ovirt.engine.ui.common.widget.table.column.PermissionTypeColumn)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)3 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)3 Inject (com.google.inject.Inject)2