use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class SystemPermissionView method initTable.
private void initTable(SystemPermissionActionPanelPresenterWidget actionPanel) {
table.enableColumnResizing();
// $NON-NLS-1$
table.addColumn(new PermissionTypeColumn(), constants.empty(), "30px");
AbstractTextColumn<Permission> userColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getOwnerName();
}
};
userColumn.makeSortable((u1, u2) -> u1.getOwnerName().compareTo(u2.getObjectName()));
// $NON-NLS-1$
table.addColumn(userColumn, constants.userPermission(), "270px");
AbstractTextColumn<Permission> authzColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getAuthz();
}
};
authzColumn.makeSortable((a1, a2) -> a1.getAuthz().compareTo(a2.getAuthz()));
// $NON-NLS-1$
table.addColumn(authzColumn, constants.authz(), "180px");
AbstractTextColumn<Permission> namespaceColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getNamespace();
}
};
namespaceColumn.makeSortable((ns1, ns2) -> ns1.getNamespace().compareTo(ns1.getNamespace()));
// $NON-NLS-1$
table.addColumn(namespaceColumn, constants.namespace(), "170px");
AbstractTextColumn<Permission> roleColumn = new AbstractTextColumn<Permission>() {
@Override
public String getValue(Permission object) {
return object.getRoleName();
}
};
roleColumn.makeSortable((r1, r2) -> r1.getRoleName().compareTo(r2.getRoleName()));
// $NON-NLS-1$
table.addColumn(roleColumn, constants.rolePermission(), "110px");
table.getSelectionModel().addSelectionChangeHandler(event -> modelProvider.setSelectedItems(table.getSelectionModel().getSelectedObjects()));
tablePanel.add(actionPanel);
tablePanel.add(table);
table.table.setHeight(360 + Unit.PX.getType());
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class AddVmCommand method addDiskPermissions.
private void addDiskPermissions() {
List<Guid> newDiskImageIds = new ArrayList<>(srcDiskIdToTargetDiskIdMapping.values());
Permission[] permsArray = new Permission[newDiskImageIds.size()];
for (int i = 0; i < newDiskImageIds.size(); i++) {
permsArray[i] = new Permission(getUserIdOfDiskOperator(), PredefinedRoles.DISK_OPERATOR.getId(), newDiskImageIds.get(i), VdcObjectType.Disk);
}
multiLevelAdministrationHandler.addPermission(permsArray);
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class AddVmCommand method copyTemplatePermissions.
private void copyTemplatePermissions(UniquePermissionsSet permissionsToAdd) {
List<Permission> templatePermissions = permissionDao.getAllForEntity(getVmTemplateId(), getEngineSessionSeqId(), false);
for (Permission templatePermission : templatePermissions) {
boolean templateOwnerRole = templatePermission.getRoleId().equals(PredefinedRoles.TEMPLATE_OWNER.getId());
boolean templateUserRole = templatePermission.getRoleId().equals(PredefinedRoles.TEMPLATE_USER.getId());
if (templateOwnerRole || templateUserRole) {
continue;
}
permissionsToAdd.addPermission(templatePermission.getAdElementId(), templatePermission.getRoleId(), getVmId(), VdcObjectType.VM);
}
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class ImportVmCommandBase method addVmPermission.
private void addVmPermission() {
UniquePermissionsSet permissionsToAdd = new UniquePermissionsSet();
if (isMakeCreatorExplicitOwner()) {
permissionsToAdd.addPermission(getCurrentUser().getId(), PredefinedRoles.VM_OPERATOR.getId(), getVmId(), VdcObjectType.VM);
}
if (!permissionsToAdd.isEmpty()) {
List<Permission> permissionsList = permissionsToAdd.asPermissionList();
multiLevelAdministrationHandler.addPermission(permissionsList.toArray(new Permission[permissionsList.size()]));
getCompensationContext().snapshotNewEntities(permissionsList);
}
}
use of org.ovirt.engine.core.common.businessentities.Permission in project ovirt-engine by oVirt.
the class AddCpuProfileCommand method createPermissionParameters.
private PermissionsOperationsParameters createPermissionParameters(Guid userId, Guid roleId) {
Permission permission = new Permission(userId, roleId, getProfileId(), VdcObjectType.CpuProfile);
permission.setObjectName(getParameters().getProfile().getName());
if (MultiLevelAdministrationHandler.EVERYONE_OBJECT_ID.equals(userId)) {
permission.setAuthz("N/A");
}
PermissionsOperationsParameters permissionsOperationsParameters = new PermissionsOperationsParameters(permission);
permissionsOperationsParameters.setParametersCurrentUser(getCurrentUser());
permissionsOperationsParameters.setSessionId(getContext().getEngineContext().getSessionId());
return permissionsOperationsParameters;
}
Aggregations