use of org.orcid.persistence.jpa.entities.ActionableNotificationEntity in project ORCID-Source by ORCID.
the class NotificationController method executeAction.
@RequestMapping(value = "/encrypted/{encryptedId}/action", method = RequestMethod.GET)
public ModelAndView executeAction(@PathVariable("encryptedId") String encryptedId) {
String idString;
try {
idString = encryptionManager.decryptForExternalUse(new String(Base64.decodeBase64(encryptedId), "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("Problem decoding " + encryptedId, e);
}
Long id = Long.valueOf(idString);
ActionableNotificationEntity notification = (ActionableNotificationEntity) notificationManager.findActionableNotificationEntity(id);
String redirectUrl = notification.getAuthorizationUrl();
String notificationOrcid = notification.getProfile().getId();
OrcidProfileUserDetails user = getCurrentUser();
if (user != null) {
// The user is logged in
if (!user.getOrcid().equals(notificationOrcid)) {
return new ModelAndView("wrong_user");
}
} else {
redirectUrl += "&orcid=" + notificationOrcid;
}
notificationManager.setActionedAndReadDate(notificationOrcid, id);
return new ModelAndView("redirect:" + redirectUrl);
}
Aggregations