Revision 60602
Added by Konstantinos Triantafyllou about 2 years ago
modules/uoa-notification-service/trunk/src/main/java/eu/dnetlib/uoanotificationservice/utils/Utils.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import eu.dnetlib.uoaauthorizationlibrary.security.AuthorizationService; |
4 | 4 |
import eu.dnetlib.uoanotificationservice.dao.NotificationDAO; |
5 |
import eu.dnetlib.uoanotificationservice.entities.Notification; |
|
6 |
import eu.dnetlib.uoanotificationservice.services.NotificationService; |
|
7 | 5 |
import org.apache.log4j.Logger; |
8 | 6 |
import org.springframework.beans.factory.annotation.Autowired; |
9 | 7 |
import org.springframework.stereotype.Component; |
... | ... | |
25 | 23 |
public boolean canRead(String id) { |
26 | 24 |
Set<String> groups = new HashSet<>(authorizationService.getRoles()); |
27 | 25 |
groups.add("all"); |
28 |
groups.add(authorizationService.getAaiId());
|
|
26 |
groups.add(authorizationService.getEmail().toLowerCase());
|
|
29 | 27 |
return notificationDAO.findByIdAndUserNotAndGroupsIn(id, authorizationService.getAaiId(), groups) != null; |
30 | 28 |
} |
31 | 29 |
|
modules/uoa-notification-service/trunk/src/main/java/eu/dnetlib/uoanotificationservice/services/NotificationService.java | ||
---|---|---|
29 | 29 |
return notificationDAO.findByOrderByDateDesc(); |
30 | 30 |
} |
31 | 31 |
|
32 |
public List<Notification> getMyNotifications(String userId, String service, List<String> roles) { |
|
33 |
logger.info("Getting notifications of user " + userId); |
|
32 |
public List<Notification> getMyNotifications(String userId, String email, String service, List<String> roles) {
|
|
33 |
logger.info("Getting notifications of user " + userId + ", " + email);
|
|
34 | 34 |
Set<String> services = new HashSet<>(); |
35 | 35 |
services.add(service); |
36 | 36 |
services.add("all"); |
37 | 37 |
Set<String> groups = new HashSet<>(roles); |
38 |
groups.add(userId);
|
|
38 |
groups.add(email.toLowerCase());
|
|
39 | 39 |
groups.add("all"); |
40 | 40 |
List<Notification> notifications = notificationDAO.findByUserNotAndServicesInAndGroupsInOrderByDateDesc(userId, services, groups); |
41 | 41 |
User user = userDAO.findById(userId); |
modules/uoa-notification-service/trunk/src/main/java/eu/dnetlib/uoanotificationservice/controllers/NotificationController.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
@RestController |
15 | 15 |
@RequestMapping("/notification") |
16 |
@CrossOrigin(origins = "*")
|
|
16 |
@CrossOrigin(origins = "*") |
|
17 | 17 |
public class NotificationController { |
18 | 18 |
|
19 | 19 |
@Autowired |
... | ... | |
31 | 31 |
@PreAuthorize("hasAuthority(@AuthorizationService.REGISTERED_USER)") |
32 | 32 |
@RequestMapping(value = {"/{service}"}, method = RequestMethod.GET) |
33 | 33 |
public List<Notification> getMyNotifications(@PathVariable String service) { |
34 |
return notificationService.getMyNotifications(authorizationService.getAaiId(), service, authorizationService.getRoles()); |
|
34 |
return notificationService.getMyNotifications(authorizationService.getAaiId(), authorizationService.getEmail(), |
|
35 |
service, authorizationService.getRoles()); |
|
35 | 36 |
} |
36 | 37 |
|
37 | 38 |
@PreAuthorize("hasAuthority(@AuthorizationService.REGISTERED_USER)") |
Also available in: Unified diff
[Notificaton Service | Trunk]: Fix a bug user email on groups