Ejemplo n.º 1
0
 private String prepareNewSubmissionContent(Submission submission, String template) {
   return template
       .replace("{session.title}", submission.getTitle())
       .replace("{session.abstract}", submission.getDescription())
       .replace(
           "{speaker.name}",
           submission.getSpeaker().getFirstName() + " " + submission.getSpeaker().getLastName())
       .replace("{speaker.bio}", submission.getSpeaker().getBio());
 }
Ejemplo n.º 2
0
  @RequestMapping(value = "/cfp", method = RequestMethod.POST)
  public String submitSession(
      @Valid final Submission submission,
      BindingResult bindingResult,
      @RequestParam("speakerImage") MultipartFile speakerImage,
      @RequestParam("coSpeakerImage") MultipartFile coSpeakerImage,
      Model model) {
    if (bindingResult.hasErrors()
        || StringUtils.isEmpty(submission.getSpeaker().getEmail())
        || !new EmailValidator().isValid(submission.getSpeaker().getEmail(), null)) {
      model.addAttribute("tags", userFacade.findAllTags());
      buildCfpFormModel(model, new Submission());
      return Globals.CFP;
    }
    saveSubmission(submission, speakerImage, coSpeakerImage);
    try {
      mailFacade.sendEmail(
          submission.getSpeaker().getEmail(),
          "jPrime talk proposal",
          loadMailContentTemplate("submissionContent.html"));
      if (submission.getCoSpeaker() != null) {
        mailFacade.sendEmail(
            submission.getCoSpeaker().getEmail(),
            "jPrime talk proposal",
            loadMailContentTemplate("submissionContent.html"));
      }
      mailFacade.sendEmail(
          JPRIME_CONF_MAIL_ADDRESS,
          "New talk proposal",
          prepareNewSubmissionContent(submission, loadMailContentTemplate("newSubmission.html")));
    } catch (Exception e) {
      logger.error("Could not send confirmation email", e);
    }

    return "redirect:/";
  }