class FindComplaintByIdAPIController {

    @RequestMapping(value = "/byId/{complaintId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
    @DecoratedAssignedObjectParticipants
    @ResponseBody
    public Complaint findComplaintById(
            @PathVariable("complaintId") Long complaintId,
            Authentication authentication,
            HttpSession session,
            HttpServletResponse response) throws AcmObjectNotFoundException, AcmUserActionFailedException
    {
        if (log.isInfoEnabled())
        {
            log.info("Finding complaint by id '" + complaintId + "'");
        }

        try
        {
            Complaint found = getComplaintDao().find(complaintId);

            if (found == null)
            {
                throw new AcmObjectNotFoundException("complaint", complaintId, "Object Not Found", null);
            }

            raiseEvent(authentication, session, found, true);

            return found;
        }
        catch (PersistenceException | TransactionException e)
        {
            // make a fake complaint so the event will have the desired complaint id and object type
            Complaint fakeComplaint = new Complaint();
            fakeComplaint.setComplaintId(complaintId);
            raiseEvent(authentication, session, fakeComplaint, false);

            throw new AcmUserActionFailedException("find", "complaint", complaintId, e.getMessage(), e);
        }

    }

}