Revision 60810
Added by Konstantina Galouni about 2 years ago
modules/uoa-notification-service/trunk/src/main/java/eu/dnetlib/uoanotificationservice/services/NotificationService.java | ||
---|---|---|
72 | 72 |
notificationDAO.delete(id); |
73 | 73 |
} |
74 | 74 |
|
75 |
// every min for testing |
|
76 |
//@Scheduled(cron = "0 * * * * *" |
|
77 |
// every day at midnight |
|
78 |
@Scheduled(cron = "0 0 0 1/1 * ?") |
|
79 |
protected void deleteNotifications() { |
|
80 |
logger.info("Deleting notifications that have been created more than a week ago"); |
|
81 |
Calendar calendar = Calendar.getInstance(); |
|
82 |
calendar.add(Calendar.DAY_OF_MONTH, -7); |
|
83 |
List<Notification> notifications = notificationDAO.findByDateBefore(calendar.getTime()); |
|
84 |
notifications.forEach(notification -> { |
|
85 |
delete(notification.getId()); |
|
86 |
}); |
|
87 |
} |
|
75 |
// // every min for testing
|
|
76 |
// //@Scheduled(cron = "0 * * * * *"
|
|
77 |
// // every day at midnight
|
|
78 |
// @Scheduled(cron = "0 0 0 1/1 * ?")
|
|
79 |
// protected void deleteNotifications() {
|
|
80 |
// logger.info("Deleting notifications that have been created more than a week ago");
|
|
81 |
// Calendar calendar = Calendar.getInstance();
|
|
82 |
// calendar.add(Calendar.DAY_OF_MONTH, -7);
|
|
83 |
// List<Notification> notifications = notificationDAO.findByDateBefore(calendar.getTime());
|
|
84 |
// notifications.forEach(notification -> {
|
|
85 |
// delete(notification.getId());
|
|
86 |
// });
|
|
87 |
// }
|
|
88 | 88 |
} |
modules/uoa-notification-service/trunk/src/main/java/eu/dnetlib/uoanotificationservice/controllers/NotificationController.java | ||
---|---|---|
22 | 22 |
@Autowired |
23 | 23 |
private AuthorizationService authorizationService; |
24 | 24 |
|
25 |
@PreAuthorize("hasAuthority(@AuthorizationService.REGISTERED_USER)")
|
|
25 |
@PreAuthorize("hasAuthority(@AuthorizationService.PORTAL_ADMIN)")
|
|
26 | 26 |
@RequestMapping(value = {"/all"}, method = RequestMethod.GET) |
27 | 27 |
public List<Notification> getAllNotifications() { |
28 | 28 |
return notificationService.getAllNotifications(); |
modules/uoa-notification-service/trunk/src/main/java/eu/dnetlib/uoanotificationservice/configuration/NotificationConfiguration.java | ||
---|---|---|
6 | 6 |
import org.springframework.scheduling.annotation.EnableScheduling; |
7 | 7 |
|
8 | 8 |
@Configuration |
9 |
@PropertySources({ |
|
10 |
@PropertySource("classpath:notification.properties"), |
|
11 |
@PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true) |
|
12 |
}) |
|
9 |
//@PropertySources({
|
|
10 |
// @PropertySource("classpath:notification.properties"),
|
|
11 |
// @PropertySource(value = "classpath:dnet-override.properties", ignoreResourceNotFound = true)
|
|
12 |
//})
|
|
13 | 13 |
@EnableConfigurationProperties({MongoConfig.class}) |
14 | 14 |
@EnableScheduling |
15 | 15 |
@ComponentScan(basePackages = { "eu.dnetlib.uoanotificationservice"}) |
modules/uoa-notification-service/trunk/src/main/resources/notification.properties | ||
---|---|---|
1 |
notification.mongodb.host = localhost |
|
2 |
notification.mongodb.port = 27017 |
|
3 |
notification.mongodb.database = openaire_notification |
|
1 |
#notification.mongodb.host = localhost |
|
2 |
#notification.mongodb.port = 27017 |
|
3 |
#notification.mongodb.database = openaire_notification |
Also available in: Unified diff
[Trunk | Notificaton Service]:
1. NotificationConfiguration.java: [Bug fix] Commented @PropertySources (a library service should not set properties locally, but parent service is responsible for that).
2. NotificationController.java: For method "getAllNotifications()" (/all), set @PreAuthorize to PORTAL_ADMIN (instead of REGISTERED_USER) (used for testing).
3. NotificationService.java: Comment @Scheduled(cron = "0 0 0 1/1 * ?") method "deleteNotifications()" and never delete old notifications.
4. notification.properties: Commented properties - set in dnet-override.properties file.