Revision 53266
Added by Argiro Kokogiannaki over 5 years ago
NotificationsController.java | ||
---|---|---|
4 | 4 |
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO; |
5 | 5 |
import eu.dnetlib.uoaadmintools.entities.Notifications; |
6 | 6 |
import eu.dnetlib.uoaadmintools.handlers.NotFoundException; |
7 |
import org.apache.log4j.Logger; |
|
7 | 8 |
import org.springframework.beans.factory.annotation.Autowired; |
8 | 9 |
import org.springframework.web.bind.annotation.*; |
9 | 10 |
|
... | ... | |
15 | 16 |
@RestController |
16 | 17 |
@CrossOrigin(origins = "*") |
17 | 18 |
public class NotificationsController { |
19 |
private final Logger log = Logger.getLogger(this.getClass()); |
|
20 |
|
|
18 | 21 |
@Autowired |
19 | 22 |
private NotificationsDAO notificationsDAO; |
20 | 23 |
@Autowired |
... | ... | |
47 | 50 |
if(communityDAO.findByPid(pid) == null){ |
48 | 51 |
throw new NotFoundException("Community not found"); |
49 | 52 |
} |
50 |
notifications.setCommunityPid(pid); |
|
51 |
Notifications savedNotifications = notificationsDAO.save(notifications); |
|
52 |
return savedNotifications; |
|
53 | 53 |
|
54 |
if(notifications.getManagerEmail() != null && !notifications.getManagerEmail().isEmpty()){ |
|
55 |
Notifications saved = notificationsDAO.findByManagerEmailAndCommunityPid(notifications.getManagerEmail(),pid); |
|
56 |
log.debug(saved); |
|
57 |
if(saved!= null){ |
|
58 |
notifications.setId(saved.getId()); |
|
59 |
} |
|
60 |
|
|
61 |
notifications.setCommunityPid(pid); |
|
62 |
log.debug(notifications); |
|
63 |
Notifications savedNotifications = notificationsDAO.save(notifications); |
|
64 |
return savedNotifications; |
|
65 |
}else{ |
|
66 |
log.error("No user e-mail specified"); |
|
67 |
return null; |
|
68 |
} |
|
69 |
|
|
70 |
|
|
54 | 71 |
} |
55 | 72 |
|
56 | 73 |
} |
Also available in: Unified diff
Fix configuration update method not creating duplicates, add check for no user information