コード例 #1
0
  @PreAuthorize("hasRole('AUTH')")
  @RequestMapping(
      value = "/admin/configuration/saveEmailConfiguration.html",
      method = RequestMethod.POST)
  public String saveEmailSettings(
      @ModelAttribute("configuration") EmailConfig config,
      BindingResult result,
      Model model,
      HttpServletRequest request,
      Locale locale)
      throws Exception {
    setEmailConfigurationMenu(model, request);
    MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE);
    EmailConfig emailConfig = emailService.getEmailConfiguration(store);
    if (emailConfig == null) {
      emailConfig = new EmailConfig();
    }

    // populte EmailConfig model from UI values
    emailConfig.setProtocol(config.getProtocol());
    emailConfig.setHost(config.getHost());
    emailConfig.setPort(config.getPort());
    emailConfig.setUsername(config.getUsername());
    emailConfig.setPassword(config.getPassword());
    emailConfig.setSmtpAuth(config.isSmtpAuth());
    emailConfig.setStarttls(config.isStarttls());

    emailService.saveEmailConfiguration(emailConfig, store);

    model.addAttribute("configuration", emailConfig);
    model.addAttribute("success", "success");
    return ControllerConstants.Tiles.Configuration.email;
  }
コード例 #2
0
  @PreAuthorize("hasRole('AUTH')")
  @RequestMapping(value = "/admin/configuration/email.html", method = RequestMethod.GET)
  public String displayEmailSettings(
      Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
    setEmailConfigurationMenu(model, request);
    MerchantStore store = (MerchantStore) request.getAttribute(Constants.ADMIN_STORE);
    EmailConfig emailConfig = emailService.getEmailConfiguration(store);
    if (emailConfig == null) {
      emailConfig = new EmailConfig();
      // TODO: Need to check below properties. When there are no record available in
      // MerchantConfguration table with EMAIL_CONFIG key,
      // instead of showing blank fields in setup screen, show default configured values from
      // email.properties
      emailConfig.setProtocol(env.getProperty("mailSender.protocol"));
      emailConfig.setHost(env.getProperty("mailSender.host"));
      emailConfig.setPort(env.getProperty("mailSender.port}"));
      emailConfig.setUsername(env.getProperty("mailSender.username"));
      emailConfig.setPassword(env.getProperty("mailSender.password"));
      emailConfig.setSmtpAuth(Boolean.parseBoolean(env.getProperty("mailSender.mail.smtp.auth")));
      emailConfig.setStarttls(Boolean.parseBoolean(env.getProperty("mail.smtp.starttls.enable")));
    }

    model.addAttribute("configuration", emailConfig);
    return ControllerConstants.Tiles.Configuration.email;
  }