Exemplo n.º 1
0
 @RequestMapping(value = "/{templateName}/{cmsName}", method = POST)
 public String sendEmail(
     DownloadRequest downloadRequest,
     @PathVariable String templateName,
     @PathVariable String cmsName) {
   downloadRequest.setTemplateName(templateName);
   downloadRequest.setCms(cmsName);
   downloadRequest.setCreated(LocalDateTime.now());
   logger.info("New download request: {}", downloadRequest);
   downloadRequest = downloadRequestRepository.save(downloadRequest);
   long timestamp = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC);
   String hash =
       downloadRequestParamsHasher.getHash(
           Template.valueOf(templateName).getDownloadName(),
           Cms.valueOf(cmsName).getNamePl(),
           timestamp);
   HtmlEmailMessage htmlEmailMessage =
       new HtmlEmailMessage(
           "*****@*****.**",
           downloadRequest.getAdministrativeEmail(),
           "Szablon CMS ze strony PWD",
           getEmailMessageTemplate(),
           getEmailMessageModelMap(
               templateName,
               Template.valueOf(templateName).getDownloadName(),
               Cms.valueOf(cmsName).getNamePl(),
               hash,
               timestamp));
   if (mailgunClient.sendEmail(htmlEmailMessage)) {
     return "email_download";
   }
   return "error";
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/{templateName}/{cmsName}", method = RequestMethod.GET)
 public String showTemplateDownloadForm(
     @PathVariable String templateName, @PathVariable String cmsName, Model model) {
   model.addAttribute("template", Template.valueOf(templateName));
   model.addAttribute("cms", Cms.valueOf(cmsName));
   return "downloadForm";
 }
Exemplo n.º 3
0
 @RequestMapping(method = RequestMethod.GET)
 public String showTemplates(Model model) {
   model.addAttribute("templates", Arrays.asList(Template.values()));
   return "download";
 }