use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup 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);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendAssignedPermissionsResource method getPrincipal.
/**
* Find the user or group that the permissions applies to.
*
* @param permission the incoming permission model
* @return the user or group that the permission applies to
*/
private Object getPrincipal(Permission permission) {
if (isUserSubCollection()) {
DbUser dbUser = new DbUser();
dbUser.setId(targetId);
return dbUser;
}
if (isGroupSubCollection()) {
DbGroup dbGroup = new DbGroup();
dbGroup.setId(targetId);
return dbGroup;
}
if (permission.isSetUser()) {
User user = permission.getUser();
DbUser dbUser = UserMapper.map(user, null);
if (dbUser.getDomain() == null) {
dbUser.setDomain(getCurrent().getUser().getDomain());
}
return dbUser;
}
if (permission.isSetGroup()) {
Group group = permission.getGroup();
DbGroup dbGroup = GroupMapper.map(group, null);
if (dbGroup.getDomain() == null) {
dbGroup.setDomain(getCurrent().getUser().getDomain());
}
return dbGroup;
}
return null;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.
the class BackendAssignedPermissionsResource method getParameters.
/**
* Create the parameters for the permissions operation.
*
* @param model the incoming permission
* @return the parameters for the operation
*/
private PermissionsOperationsParameters getParameters(Permission model) {
org.ovirt.engine.core.common.businessentities.Permission entity = map(model, null);
if (!isPrincipalSubCollection()) {
entity.setObjectId(targetId);
entity.setObjectType(objectType);
}
PermissionsOperationsParameters parameters = new PermissionsOperationsParameters();
parameters.setPermission(entity);
Object principal = getPrincipal(model);
if (principal instanceof DbUser) {
DbUser user = (DbUser) principal;
entity.setAdElementId(user.getId());
parameters.setUser(user);
}
if (principal instanceof DbGroup) {
DbGroup group = (DbGroup) principal;
entity.setAdElementId(group.getId());
parameters.setGroup(group);
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup 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.DbGroup 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);
}
Aggregations