Search in sources :

Example 91 with DbUser

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

the class AdElementListModel method addUsersToModel.

protected void addUsersToModel(QueryReturnValue returnValue, Set<String> excludeUsers) {
    for (Queryable item : (List<Queryable>) returnValue.getReturnValue()) {
        DirectoryUser a = (DirectoryUser) item;
        if (!excludeUsers.contains(a.getId())) {
            EntityModel<DbUser> tempVar2 = new EntityModel<>();
            tempVar2.setEntity(new DbUser(a));
            getusers().add(tempVar2);
        }
    }
}
Also used : DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) Queryable(org.ovirt.engine.core.common.businessentities.Queryable) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) List(java.util.List) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 92 with DbUser

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

the class UserListModel method postOnAssignTags.

@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> userIds = new ArrayList<>();
    ArrayList<Guid> grpIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        DbUser user = (DbUser) item;
        if (user.isGroup()) {
            grpIds.add(user.getId());
        } else {
            userIds.add(user.getId());
        }
    }
    // prepare attach/detach lists
    ArrayList<Guid> tagsToAttach = new ArrayList<>();
    ArrayList<Guid> tagsToDetach = new ArrayList<>();
    if (model.getItems() != null && model.getItems().size() > 0) {
        ArrayList<TagModel> tags = (ArrayList<TagModel>) model.getItems();
        TagModel rootTag = tags.get(0);
        TagModel.recursiveEditAttachDetachLists(rootTag, attachedTags, tagsToAttach, tagsToDetach);
    }
    ArrayList<ActionParametersBase> usersToAttach = new ArrayList<>();
    ArrayList<ActionParametersBase> grpsToAttach = new ArrayList<>();
    for (Guid tag_id : tagsToAttach) {
        if (userIds.size() > 0) {
            usersToAttach.add(new AttachEntityToTagParameters(tag_id, userIds));
        }
        if (grpIds.size() > 0) {
            grpsToAttach.add(new AttachEntityToTagParameters(tag_id, grpIds));
        }
    }
    if (usersToAttach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.AttachUserToTag, usersToAttach);
    }
    if (grpsToAttach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.AttachUserGroupToTag, grpsToAttach);
    }
    ArrayList<ActionParametersBase> usersToDetach = new ArrayList<>();
    ArrayList<ActionParametersBase> grpsToDetach = new ArrayList<>();
    for (Guid tag_id : tagsToDetach) {
        if (userIds.size() > 0) {
            usersToDetach.add(new AttachEntityToTagParameters(tag_id, userIds));
        }
        if (grpIds.size() > 0) {
            grpsToDetach.add(new AttachEntityToTagParameters(tag_id, grpIds));
        }
    }
    if (usersToDetach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.DetachUserFromTag, usersToDetach);
    }
    if (grpsToDetach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.DetachUserGroupFromTag, grpsToDetach);
    }
    cancel();
}
Also used : ArrayList(java.util.ArrayList) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Guid(org.ovirt.engine.core.compat.Guid) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 93 with DbUser

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

the class UserPermissionListModel method onAddRoleToUser.

private void onAddRoleToUser() {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    List<Role> roles = model.getRole().getSelectedItems();
    // adGroup/user
    DbUser user = getEntity();
    List<ActionParametersBase> permissionParamsList = new ArrayList<>();
    roles.forEach(role -> {
        PermissionsOperationsParameters permissionParams = new PermissionsOperationsParameters();
        Permission perm = new Permission(user.getId(), role.getId(), null, null);
        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());
            permissionParams.setPermission(perm);
            permissionParams.setGroup(group);
        } else {
            permissionParams.setPermission(perm);
            permissionParams.setUser(user);
        }
        permissionParamsList.add(permissionParams);
    });
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.AddSystemPermission, permissionParamsList, 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) Permission(org.ovirt.engine.core.common.businessentities.Permission) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 94 with DbUser

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

the class SetVmTicketCommandTest method testNullConsoleUserNameWhenNoUserSet.

/**
 * Check that the constructed consule user name is {@code null} when the
 * user doesn't have a name.
 */
@Test
public void testNullConsoleUserNameWhenNoUserSet() {
    DbUser user = new DbUser();
    command.setCurrentUser(user);
    assertNull(command.getConsoleUserName());
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Example 95 with DbUser

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

the class SetVmTicketCommandTest method testLoginNameAtDirectoryWhenDirectorySet.

/**
 * Check that when the has a name and a directory name the console user name
 * is the user name followed by {@code @} and the directory name.
 */
@Test
public void testLoginNameAtDirectoryWhenDirectorySet() {
    DbUser user = new DbUser();
    user.setLoginName("Legolas");
    user.setDomain("MiddleEarth.com");
    command.setCurrentUser(user);
    assertEquals("Legolas@MiddleEarth.com", command.getConsoleUserName());
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Aggregations

DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)109 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)18 Guid (org.ovirt.engine.core.compat.Guid)18 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)13 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)10 HashSet (java.util.HashSet)9 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)9 HashMap (java.util.HashMap)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 Collection (java.util.Collection)7 Before (org.junit.Before)7 Permission (org.ovirt.engine.core.common.businessentities.Permission)7 List (java.util.List)5 Map (java.util.Map)5 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)5 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)5