Search in sources :

Example 6 with Permission

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

the class SystemPermissionView method initTable.

private void initTable(SystemPermissionActionPanelPresenterWidget actionPanel) {
    table.enableColumnResizing();
    // $NON-NLS-1$
    table.addColumn(new PermissionTypeColumn(), constants.empty(), "30px");
    AbstractTextColumn<Permission> userColumn = new AbstractTextColumn<Permission>() {

        @Override
        public String getValue(Permission object) {
            return object.getOwnerName();
        }
    };
    userColumn.makeSortable((u1, u2) -> u1.getOwnerName().compareTo(u2.getObjectName()));
    // $NON-NLS-1$
    table.addColumn(userColumn, constants.userPermission(), "270px");
    AbstractTextColumn<Permission> authzColumn = new AbstractTextColumn<Permission>() {

        @Override
        public String getValue(Permission object) {
            return object.getAuthz();
        }
    };
    authzColumn.makeSortable((a1, a2) -> a1.getAuthz().compareTo(a2.getAuthz()));
    // $NON-NLS-1$
    table.addColumn(authzColumn, constants.authz(), "180px");
    AbstractTextColumn<Permission> namespaceColumn = new AbstractTextColumn<Permission>() {

        @Override
        public String getValue(Permission object) {
            return object.getNamespace();
        }
    };
    namespaceColumn.makeSortable((ns1, ns2) -> ns1.getNamespace().compareTo(ns1.getNamespace()));
    // $NON-NLS-1$
    table.addColumn(namespaceColumn, constants.namespace(), "170px");
    AbstractTextColumn<Permission> roleColumn = new AbstractTextColumn<Permission>() {

        @Override
        public String getValue(Permission object) {
            return object.getRoleName();
        }
    };
    roleColumn.makeSortable((r1, r2) -> r1.getRoleName().compareTo(r2.getRoleName()));
    // $NON-NLS-1$
    table.addColumn(roleColumn, constants.rolePermission(), "110px");
    table.getSelectionModel().addSelectionChangeHandler(event -> modelProvider.setSelectedItems(table.getSelectionModel().getSelectedObjects()));
    tablePanel.add(actionPanel);
    tablePanel.add(table);
    table.table.setHeight(360 + Unit.PX.getType());
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) PermissionTypeColumn(org.ovirt.engine.ui.common.widget.table.column.PermissionTypeColumn)

Example 7 with Permission

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

the class AddVmCommand method addDiskPermissions.

private void addDiskPermissions() {
    List<Guid> newDiskImageIds = new ArrayList<>(srcDiskIdToTargetDiskIdMapping.values());
    Permission[] permsArray = new Permission[newDiskImageIds.size()];
    for (int i = 0; i < newDiskImageIds.size(); i++) {
        permsArray[i] = new Permission(getUserIdOfDiskOperator(), PredefinedRoles.DISK_OPERATOR.getId(), newDiskImageIds.get(i), VdcObjectType.Disk);
    }
    multiLevelAdministrationHandler.addPermission(permsArray);
}
Also used : ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with Permission

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

the class AddVmCommand method copyTemplatePermissions.

private void copyTemplatePermissions(UniquePermissionsSet permissionsToAdd) {
    List<Permission> templatePermissions = permissionDao.getAllForEntity(getVmTemplateId(), getEngineSessionSeqId(), false);
    for (Permission templatePermission : templatePermissions) {
        boolean templateOwnerRole = templatePermission.getRoleId().equals(PredefinedRoles.TEMPLATE_OWNER.getId());
        boolean templateUserRole = templatePermission.getRoleId().equals(PredefinedRoles.TEMPLATE_USER.getId());
        if (templateOwnerRole || templateUserRole) {
            continue;
        }
        permissionsToAdd.addPermission(templatePermission.getAdElementId(), templatePermission.getRoleId(), getVmId(), VdcObjectType.VM);
    }
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission)

Example 9 with Permission

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

the class ImportVmCommandBase method addVmPermission.

private void addVmPermission() {
    UniquePermissionsSet permissionsToAdd = new UniquePermissionsSet();
    if (isMakeCreatorExplicitOwner()) {
        permissionsToAdd.addPermission(getCurrentUser().getId(), PredefinedRoles.VM_OPERATOR.getId(), getVmId(), VdcObjectType.VM);
    }
    if (!permissionsToAdd.isEmpty()) {
        List<Permission> permissionsList = permissionsToAdd.asPermissionList();
        multiLevelAdministrationHandler.addPermission(permissionsList.toArray(new Permission[permissionsList.size()]));
        getCompensationContext().snapshotNewEntities(permissionsList);
    }
}
Also used : UniquePermissionsSet(org.ovirt.engine.core.bll.UniquePermissionsSet) Permission(org.ovirt.engine.core.common.businessentities.Permission)

Example 10 with Permission

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

the class AddCpuProfileCommand method createPermissionParameters.

private PermissionsOperationsParameters createPermissionParameters(Guid userId, Guid roleId) {
    Permission permission = new Permission(userId, roleId, getProfileId(), VdcObjectType.CpuProfile);
    permission.setObjectName(getParameters().getProfile().getName());
    if (MultiLevelAdministrationHandler.EVERYONE_OBJECT_ID.equals(userId)) {
        permission.setAuthz("N/A");
    }
    PermissionsOperationsParameters permissionsOperationsParameters = new PermissionsOperationsParameters(permission);
    permissionsOperationsParameters.setParametersCurrentUser(getCurrentUser());
    permissionsOperationsParameters.setSessionId(getContext().getEngineContext().getSessionId());
    return permissionsOperationsParameters;
}
Also used : PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) Permission(org.ovirt.engine.core.common.businessentities.Permission)

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