use of io.datarouter.web.user.session.service.SessionBasedUser in project datarouter by hotpads.
the class AdminEditUserHandler method getEditUserDetailsDto.
// TODO DATAROUTER-2788
private EditUserDetailsDto getEditUserDetailsDto(String username) {
SessionBasedUser user = userInfo.getUserByUsername(username, false).orElseThrow();
Set<Role> roles = userInfo.getRolesByUsername(username, false);
List<PermissionRequestDto> permissionRequests = datarouterPermissionRequestDao.scanPermissionRequestsForUser(user.getId()).listTo(requests -> Scanner.of(datarouterUserHistoryService.getResolvedRequestToHistoryChangesMap(requests).entrySet())).sort(Comparator.comparing(Entry::getKey, DatarouterPermissionRequest.REVERSE_CHRONOLOGICAL_COMPARATOR)).map(this::buildPermissionRequestDto).list();
return new EditUserDetailsDto(user.getUsername(), user.getId().toString(), user.getToken(), permissionRequests, deprovisionedUserDao.find(new DeprovisionedUserKey(username)).map(DeprovisionedUser::toDto).orElseGet(() -> buildDeprovisionedUserDto(user, roles)), roleManager.getConferrableRoles(getSessionInfo().getRoles()), roles, datarouterAccountUserService.getAllAccountNamesWithUserMappingsEnabled(), datarouterAccountUserService.findAccountNamesForUser(user), true, "", // zoneId can be configured through the UI, fallback to system default
user.getZoneId().map(ZoneId::getId).orElse(ZoneId.systemDefault().getId()));
}
Aggregations