Exemplo n.º 1
0
  public MailBodyUI() {
    String fileName = StringUtilities.getConfigPath() + File.separator + "mailsetting.properties";
    File file = new File(fileName);
    this.mailProps = new LoadProperties(file).readProperties();

    String templatePath = StringUtilities.getConfigPath() + File.separator + "emailTemplates";
    this.theme = new Theme(templatePath, "");
  }
Exemplo n.º 2
0
  public String renderEmailBody(Map<String, Object> mailDetailsMap) {
    String output = "";

    try {
      if (!mailDetailsMap.isEmpty()) {
        String templateFor =
            (null != mailDetailsMap.get("templateFor")
                    && StringUtilities.isNotBlank(mailDetailsMap.get("templateFor").toString())
                ? mailDetailsMap.get("templateFor").toString()
                : "");
        switch (templateFor) {
          case "userActivation":
            {
              String userName =
                  (null != mailDetailsMap.get("userName")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("userName").toString())
                      ? mailDetailsMap.get("userName").toString()
                      : "There!");
              String activationURL =
                  (!mailDetailsMap.isEmpty()
                          && null != mailDetailsMap.get("ativationURL")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("ativationURL").toString())
                      ? mailDetailsMap.get("ativationURL").toString()
                      : "www.replad.com");

              String templateName = mailProps.get("replad.user.activation.email.template.name");
              output = renderActivationEmail(userName, activationURL, templateName);
              //						 								System.out.println("Email Body-->"+output);
              break;
            }
          case "newServiceRequest":
            {
              String userName =
                  (null != mailDetailsMap.get("userName")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("userName").toString())
                      ? mailDetailsMap.get("userName").toString()
                      : "There!");
              String requested_date =
                  (null != mailDetailsMap.get("createdDate")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("createdDate").toString())
                      ? mailDetailsMap.get("createdDate").toString()
                      : "");
              List<String> service_description =
                  (List<String>)
                      (null != mailDetailsMap.get("serviceDesc")
                          ? mailDetailsMap.get("serviceDesc")
                          : new ArrayList<String>());
              String other_details =
                  (null != mailDetailsMap.get("otherDtls")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("otherDtls").toString())
                      ? mailDetailsMap.get("otherDtls").toString()
                      : "");

              String templateName =
                  mailProps.get("replad.new.service.creation.email.template.name");
              output =
                  renderServiceCreationEmail(
                      userName, requested_date, service_description, other_details, templateName);
              //														System.out.println("Email Body-->"+output);
              break;
            }
          case "guestServiceRequest":
            {
              String userName =
                  (null != mailDetailsMap.get("userName")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("userName").toString())
                      ? mailDetailsMap.get("userName").toString()
                      : "There!");
              String requested_date =
                  (null != mailDetailsMap.get("requested_date")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("requested_date").toString())
                      ? mailDetailsMap.get("requested_date").toString()
                      : "");
              String address =
                  (null != mailDetailsMap.get("address")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("address").toString())
                      ? mailDetailsMap.get("address").toString()
                      : "Not Provided");
              String service_details =
                  (null != mailDetailsMap.get("service_details")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("service_details").toString())
                      ? mailDetailsMap.get("service_details").toString()
                      : "Not Available");
              String other_details =
                  (null != mailDetailsMap.get("other_details")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("other_details").toString())
                      ? mailDetailsMap.get("other_details").toString()
                      : "");
              String service_charges =
                  (null != mailDetailsMap.get("service_charges")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("service_charges").toString())
                      ? mailDetailsMap.get("service_charges").toString()
                      : "0");
              String discount =
                  (null != mailDetailsMap.get("discount")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("discount").toString())
                      ? mailDetailsMap.get("discount").toString()
                      : "");
              String total_amount =
                  (null != mailDetailsMap.get("total_amount")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("total_amount").toString())
                      ? mailDetailsMap.get("total_amount").toString()
                      : "");
              String service_support_mail_id = "", service_support_number = "";
              Map<String, String> supportDetailsMap = getSupportContactDetails();
              if (null != supportDetailsMap) {
                service_support_mail_id =
                    (null != supportDetailsMap.get("supportEmailId")
                            && StringUtilities.isNotBlank(
                                supportDetailsMap.get("supportEmailId").toString())
                        ? supportDetailsMap.get("supportEmailId").toString()
                        : "");
                service_support_number =
                    (null != supportDetailsMap.get("supportContactNumber")
                            && StringUtilities.isNotBlank(
                                supportDetailsMap.get("supportContactNumber").toString())
                        ? supportDetailsMap.get("supportContactNumber").toString()
                        : "");
              }
              String templateName =
                  mailProps.get("replad.guest.service.creation.email.template.name");
              output =
                  renderGuestServiceEmail(
                      userName,
                      requested_date,
                      address,
                      service_details,
                      other_details,
                      service_charges,
                      discount,
                      total_amount,
                      service_support_mail_id,
                      service_support_number,
                      templateName);
              //														System.out.println("Email Body-->"+output);
              break;
            }
          case "userPromotionCoupon":
            {
              String userName =
                  (null != mailDetailsMap.get("userName")
                          && StringUtilities.isNotBlank(mailDetailsMap.get("userName").toString())
                      ? mailDetailsMap.get("userName").toString()
                      : "There!");
              String coupon_code =
                  (null != mailDetailsMap.get("coupon_code")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("coupon_code").toString())
                      ? mailDetailsMap.get("coupon_code").toString()
                      : "");
              String promotion_start_date =
                  (null != mailDetailsMap.get("promotion_start_date")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("promotion_start_date").toString())
                      ? mailDetailsMap.get("promotion_start_date").toString()
                      : "");
              String promotion_end_date =
                  (null != mailDetailsMap.get("promotion_end_date")
                          && StringUtilities.isNotBlank(
                              mailDetailsMap.get("promotion_end_date").toString())
                      ? mailDetailsMap.get("promotion_end_date").toString()
                      : "");
              String promotion_email = "", promotion_number = "";
              Map<String, String> promotionDetailsMap = getPromotionContactDetails();
              if (null != promotionDetailsMap) {
                promotion_email =
                    (null != promotionDetailsMap.get("promotion_email")
                            && StringUtilities.isNotBlank(
                                promotionDetailsMap.get("promotion_email").toString())
                        ? promotionDetailsMap.get("promotion_email").toString()
                        : "");
                promotion_number =
                    (null != promotionDetailsMap.get("promotion_number")
                            && StringUtilities.isNotBlank(
                                promotionDetailsMap.get("promotion_number").toString())
                        ? promotionDetailsMap.get("promotion_number").toString()
                        : "");
              }
              String templateName =
                  mailProps.get("replad.register.user.promotion.coupon.email.template.name");
              output =
                  renderUserPromotionCouponEmail(
                      userName,
                      coupon_code,
                      promotion_start_date,
                      promotion_end_date,
                      promotion_email,
                      promotion_number,
                      templateName);
              System.out.println("Email Body-->" + output);
              break;
            }

          default:
            break;
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    return output;
  }