@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_READ + "')") @Transactional(readOnly = true) public NotificationTO read(final String key) { Notification notification = notificationDAO.find(key); if (notification == null) { LOG.error("Could not find notification '" + key + "'"); throw new NotFoundException(String.valueOf(key)); } return binder.getNotificationTO(notification); }
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_CREATE + "')") public NotificationTO create(final NotificationTO notificationTO) { return binder.getNotificationTO(notificationDAO.save(binder.create(notificationTO))); }
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_DELETE + "')") public NotificationTO delete(final String key) { Notification notification = notificationDAO.find(key); if (notification == null) { LOG.error("Could not find notification '" + key + "'"); throw new NotFoundException(String.valueOf(key)); } NotificationTO deleted = binder.getNotificationTO(notification); notificationDAO.delete(key); return deleted; }
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_UPDATE + "')") public NotificationTO update(final NotificationTO notificationTO) { Notification notification = notificationDAO.find(notificationTO.getKey()); if (notification == null) { LOG.error("Could not find notification '" + notificationTO.getKey() + "'"); throw new NotFoundException(String.valueOf(notificationTO.getKey())); } binder.update(notification, notificationTO); notification = notificationDAO.save(notification); return binder.getNotificationTO(notification); }
@Override protected NotificationTO resolveReference(final Method method, final Object... args) throws UnresolvedReferenceException { String key = null; if (ArrayUtils.isNotEmpty(args)) { for (int i = 0; key == null && i < args.length; i++) { if (args[i] instanceof String) { key = (String) args[i]; } else if (args[i] instanceof NotificationTO) { key = ((NotificationTO) args[i]).getKey(); } } } if (key != null) { try { return binder.getNotificationTO(notificationDAO.find(key)); } catch (Throwable ignore) { LOG.debug("Unresolved reference", ignore); throw new UnresolvedReferenceException(ignore); } } throw new UnresolvedReferenceException(); } }