Search in sources :

Example 86 with DbUser

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

the class GetSessionUser method runQuery.

private boolean runQuery(HttpServletResponse response, String sessionID) {
    boolean returnValue = false;
    log.debug("Calling ValidateSession query");
    QueryReturnValue queryReturnValue = backend.runInternalQuery(QueryType.ValidateSession, new QueryParametersBase(sessionID));
    if (queryReturnValue != null) {
        returnValue = queryReturnValue.getSucceeded();
        if (returnValue) {
            DbUser user = queryReturnValue.getReturnValue();
            // We get the user name only in case the validation succeeded, and the user is an administrator
            if (user.isAdmin()) {
                log.debug("Getting user name");
                printUPNToResponse(response, getUPN(user));
            } else {
                log.error("User '{}' is not authorized to perform operation", user.getLoginName());
                returnValue = false;
            }
        }
    } else {
        log.error("Got NULL from backend.RunQuery");
    }
    return returnValue;
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 87 with DbUser

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

the class QuotaUserListModel method onAdd.

public void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSelectedItems() == null && model.getSearchType() != AdSearchType.EVERYONE) {
        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());
            }
        }
    }
    model.startProgress();
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    PermissionsOperationsParameters permissionParams;
    for (DbUser user : items) {
        Permission perm = new Permission(user.getId(), ApplicationGuids.quotaConsumer.asGuid(), getEntity().getId(), VdcObjectType.Quota);
        permissionParams = new PermissionsOperationsParameters();
        if (user.isGroup()) {
            DbGroup group = new DbGroup();
            group.setId(user.getId());
            group.setExternalId(user.getExternalId());
            group.setName(user.getFirstName());
            group.setDomain(user.getDomain());
            permissionParams.setGroup(group);
        } else {
            permissionParams.setUser(user);
        }
        permissionParams.setPermission(perm);
        list.add(permissionParams);
    }
    Frontend.getInstance().runMultipleAction(ActionType.AddPermission, list, result -> {
        QuotaUserListModel localModel = (QuotaUserListModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
    cancel();
}
Also used : 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 88 with DbUser

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

the class OvfHelper method buildMetadataDictionaryForVm.

/**
 * Adds the given vm metadata to the given map
 */
private String buildMetadataDictionaryForVm(VM vm) {
    List<DiskImage> allVmImages = new ArrayList<>();
    List<DiskImage> filteredDisks = DisksFilter.filterImageDisks(vm.getDiskList(), ONLY_SNAPABLE, ONLY_ACTIVE);
    List<LunDisk> lunDisks = DisksFilter.filterLunDisks(vm.getDiskMap().values());
    List<AffinityGroup> affinityGroups = affinityGroupDao.getAllAffinityGroupsByVmId(vm.getId());
    Set<DbUser> dbUsers = new HashSet<>(dbUserDao.getAllForVm(vm.getId()));
    List<Label> affinityLabels = labelDao.getAllByEntityIds(Collections.singletonList(vm.getId()));
    for (DiskImage diskImage : filteredDisks) {
        List<DiskImage> images = diskImageDao.getAllSnapshotsForLeaf(diskImage.getImageId());
        images.forEach(d -> d.setDiskVmElements(Collections.singletonList(diskImage.getDiskVmElementForVm(vm.getId()))));
        allVmImages.addAll(images);
    }
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(vm);
    fullEntityOvfData.setDiskImages(allVmImages);
    fullEntityOvfData.setLunDisks(lunDisks);
    fullEntityOvfData.setAffinityGroups(affinityGroups);
    fullEntityOvfData.setAffinityLabels(affinityLabels);
    fullEntityOvfData.setDbUsers(dbUsers);
    populateUserToRoles(fullEntityOvfData, vm.getId());
    return ovfManager.exportVm(vm, fullEntityOvfData, clusterUtils.getCompatibilityVersion(vm));
}
Also used : ArrayList(java.util.ArrayList) Label(org.ovirt.engine.core.common.businessentities.Label) FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Example 89 with DbUser

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

the class OvfUpdateProcessHelper method buildMetadataDictionaryForTemplate.

/**
 * Adds the given template metadata to the given map
 */
public String buildMetadataDictionaryForTemplate(VmTemplate template, Map<Guid, KeyValuePairCompat<String, List<Guid>>> metaDictionary) {
    List<DiskImage> allTemplateImages = template.getDiskList();
    Set<DbUser> dbUsers = new HashSet<>(dbUserDao.getAllForTemplate(template.getId()));
    FullEntityOvfData fullEntityOvfData = new FullEntityOvfData(template);
    fullEntityOvfData.setDbUsers(dbUsers);
    fullEntityOvfData.setDiskImages(allTemplateImages);
    ovfHelper.populateUserToRoles(fullEntityOvfData, template.getId());
    String templateMeta = generateVmTemplateMetadata(fullEntityOvfData);
    metaDictionary.put(template.getId(), new KeyValuePairCompat<>(templateMeta, allTemplateImages.stream().map(BaseDisk::getId).collect(Collectors.toList())));
    return templateMeta;
}
Also used : FullEntityOvfData(org.ovirt.engine.core.common.businessentities.storage.FullEntityOvfData) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) HashSet(java.util.HashSet)

Example 90 with DbUser

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

the class AdElementListModel method searchMyGroups.

public void searchMyGroups() {
    getSearchInProgress().setEntity(true);
    AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(queryReturnValue -> {
        if (handleQueryError(queryReturnValue)) {
            return;
        }
        HashSet<String> excludeUsers = new HashSet<>();
        if (getExcludeItems() != null) {
            for (DbUser item : getExcludeItems()) {
                excludeUsers.add(item.getExternalId());
            }
        }
        setgroups(new ArrayList<>());
        addGroupsToModel(queryReturnValue, excludeUsers);
        setusers(new ArrayList<>());
        onUserAndAdGroupsLoaded();
    });
    asyncQuery.setHandleFailure(true);
    Frontend.getInstance().runQuery(QueryType.GetDirectoryGroupsForUser, new QueryParametersBase(), asyncQuery);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) HashSet(java.util.HashSet) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

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