Search in sources :

Example 1 with Permission

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

the class PermissionListModel method updateActionAvailability.

private void updateActionAvailability() {
    getRemoveCommand().setIsExecutionAllowed(getSelectedItems() != null && getSelectedItems().size() > 0);
    if (!getRemoveCommand().getIsExecutionAllowed()) {
        return;
    }
    Guid entityGuid = getEntityGuid();
    for (Object p : getSelectedItems()) {
        if (!entityGuid.equals(((Permission) p).getObjectId())) {
            getRemoveCommand().setIsExecutionAllowed(false);
            return;
        }
    }
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with Permission

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

the class QuotaUserListModel method remove.

public void remove() {
    if (getWindow() != null) {
        return;
    }
    ConfirmationModel model = new ConfirmationModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().removeQuotaAssignmentFromUsersTitle());
    model.setHelpTag(HelpTag.remove_quota_assignment_from_user);
    // $NON-NLS-1$
    model.setHashName("remove_quota_assignment_from_user");
    ArrayList<String> list = new ArrayList<>();
    for (Permission item : getSelectedItems()) {
        list.add(item.getOwnerName());
    }
    model.setItems(list);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnRemove", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 3 with Permission

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

the class QuotaUserListModel method updateActionAvailability.

private void updateActionAvailability() {
    ArrayList<Permission> items = (getSelectedItems() != null) ? (ArrayList<Permission>) getSelectedItems() : new ArrayList<Permission>();
    boolean removeExe = false;
    if (items.size() > 0) {
        removeExe = true;
    }
    for (Permission perm : items) {
        if (!perm.getRoleId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
            removeExe = false;
            break;
        }
    }
    getRemoveCommand().setIsExecutionAllowed(removeExe);
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission)

Example 4 with Permission

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

the class QuotaUserListModel method syncSearch.

@Override
protected void syncSearch() {
    super.syncSearch();
    IdQueryParameters param = new IdQueryParameters(getEntity().getId());
    param.setRefresh(getIsQueryFirstTime());
    param.setRefresh(getIsQueryFirstTime());
    Frontend.getInstance().runQuery(QueryType.GetPermissionsToConsumeQuotaByQuotaId, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
        ArrayList<Permission> list = returnValue.getReturnValue();
        Map<Guid, Permission> map = new HashMap<>();
        for (Permission permission : list) {
            // filter out sys-admin and dc admin from consumers sub-tab
            if (permission.getRoleId().equals(ApplicationGuids.superUser.asGuid()) || permission.getRoleId().equals(ApplicationGuids.dataCenterAdmin.asGuid())) {
                continue;
            }
            if (!map.containsKey(permission.getAdElementId())) {
                map.put(permission.getAdElementId(), permission);
            } else {
                if (map.get(permission.getAdElementId()).getRoleId().equals(ApplicationGuids.quotaConsumer.asGuid())) {
                    map.put(permission.getAdElementId(), permission);
                }
            }
        }
        list.clear();
        for (Permission permission : map.values()) {
            list.add(permission);
        }
        setItems(list);
    }));
    setIsQueryFirstTime(false);
}
Also used : QueryType(org.ovirt.engine.core.common.queries.QueryType) Guid(org.ovirt.engine.core.compat.Guid) AdSearchType(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel.AdSearchType) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) HashMap(java.util.HashMap) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Frontend(org.ovirt.engine.ui.frontend.Frontend) PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) Map(java.util.Map) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) Permission(org.ovirt.engine.core.common.businessentities.Permission) ApplicationGuids(org.ovirt.engine.ui.uicommonweb.auth.ApplicationGuids) AdElementListModel(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) Quota(org.ovirt.engine.core.common.businessentities.Quota) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with Permission

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

the class SystemPermissionsRemoveConfirmationPopupView method addItemText.

@Override
protected void addItemText(Object item) {
    // We assume that the objects passed in are of type permissions.
    Permission permissions = (Permission) item;
    addItemLabel(messages.userWithRole(permissions.getOwnerName(), permissions.getRoleName()));
}
Also used : 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