use of com.icodici.universa.node2.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 com.icodici.universa.node2.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 com.icodici.universa.node2.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 com.icodici.universa.node2.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 com.icodici.universa.node2.Notification in project ORCID-Source by ORCID.
the class NotificationManagerTest method testCreateCustomNotification.
@Test
public void testCreateCustomNotification() {
SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
String testOrcid = "0000-0000-0000-0003";
NotificationCustom notification = new NotificationCustom();
notification.setSubject("Test subject");
notification.setLang("en-gb");
Notification result = notificationManager.createNotification(testOrcid, notification);
assertNotNull(result);
assertTrue(result instanceof NotificationCustom);
NotificationCustom customResult = (NotificationCustom) result;
assertEquals("Test subject", customResult.getSubject());
assertEquals("en-gb", customResult.getLang());
}
Aggregations