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;
}
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();
}
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));
}
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;
}
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);
}
Aggregations