use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationsApiServiceDelegatorImpl method flagNotificationAsArchived.
@Override
@AccessControl(requiredScope = ScopePathType.PREMIUM_NOTIFICATION)
public Response flagNotificationAsArchived(String orcid, Long id) throws OrcidNotificationAlreadyReadException {
checkIfProfileDeprecated(orcid);
Notification notification = notificationManager.flagAsArchived(orcid, id);
if (notification == null) {
Map<String, String> params = new HashMap<String, String>();
params.put("orcid", orcid);
params.put("id", String.valueOf(id));
throw new OrcidNotificationNotFoundException(params);
}
return Response.ok(notification).build();
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationsApiServiceDelegatorImpl method findPermissionNotification.
@Override
@AccessControl(requiredScope = ScopePathType.PREMIUM_NOTIFICATION)
public Response findPermissionNotification(String orcid, Long id) {
checkIfProfileDeprecated(orcid);
Notification notification = notificationManager.findByOrcidAndId(orcid, id);
if (notification != null) {
checkSource(notification);
return Response.ok(notification).build();
} else {
Map<String, String> params = new HashMap<String, String>();
params.put("orcid", orcid);
params.put("id", String.valueOf(id));
throw new OrcidNotificationNotFoundException(params);
}
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationsApiServiceDelegatorImpl method addPermissionNotification.
@Override
@AccessControl(requiredScope = ScopePathType.PREMIUM_NOTIFICATION)
public Response addPermissionNotification(UriInfo uriInfo, String orcid, NotificationPermission notification) {
checkIfProfileDeprecated(orcid);
notificationValidationManager.validateNotificationPermission(notification);
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
if (profile == null) {
throw OrcidNotFoundException.newInstance(orcid);
}
if (profile.getSendMemberUpdateRequests() != null && !profile.getSendMemberUpdateRequests()) {
Map<String, String> params = new HashMap<String, String>();
params.put("orcid", orcid);
throw new OrcidNotificationException(params);
}
Notification createdNotification = notificationManager.createNotification(orcid, notification);
try {
return Response.created(new URI(uriInfo.getAbsolutePath() + "/" + createdNotification.getPutCode())).build();
} catch (URISyntaxException e) {
throw new RuntimeException(localeManager.resolveMessage("apiError.notification_uri.exception"), e);
}
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class NotificationManagerImpl method findPermissionsByOrcidAndClient.
@Override
@Transactional(readOnly = true)
public NotificationPermissions findPermissionsByOrcidAndClient(String orcid, String client, int firstResult, int maxResults) {
NotificationPermissions notifications = new NotificationPermissions();
List<Notification> notificationsForOrcidAndClient = notificationAdapter.toNotification(notificationDao.findPermissionsByOrcidAndClient(orcid, client, firstResult, maxResults));
List<NotificationPermission> notificationPermissions = new ArrayList<>();
notificationsForOrcidAndClient.forEach(n -> notificationPermissions.add((NotificationPermission) n));
notifications.setNotifications(notificationPermissions);
return notifications;
}
use of org.orcid.jaxb.model.notification_v2.Notification in project ORCID-Source by ORCID.
the class EmailMessageSenderImpl method flagAsSent.
private void flagAsSent(List<Notification> notifications) {
List<Long> notificationIds = new ArrayList<>();
for (Notification notification : notifications) {
notificationIds.add(notification.getPutCode());
}
List<List<Long>> batches = Lists.partition(notificationIds, 30000);
for (List<Long> batch : batches) {
notificationDao.flagAsSent(batch);
}
notificationDao.flush();
}
Aggregations