Search in sources :

Example 1 with Notification

use of org.orcid.jaxb.model.v3.dev1.notification.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.v3.dev1.notification.Notification) AccessControl(org.orcid.core.security.visibility.aop.AccessControl)

Example 2 with Notification

use of org.orcid.jaxb.model.v3.dev1.notification.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.v3.dev1.notification.Notification) AccessControl(org.orcid.core.security.visibility.aop.AccessControl)

Example 3 with Notification

use of org.orcid.jaxb.model.v3.dev1.notification.Notification in project ORCID-Source by ORCID.

the class NotificationController method getInstitutionalConnectionNotificationHtml.

@RequestMapping(value = "/INSTITUTIONAL_CONNECTION/{id}/notification.html", produces = OrcidApiConstants.HTML_UTF)
public ModelAndView getInstitutionalConnectionNotificationHtml(@PathVariable("id") String id) throws UnsupportedEncodingException {
    ModelAndView mav = new ModelAndView();
    Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
    String clientId = notification.getSource().retrieveSourcePath();
    ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId);
    String authorizationUrl = notificationManager.buildAuthorizationUrlForInstitutionalSignIn(clientDetails);
    addSourceDescription(notification);
    mav.addObject("notification", notification);
    mav.addObject("baseUri", getBaseUri());
    mav.addObject("clientId", clientId);
    mav.addObject("authorizationUrl", authorizationUrl);
    mav.setViewName("notification/institutional_connection_notification");
    mav.addObject("noIndex", true);
    return mav;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ModelAndView(org.springframework.web.servlet.ModelAndView) Notification(org.orcid.jaxb.model.v3.dev1.notification.Notification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with Notification

use of org.orcid.jaxb.model.v3.dev1.notification.Notification in project ORCID-Source by ORCID.

the class NotificationController method getPermissionNotificationHtml.

@RequestMapping(value = "/PERMISSION/{id}/notification.html", produces = OrcidApiConstants.HTML_UTF)
public ModelAndView getPermissionNotificationHtml(@PathVariable("id") String id) {
    ModelAndView mav = new ModelAndView();
    Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
    addSourceDescription(notification);
    mav.addObject("notification", notification);
    mav.setViewName("notification/add_activities_notification");
    mav.addObject("noIndex", true);
    return mav;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Notification(org.orcid.jaxb.model.v3.dev1.notification.Notification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Notification

use of org.orcid.jaxb.model.v3.dev1.notification.Notification in project ORCID-Source by ORCID.

the class NotificationController method getCustomNotificationHtml.

@RequestMapping(value = "/CUSTOM/{id}/notification.html", produces = OrcidApiConstants.HTML_UTF)
@ResponseBody
public String getCustomNotificationHtml(HttpServletResponse response, @PathVariable("id") String id) {
    Notification notification = notificationManager.findByOrcidAndId(getCurrentUserOrcid(), Long.valueOf(id));
    response.addHeader("X-Robots-Tag", "noindex");
    if (notification instanceof NotificationCustom) {
        return ((NotificationCustom) notification).getBodyHtml();
    } else {
        return "Notification is of wrong type";
    }
}
Also used : NotificationCustom(org.orcid.jaxb.model.v3.dev1.notification.custom.NotificationCustom) Notification(org.orcid.jaxb.model.v3.dev1.notification.Notification) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Test (org.junit.Test)15 Notification (org.orcid.jaxb.model.v3.dev1.notification.Notification)13 NotificationPermission (org.orcid.jaxb.model.v3.dev1.notification.permission.NotificationPermission)13 NotificationCustom (org.orcid.jaxb.model.v3.dev1.notification.custom.NotificationCustom)9 HashMap (java.util.HashMap)8 AuthorizationUrl (org.orcid.jaxb.model.v3.dev1.notification.permission.AuthorizationUrl)8 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)8 ClientResponse (com.sun.jersey.api.client.ClientResponse)7 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)6 Locale (java.util.Locale)5 NotificationInstitutionalConnection (org.orcid.model.v3.dev1.notification.institutional_sign_in.NotificationInstitutionalConnection)5 Source (org.orcid.jaxb.model.v3.dev1.common.Source)4 NotificationAmended (org.orcid.jaxb.model.v3.dev1.notification.amended.NotificationAmended)4 NotificationEntity (org.orcid.persistence.jpa.entities.NotificationEntity)4 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)4 IOException (java.io.IOException)3 URISyntaxException (java.net.URISyntaxException)3 ArrayList (java.util.ArrayList)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 Email (org.orcid.jaxb.model.v3.dev1.record.Email)3