use of io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto 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()));
}
use of io.datarouter.auth.web.DatarouterPermissionRequestHandler.PermissionRequestDto in project datarouter by hotpads.
the class AdminEditUserHandler method buildPermissionRequestDto.
// TODO DATAROUTER-2789
private PermissionRequestDto buildPermissionRequestDto(Entry<DatarouterPermissionRequest, Optional<String>> entry) {
ZoneId zoneId = currentUserSessionInfoService.getZoneId(getRequest());
DatarouterPermissionRequest request = entry.getKey();
return new PermissionRequestDto(request.getKey().getRequestTime(), request.getRequestText(), request.getResolutionTime(), entry.getValue().orElse(null), zoneId);
}
Aggregations