Package com.agiletec.plugins.jpuserreg.aps.system.services.userreg.model

Examples of com.agiletec.plugins.jpuserreg.aps.system.services.userreg.model.Template


    Map<String, Template> templates = new HashMap<String, Template>();
    List<Element> templateElements = parentElem.getChildren(TEMPLATE);
    Iterator<Element> it = templateElements.iterator();
    while (it.hasNext()) {
      Element templateElem = it.next();
      Template template = new Template();
      String langCode = templateElem.getAttributeValue(TEMPLATE_LANG_ATTR);
      template.setSubject(templateElem.getChildText(TEMPLATE_SUBJECT_CHILD));
      template.setBody(templateElem.getChildText(TEMPLATE_BODY_CHILD));
      templates.put(langCode, template);
    }
    return templates;
  }
View Full Code Here


  private void addTemplateElements(Element parent, Map<String, Template> templates) {
    Iterator<Entry<String, Template>> templatesIter = templates.entrySet().iterator();
    while (templatesIter.hasNext()) {
      Element templateElement = new Element(TEMPLATE);
      Entry<String, Template> current = templatesIter.next();
      Template template = current.getValue();
     
      templateElement.setAttribute(TEMPLATE_LANG_ATTR, current.getKey());
     
      Element subjectElem = new Element(TEMPLATE_SUBJECT_CHILD);
      subjectElem.addContent(new CDATA(template.getSubject()));
      templateElement.addContent(subjectElem);
     
      Element bodyElem = new Element(TEMPLATE_BODY_CHILD);
      bodyElem.addContent(new CDATA(template.getBody()));
      templateElement.addContent(bodyElem);
     
      parent.addContent(templateElement);
    }
  }
View Full Code Here

  private void sendAlert(Map<String, Template> templates, Map<String, String> params, IUserProfile profile) throws ApsSystemException {
    IUserRegConfig config = this.getConfig();
   
    String[] eMail = { this.getFieldValue(profile, SystemConstants.USER_PROFILE_ATTRIBUTE_ROLE_MAIL) };
    Template template = null;
    String langCode = this.getFieldValue(profile, JpUserRegSystemConstants.ATTRIBUTE_ROLE_LANGUAGE);
    if (langCode!=null) {
      template = templates.get(langCode);
    }
    if (template==null) {
      template = templates.get(this.getLangManager().getDefaultLang().getCode());
    }
    String subject = template.getSubject();
    String text = this.replaceParams(template.getBody(), params);
    this.getMailManager().sendMail(text, subject, eMail, null, null, config.getEMailSenderCode());
  }
View Full Code Here

  private void checkTemplates(Map<String, Template> templates, String fieldName) {
    Iterator<Lang> langs = this.getLangManager().getLangs().iterator();
    while (langs.hasNext()) {
      Lang lang = langs.next();
      Template template = templates.get(lang.getCode());
      if (template==null) {
        this.addFieldError(fieldName, this.getText("jpuserreg.errors.templates.notValued", new String[] { this.getText(fieldName), lang.getDescr() }));
      } else {
        String subject = template.getSubject();
        if (subject==null || subject.trim().length()==0) {
          this.addFieldError(fieldName, this.getText("jpuserreg.errors.templates.subject.notValued", new String[] { this.getText(fieldName), lang.getDescr() }));
        }
        String body = template.getBody();
        if (body==null || body.trim().length()==0) {
          this.addFieldError(fieldName, this.getText("jpuserreg.errors.templates.body.notValued", new String[] { this.getText(fieldName), lang.getDescr() }));
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpuserreg.aps.system.services.userreg.model.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.