Search in sources :

Example 26 with Permission

use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.

the class PermissionDaoTest method testGetAllForRoleAndAdElementAndObjectWithInvalidAdElement.

/**
 * Ensures that a null object is returned when the element is invalid.
 */
@Test
public void testGetAllForRoleAndAdElementAndObjectWithInvalidAdElement() {
    Permission result = dao.getForRoleAndAdElementAndObject(ROLE_ID, Guid.newGuid(), VM_ENTITY_ID);
    assertNull(result);
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Test(org.junit.Test)

Example 27 with Permission

use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.

the class PermissionDaoTest method assertGetTreeForEntityResult.

/**
 * asserts the result of a call to {@link PermissionDao#getTreeForEntity(Guid, VdcObjectType)}
 * @param entityID The object to retrieve tree for
 * @param alternativeObjectIds Additional object IDs that are allowed in the resulting permissions
 */
protected void assertGetTreeForEntityResult(Guid entityID, List<Permission> result, Guid... alternativeObjectIds) {
    Set<Guid> expectedObjectIds = new HashSet<>();
    expectedObjectIds.add(entityID);
    expectedObjectIds.addAll(Arrays.asList(alternativeObjectIds));
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (Permission permission : result) {
        assertTrue(expectedObjectIds.contains(permission.getObjectId()));
    }
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Guid(org.ovirt.engine.core.compat.Guid) HashSet(java.util.HashSet)

Example 28 with Permission

use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.

the class PermissionDaoTest method testGetAllForRoleAndAdElement.

/**
 * Ensures a collection is returned.
 */
@Test
public void testGetAllForRoleAndAdElement() {
    List<Permission> result = dao.getAllForRoleAndAdElement(ROLE_ID, AD_ELEMENT_ID);
    assertNotNull(result);
    assertFalse(result.isEmpty());
    for (Permission permission : result) {
        assertEquals(ROLE_ID, permission.getRoleId());
        assertEquals(AD_ELEMENT_ID, permission.getAdElementId());
    }
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Test(org.junit.Test)

Example 29 with Permission

use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.

the class AddDiskCommand method addDiskPermissions.

private void addDiskPermissions(Disk disk) {
    if (getCurrentUser() != null) {
        Permission perms = new Permission(getCurrentUser().getId(), PredefinedRoles.DISK_OPERATOR.getId(), disk.getId(), VdcObjectType.Disk);
        multiLevelAdministrationHandler.addPermission(perms);
    }
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission)

Example 30 with Permission

use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.

the class PermissionListModelTable method addCreationDateColum.

private void addCreationDateColum() {
    AbstractTextColumn<Permission> creationDateColumn = new AbstractRenderedTextColumn<Permission, Date>(new FullDateTimeRenderer()) {

        @Override
        public Date getRawValue(Permission object) {
            // GWT doesn't have TimeUnit.java
            return new Date(object.getCreationDate() * 1000);
        }
    };
    // $NON-NLS-1$
    getTable().addColumn(creationDateColumn, constants.permissionsCreationDate(), "300px");
    creationDateColumn.makeSortable();
}
Also used : AbstractRenderedTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractRenderedTextColumn) FullDateTimeRenderer(org.ovirt.engine.ui.common.widget.renderer.FullDateTimeRenderer) Permission(org.ovirt.engine.core.common.businessentities.Permission) Date(java.util.Date)

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