use of com.pratilipi.common.type.NotificationState in project pratilipi by Pratilipi.
the class NotificationDataUtil method saveNotificationState.
public static void saveNotificationState(Map<Long, NotificationState> notificationStates) throws InsufficientAccessException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
Map<Long, Notification> notifications = dataAccessor.getNotifications(notificationStates.keySet());
for (Map.Entry<Long, NotificationState> entry : notificationStates.entrySet()) {
Notification notification = notifications.get(entry.getKey());
if (notification.getState() == entry.getValue())
continue;
if (!hasAccessToUpdateData(notification))
throw new InsufficientAccessException();
notification.setState(entry.getValue());
}
dataAccessor.createOrUpdateNotificationList(new ArrayList<Notification>(notifications.values()));
}
Aggregations