use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters 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.action.PermissionsOperationsParameters 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.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.
the class AddCpuProfileCommand method addPermissions.
@Override
protected void addPermissions() {
PermissionsOperationsParameters permissionsOperationsParameters = createPermissionParameters(MultiLevelAdministrationHandler.EVERYONE_OBJECT_ID, PredefinedRoles.CPU_PROFILE_OPERATOR.getId());
backend.runAction(ActionType.AddPermission, permissionsOperationsParameters);
permissionsOperationsParameters = createPermissionParameters(getUserId(), PredefinedRoles.CPU_PROFILE_CREATOR.getId());
backend.runAction(ActionType.AddPermission, permissionsOperationsParameters);
}
use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters 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);
}
use of org.ovirt.engine.core.common.action.PermissionsOperationsParameters in project ovirt-engine by oVirt.
the class RemoveGroupCommand method executeCommand.
@Override
protected void executeCommand() {
// Get the identifier of the group 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 param = new PermissionsOperationsParameters(permission);
param.setSessionId(getParameters().getSessionId());
runInternalActionWithTasksContext(ActionType.RemovePermission, param);
}
// Remove the group itself:
dbGroupDao.remove(id);
setSucceeded(true);
}
Aggregations