class SaveNotificationAPIController {

    @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public Notification addNotification(
            @RequestBody Notification notification,
            HttpSession httpSession) throws AcmUserActionFailedException
    {
        if (log.isInfoEnabled())
        {

            if (notification != null)
            {
                log.info("Notification ID : " + notification.getId());
            }
            else
            {
                throw new AcmUserActionFailedException("addNote", NotificationConstants.OBJECT_TYPE, null,
                        "Could not save note, missing parent type and ID", new NullPointerException());
            }
        }

        try
        {
            // to db
            Notification newNotification = new Notification();

            newNotification.setId(notification.getId());
            newNotification.setCreated(notification.getCreated());
            newNotification.setCreator(notification.getCreator());
            newNotification.setStatus(notification.getStatus());
            newNotification.setAction(notification.getAction());
            newNotification.setNote(notification.getNote());
            newNotification.setModifier(notification.getModifier());
            newNotification.setModified(notification.getModified());
            newNotification.setData(notification.getData());
            newNotification.setType(notification.getType());
            newNotification.setUser(notification.getUser());

            Notification savedNotification = getNotificationDao().save(notification);

            publishNotificationEvent(httpSession, savedNotification, true);

            return savedNotification;
        }
        catch (Exception e)
        {
            // gen up a fake notification so we can audit the failure
            Notification fakeNotification = new Notification();
            fakeNotification.setId(notification.getId());
            log.info("fake id : " + fakeNotification.getId());
            log.info("fake id 2: " + notification.getId());

            fakeNotification.setId(notification.getId());
            fakeNotification.setCreated(notification.getCreated());
            fakeNotification.setCreator(notification.getCreator());
            fakeNotification.setStatus(notification.getStatus());
            fakeNotification.setAction(notification.getAction());
            fakeNotification.setNote(notification.getNote());
            fakeNotification.setModifier(notification.getModifier());
            fakeNotification.setModified(notification.getModified());
            fakeNotification.setData(notification.getData());
            fakeNotification.setType(notification.getType());
            fakeNotification.setUser(notification.getUser());

            publishNotificationEvent(httpSession, fakeNotification, false);
            throw new AcmUserActionFailedException("unable to add notification from ", notification.getUser(), notification.getId(),
                    e.getMessage(), e);
        }
    }

}