Search in sources :

Example 11 with Permission

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

the class GetPermissionsForObjectQueryTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    objectID = Guid.newGuid();
    Permission permission = new Permission();
    permission.setObjectId(objectID);
    mockedPermissions = Collections.singletonList(permission);
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Before(org.junit.Before)

Example 12 with Permission

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

the class UserPermissionListModel method syncSearch.

@Override
protected void syncSearch() {
    if (getEntity() == null) {
        return;
    }
    IdQueryParameters mlaParams = new IdQueryParameters(getEntity().getId());
    mlaParams.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetPermissionsOnBehalfByAdElementId, mlaParams, new AsyncQuery<>((AsyncCallback<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 : IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) AsyncCallback(org.ovirt.engine.ui.frontend.AsyncCallback) Permission(org.ovirt.engine.core.common.businessentities.Permission) ArrayList(java.util.ArrayList)

Example 13 with Permission

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

the class UserPermissionListModel method updateActionAvailability.

private void updateActionAvailability() {
    boolean isInherited = false;
    Permission p = getSelectedItem();
    if (p != null && getEntity() != null) {
        isInherited = !p.getAdElementId().equals(getEntity().getId());
    }
    getRemoveCommand().setIsExecutionAllowed(!isInherited && (getSelectedItem() != null || (getSelectedItems() != null && getSelectedItems().size() > 0)));
    // User Permission uses the same action panel as all the permission models, but you can't
    // add, so we need to hide the add button.
    getAddCommand().setIsAvailable(false);
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission)

Example 14 with Permission

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

the class UserModule method getPermissionListProvider.

@Provides
@Singleton
public SearchableDetailModelProvider<Permission, UserListModel, UserPermissionListModel> getPermissionListProvider(EventBus eventBus, Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<UserRolesPopupPresenterWidget> popupProvider, final Provider<RolePermissionsRemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, final Provider<UserListModel> mainModelProvider, final Provider<UserPermissionListModel> modelProvider) {
    SearchableDetailTabModelProvider<Permission, UserListModel, UserPermissionListModel> result = new SearchableDetailTabModelProvider<Permission, UserListModel, UserPermissionListModel>(eventBus, defaultConfirmPopupProvider) {

        @Override
        public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(UserPermissionListModel source, UICommand lastExecutedCommand, Model windowModel) {
            UserPermissionListModel model = getModel();
            if (lastExecutedCommand == model.getAddRoleToUserCommand()) {
                return popupProvider.get();
            } else {
                return super.getModelPopup(source, lastExecutedCommand, windowModel);
            }
        }

        @Override
        public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(UserPermissionListModel source, UICommand lastExecutedCommand) {
            if (lastExecutedCommand == getModel().getRemoveCommand()) {
                return removeConfirmPopupProvider.get();
            } else {
                return super.getConfirmModelPopup(source, lastExecutedCommand);
            }
        }
    };
    result.setMainModelProvider(mainModelProvider);
    result.setModelProvider(modelProvider);
    return result;
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) UserPermissionListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserPermissionListModel) UserGeneralModel(org.ovirt.engine.ui.uicommonweb.models.users.UserGeneralModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) UserQuotaListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserQuotaListModel) UserListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserListModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) UserEventNotifierListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserEventNotifierListModel) UserEventListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserEventListModel) UserGroupListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserGroupListModel) UserListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserListModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UserPermissionListModel(org.ovirt.engine.ui.uicommonweb.models.users.UserPermissionListModel) SearchableDetailTabModelProvider(org.ovirt.engine.ui.common.uicommon.model.SearchableDetailTabModelProvider) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 15 with Permission

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

the class SubTabQuotaUserView method initTable.

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

        @Override
        public String getValue(Permission object) {
            return object.getOwnerName();
        }
    };
    userColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(userColumn, constants.userUser(), "400px");
    AbstractTextColumn<Permission> permissionColumn = new AbstractObjectNameColumn<Permission>() {

        @Override
        protected Object[] getRawValue(Permission object) {
            return new Object[] { object.getObjectType(), object.getObjectName(), getDetailModel().getEntity(), object.getObjectId() };
        }
    };
    permissionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(permissionColumn, constants.inheritedFromUser(), "400px");
}
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) AbstractObjectNameColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractObjectNameColumn)

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