Search in sources :

Example 1 with Notification

use of org.sagebionetworks.bridge.models.schedules2.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();
}
Also used : HashMap(java.util.HashMap) OrcidNotificationNotFoundException(org.orcid.core.exception.OrcidNotificationNotFoundException) Notification(org.orcid.jaxb.model.notification_v2.Notification) AccessControl(org.orcid.core.security.visibility.aop.AccessControl)

Example 2 with Notification

use of org.sagebionetworks.bridge.models.schedules2.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);
    }
}
Also used : HashMap(java.util.HashMap) OrcidNotificationNotFoundException(org.orcid.core.exception.OrcidNotificationNotFoundException) Notification(org.orcid.jaxb.model.notification_v2.Notification) AccessControl(org.orcid.core.security.visibility.aop.AccessControl)

Example 3 with Notification

use of org.sagebionetworks.bridge.models.schedules2.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);
    }
}
Also used : HashMap(java.util.HashMap) OrcidNotificationException(org.orcid.core.exception.OrcidNotificationException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Notification(org.orcid.jaxb.model.notification_v2.Notification) AccessControl(org.orcid.core.security.visibility.aop.AccessControl)

Example 4 with Notification

use of org.sagebionetworks.bridge.models.schedules2.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;
}
Also used : NotificationPermissions(org.orcid.jaxb.model.notification.permission_v2.NotificationPermissions) ArrayList(java.util.ArrayList) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) Notification(org.orcid.jaxb.model.notification_v2.Notification) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Notification

use of org.sagebionetworks.bridge.models.schedules2.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());
}
Also used : NotificationCustom(org.orcid.jaxb.model.notification.custom_v2.NotificationCustom) ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Notification(org.orcid.jaxb.model.notification_v2.Notification) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Notification (org.oasis_open.docs.ws_tx.wsat._2006._06.Notification)28 Notification (org.orcid.jaxb.model.notification_v2.Notification)18 ArjunaContext (com.arjuna.webservices11.wsarj.ArjunaContext)15 MAP (org.jboss.ws.api.addressing.MAP)15 MessageContext (javax.xml.ws.handler.MessageContext)13 Task (com.arjuna.services.framework.task.Task)11 Action (javax.xml.ws.Action)11 MAPEndpoint (org.jboss.ws.api.addressing.MAPEndpoint)11 Notification (com.google.storage.v2.Notification)10 StorageClient (com.google.storage.v2.StorageClient)10 HashMap (java.util.HashMap)8 Test (org.junit.Test)8 AccessControl (org.orcid.core.security.visibility.aop.AccessControl)6 NotificationAmended (org.orcid.jaxb.model.notification.amended_v2.NotificationAmended)5 NotificationPermission (org.orcid.jaxb.model.notification.permission_v2.NotificationPermission)5 NotificationInstitutionalConnection (org.orcid.model.notification.institutional_sign_in_v2.NotificationInstitutionalConnection)5 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 NotificationCustom (org.orcid.jaxb.model.notification.custom_v2.NotificationCustom)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4