@Transactional
    @RequestMapping(value = {"/app/saveIssue"}, method = RequestMethod.POST)  
    public ModelAndView saveIssue(HttpServletRequest request,
                                  @RequestParam(required = false) Long id,
                                  @RequestParam String title,
                                  @RequestParam String description,
                                  @RequestParam Long assignee,
                                  @RequestParam String priority,
                                  @RequestParam String status,
                                  Principal principal)
    {
        User visitor = usersRepository.findByLogin(principal.getName());
        
        boolean newIssue = Utils.isEmpty(id);
        
        IssueForm issueForm;
        
        if (newIssue) {
            issueForm = new IssueForm();
            issueForm.setCreator(visitor);
            issueForm.setCreationDate(new Date());                        
        } else {
            issueForm = new IssueForm(issuesRepository.findOne(id));
        }
        
        issueForm.setTitle(title);
        issueForm.setDescription(description);
        issueForm.setAssignee(assignee != null ? usersRepository.findOne(assignee) : null);
        issueForm.setPriority(Priority.valueOf(priority));
        issueForm.setStatus(Status.valueOf(status));
        
        MessageCollector collector = new MessageCollector();           
        IssueFormValidator validator = new IssueFormValidator(visitor, newIssue);
        
        ModelAndView modelAndView;
        
        if (validator.validate(collector, issueForm)) {
            Issue issue = newIssue ? new Issue() : issuesRepository.findOne(id);
            
            issueForm.apply(issue);
            
            issuesRepository.save(issue);            

            if (!newIssue) {
                IssuesSearchForm searchForm = (IssuesSearchForm) request.getSession().getAttribute(Constants.BEAN_SEARCH_ISSUES_FORM);
                if (searchForm != null) {
                    List<Issue> issues = searchIssues(
                            visitor, 
                            searchForm.getCreator(), 
                            searchForm.getAssignee(), 
                            searchForm.getTitle(),
                            searchForm.getPriority(), 
                            searchForm.getStatus()
                    );
                    
                    modelAndView = new ModelAndView("issues");
                    modelAndView.addObject(Constants.ISSUES, issues);
                } else {
                    modelAndView = new ModelAndView("index");
                }
            } else {
                modelAndView = new ModelAndView("index");
            }

            modelAndView.addObject(Constants.USERS, usersRepository.findAll());
            
        } else {
            modelAndView = new ModelAndView("edit_issue");
            modelAndView.addObject(Constants.ISSUE, issueForm);
            modelAndView.addObject(Constants.USERS, usersRepository.findAll());
            modelAndView.addObject(Constants.MESSAGE_COLLECTOR, collector);
        }

        return modelAndView;
    }