use of org.orcid.core.exception.OrcidNotificationAlreadyReadException in project ORCID-Source by ORCID.
the class NotificationManagerImpl method flagAsArchived.
@Override
@Transactional
public Notification flagAsArchived(String orcid, Long id, boolean validateForApi) throws OrcidNotificationAlreadyReadException {
NotificationEntity notificationEntity = notificationDao.findByOricdAndId(orcid, id);
if (notificationEntity == null) {
return null;
}
String sourceId = sourceManager.retrieveSourceOrcid();
if (validateForApi) {
if (sourceId != null && !sourceId.equals(notificationEntity.getElementSourceId())) {
Map<String, String> params = new HashMap<String, String>();
params.put("activity", "notification");
throw new WrongSourceException(params);
}
if (notificationEntity.getReadDate() != null) {
throw new OrcidNotificationAlreadyReadException();
}
}
if (notificationEntity.getArchivedDate() == null) {
notificationEntity.setArchivedDate(new Date());
notificationDao.merge(notificationEntity);
}
return notificationAdapter.toNotification(notificationEntity);
}
use of org.orcid.core.exception.OrcidNotificationAlreadyReadException in project ORCID-Source by ORCID.
the class NotificationManagerImpl method flagAsArchived.
@Override
@Transactional
public Notification flagAsArchived(String orcid, Long id, boolean validateForApi) throws OrcidNotificationAlreadyReadException {
NotificationEntity notificationEntity = notificationDao.findByOricdAndId(orcid, id);
if (notificationEntity == null) {
return null;
}
String sourceId = sourceManager.retrieveSourceOrcid();
if (validateForApi) {
if (sourceId != null && !sourceId.equals(notificationEntity.getElementSourceId())) {
Map<String, String> params = new HashMap<String, String>();
params.put("activity", "notification");
throw new WrongSourceException(params);
}
if (notificationEntity.getReadDate() != null) {
throw new OrcidNotificationAlreadyReadException();
}
}
if (notificationEntity.getArchivedDate() == null) {
notificationEntity.setArchivedDate(new Date());
notificationDao.merge(notificationEntity);
}
return notificationAdapter.toNotification(notificationEntity);
}
Aggregations