Search in sources :

Example 6 with PermissionsOperationsParameters

use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.

the class UserPermissionListModel method onRemove.

private void onRemove() {
    if (getSelectedItems() != null && getSelectedItems().size() > 0) {
        ConfirmationModel model = (ConfirmationModel) getWindow();
        if (model.getProgress() != null) {
            return;
        }
        ArrayList<ActionParametersBase> list = new ArrayList<>();
        for (Object perm : getSelectedItems()) {
            PermissionsOperationsParameters tempVar = new PermissionsOperationsParameters();
            tempVar.setPermission((Permission) perm);
            list.add(tempVar);
        }
        model.startProgress();
        Frontend.getInstance().runMultipleAction(ActionType.RemovePermission, list, result -> {
            ConfirmationModel localModel = (ConfirmationModel) result.getState();
            localModel.stopProgress();
            cancel();
        }, model);
    } else {
        cancel();
    }
}
Also used : PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 7 with PermissionsOperationsParameters

use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.

the class RemoveUserCommand method executeCommand.

@Override
protected void executeCommand() {
    // Get the identifier of the user to be removed from the parameters:
    Guid id = getParameters().getId();
    // TODO: This should be done without invoking the command to avoid the overhead.
    for (Permission permission : permissionDao.getAllDirectPermissionsForAdElement(id)) {
        PermissionsOperationsParameters tempVar = new PermissionsOperationsParameters(permission);
        tempVar.setShouldBeLogged(false);
        runInternalActionWithTasksContext(ActionType.RemovePermission, tempVar);
    }
    // Delete the user itself:
    dbUserDao.remove(id);
    setSucceeded(true);
}
Also used : PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) Permission(org.ovirt.engine.core.common.businessentities.Permission) Guid(org.ovirt.engine.core.compat.Guid)

Example 8 with PermissionsOperationsParameters

use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.

the class PermissionListModel method onAdd.

private void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSearchType() != AdSearchType.EVERYONE && model.getSelectedItems() == null) {
        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());
            }
        }
    }
    Role role = model.getRole().getSelectedItem();
    // adGroup/user
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (DbUser user : items) {
        Permission perm = new Permission(user.getId(), role.getId(), getEntityGuid(), getObjectType());
        if (user.isGroup()) {
            DbGroup group = new DbGroup();
            group.setId(user.getId());
            group.setExternalId(user.getExternalId());
            group.setName(user.getFirstName());
            group.setDomain(user.getDomain());
            group.setNamespace(user.getNamespace());
            PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
            tempVar3.setPermission(perm);
            tempVar3.setGroup(group);
            list.add(tempVar3);
        } else {
            PermissionsOperationsParameters tempVar4 = new PermissionsOperationsParameters();
            tempVar4.setPermission(perm);
            tempVar4.setUser(user);
            list.add(tempVar4);
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.AddPermission, list, result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) 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 9 with PermissionsOperationsParameters

use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.

the class SystemPermissionListModel method onAttach.

private void onAttach() {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSelectedItems() == null) {
        cancel();
        return;
    }
    ArrayList<DbUser> items = new ArrayList<>();
    for (Object item : model.getItems()) {
        EntityModel entityModel = (EntityModel) item;
        if (entityModel.getIsSelected()) {
            items.add((DbUser) entityModel.getEntity());
        }
    }
    Role role = model.getRole().getSelectedItem();
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (DbUser user : items) {
        Permission perm = new Permission(user.getId(), role.getId(), null, null);
        if (user.isGroup()) {
            DbGroup group = new DbGroup();
            group.setId(user.getId());
            group.setName(user.getFirstName());
            group.setDomain(user.getDomain());
            group.setExternalId(user.getExternalId());
            group.setNamespace(user.getNamespace());
            PermissionsOperationsParameters tempVar2 = new PermissionsOperationsParameters();
            tempVar2.setPermission(perm);
            tempVar2.setGroup(group);
            list.add(tempVar2);
        } else {
            PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
            tempVar3.setPermission(perm);
            tempVar3.setUser(user);
            list.add(tempVar3);
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.AddSystemPermission, list, result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) 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 10 with PermissionsOperationsParameters

use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.

the class RolePermissionListModel method onRemove.

private void onRemove() {
    if (getSelectedItems() != null && getSelectedItems().size() > 0) {
        ConfirmationModel model = (ConfirmationModel) getWindow();
        if (model.getProgress() != null) {
            return;
        }
        ArrayList<ActionParametersBase> list = new ArrayList<>();
        for (Object perm : getSelectedItems()) {
            PermissionsOperationsParameters tempVar = new PermissionsOperationsParameters();
            tempVar.setPermission((Permission) perm);
            list.add(tempVar);
        }
        model.startProgress();
        Frontend.getInstance().runMultipleAction(ActionType.RemovePermission, list, result -> {
            ConfirmationModel localModel = (ConfirmationModel) result.getState();
            localModel.stopProgress();
            cancel();
        }, model);
    }
}
Also used : PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) ArrayList(java.util.ArrayList) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Aggregations

PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)16 ArrayList (java.util.ArrayList)9 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)9 Permission (org.ovirt.engine.core.common.businessentities.Permission)8 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)5 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 Role (org.ovirt.engine.core.common.businessentities.Role)3 Guid (org.ovirt.engine.core.compat.Guid)3 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)3 AdElementListModel (org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel)3