Examples of MailService


Examples of org.exoplatform.services.mail.MailService

        public void execute(Event<UIForgetPassword> event) throws Exception {
            UIForgetPassword uiForm = event.getSource();
            UILogin uilogin = uiForm.getParent();
            WebuiRequestContext requestContext = event.getRequestContext();
            PortalRequestContext portalContext = PortalRequestContext.getCurrentInstance();
            MailService mailSrc = uiForm.getApplicationComponent(MailService.class);
            OrganizationService orgSrc = uiForm.getApplicationComponent(OrganizationService.class);
            String userName = uiForm.getUIStringInput(Username).getValue();
            String email = uiForm.getUIStringInput(Email).getValue();
            uiForm.reset();

            User user = null;

            String tokenId = null;

            // User provided his username
            if (userName != null) {
                user = orgSrc.getUserHandler().findUserByName(userName);
                if (user == null) {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.user-not-exist", null));
                    return;
                }
            }

            // User provided his email address
            if (user == null && email != null) {
                Query query = new Query();
                // Querying on email won't work. PLIDM-12
                // Note that querying on email is inefficient as it loops over all users...
                query.setEmail(email);
                PageList<User> users = orgSrc.getUserHandler().findUsers(query);
                if (users.getAll().size() > 0) {
                    user = users.getAll().get(0);
                } else {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.email-not-exist", null));
                    return;
                }
            }

            email = user.getEmail();

            // Create token
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
            Credentials credentials = new Credentials(user.getUserName(), "");
            tokenId = tokenService.createToken(credentials);

            String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

            ResourceBundle res = requestContext.getApplicationResourceBundle();
            String headerMail = "headermail";
            String footerMail = "footer";
            try {
                headerMail = res.getString(uiForm.getId() + ".mail.header") + "\n\n"
                        + res.getString(uiForm.getId() + ".mail.user") + user.getUserName() + "\n"
                        + res.getString(uiForm.getId() + ".mail.link");
                footerMail = "\n\n\n" + res.getString(uiForm.getId() + ".mail.footer");
            } catch (MissingResourceException e) {
                log.error(e.getMessage(), e);
            }
            HttpServletRequest request = portalContext.getRequest();
            String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
            String activeLink = host + requestContext.getRequestContextPath() + "/public/" + portalName + "?"
                    + ComponentURL.PORTAL_COMPONENT_ID + "=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
                    + tokenId;
            String mailText = headerMail + "\n" + activeLink + footerMail;
            try {
                mailSrc.sendMessage(res.getString("UIForgetPassword.mail.from"), email,
                        res.getString("UIForgetPassword.mail.subject"), mailText);
            } catch (Exception e) {
                requestContext.getUIApplication().addMessage(
                        new ApplicationMessage("UIForgetPassword.msg.send-mail-fail", null));
                requestContext.addUIComponentToUpdateByAjax(uilogin);
View Full Code Here

Examples of org.exoplatform.services.mail.MailService

        public void execute(Event<UIForgetPassword> event) throws Exception {
            UIForgetPassword uiForm = event.getSource();
            UILogin uilogin = uiForm.getParent();
            WebuiRequestContext requestContext = event.getRequestContext();
            PortalRequestContext portalContext = PortalRequestContext.getCurrentInstance();
            MailService mailSrc = uiForm.getApplicationComponent(MailService.class);
            OrganizationService orgSrc = uiForm.getApplicationComponent(OrganizationService.class);
            String userName = uiForm.getUIStringInput(Username).getValue();
            String email = uiForm.getUIStringInput(Email).getValue();
            uiForm.reset();

            User user = null;

            String tokenId = null;

            // User provided his username
            if (userName != null) {
                user = orgSrc.getUserHandler().findUserByName(userName, UserStatus.ANY);
                if (user == null) {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.user-not-exist", null));
                    return;
                } else if (!user.isEnabled()) {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.user-is-disabled", null));
                    return;
                }
            }

            // User provided his email address
            if (user == null && email != null) {
                Query query = new Query();
                // Querying on email won't work. PLIDM-12
                // Note that querying on email is inefficient as it loops over all users...
                query.setEmail(email);
                ListAccess<User> users = orgSrc.getUserHandler().findUsersByQuery(query, UserStatus.ANY);
                if (users == null || users.getSize() == 0) {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.email-not-exist", null));
                    return;
                } else if (users.getSize() == 1) {
                    user = users.load(0, 1)[0];
                    if (!user.isEnabled()) {
                        requestContext.getUIApplication().addMessage(
                                new ApplicationMessage("UIForgetPassword.msg.user-is-disabled", null));
                        return;
                    }
                }
            }

            email = user.getEmail();

            // Create token
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
            Credentials credentials = new Credentials(user.getUserName(), "");
            tokenId = tokenService.createToken(credentials);

            String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

            ResourceBundle res = requestContext.getApplicationResourceBundle();
            String headerMail = "headermail";
            String footerMail = "footer";
            try {
                headerMail = res.getString(uiForm.getId() + ".mail.header") + "\n\n"
                        + res.getString(uiForm.getId() + ".mail.user") + user.getUserName() + "\n"
                        + res.getString(uiForm.getId() + ".mail.link");
                footerMail = "\n\n\n" + res.getString(uiForm.getId() + ".mail.footer");
            } catch (MissingResourceException e) {
                log.error(e.getMessage(), e);
            }
            HttpServletRequest request = portalContext.getRequest();
            String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
            String activeLink = host + requestContext.getRequestContextPath() + "/public/" + portalName + "?"
                    + ComponentURL.PORTAL_COMPONENT_ID + "=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
                    + tokenId;
            String mailText = headerMail + "\n" + activeLink + footerMail;
            try {
                mailSrc.sendMessage(res.getString("UIForgetPassword.mail.from"), email,
                        res.getString("UIForgetPassword.mail.subject"), mailText);
            } catch (Exception e) {
                requestContext.getUIApplication().addMessage(
                        new ApplicationMessage("UIForgetPassword.msg.send-mail-fail", null));
                requestContext.addUIComponentToUpdateByAjax(uilogin);
View Full Code Here

Examples of org.exoplatform.services.mail.MailService

         UIForgetPassword uiForm = event.getSource();
         UILogin uilogin = uiForm.getParent();
         WebuiRequestContext requestContext = event.getRequestContext();
         PortalRequestContext portalContext = PortalRequestContext.getCurrentInstance();
         String url = portalContext.getRequest().getRequestURL().toString();
         MailService mailSrc = uiForm.getApplicationComponent(MailService.class);
         OrganizationService orgSrc = uiForm.getApplicationComponent(OrganizationService.class);
         String userName = uiForm.getUIStringInput(Username).getValue();
         String email = uiForm.getUIStringInput(Email).getValue();
         uiForm.reset();
                 
         User user = null;

         String tokenId = null;
        
         // User provided his username
         if (userName != null)
         {
            user = orgSrc.getUserHandler().findUserByName(userName);
            if (user == null)
            {
               requestContext.getUIApplication().addMessage(
                  new ApplicationMessage("UIForgetPassword.msg.user-not-exist", null));
               return;
            }
         }
        
         // User provided his email address
         if (user == null && email != null)
         {
            Query query = new Query();
            // Querying on email won't work. PLIDM-12
            // Note that querying on email is inefficient as it loops over all users...
            query.setEmail(email);
            PageList<User> users = orgSrc.getUserHandler().findUsers(query);
            if (users.getAll().size() > 0)
            {
              user = users.getAll().get(0);
            }
            else
            {
               requestContext.getUIApplication().addMessage(
                  new ApplicationMessage("UIForgetPassword.msg.email-not-exist", null));
               return;
            }
         }
        
         email = user.getEmail();

         // Create token
         RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
         Credentials credentials = new Credentials(user.getUserName(), "");
         tokenId = tokenService.createToken(credentials);

         String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

         ResourceBundle res = requestContext.getApplicationResourceBundle();
         String headerMail = "headermail";
         String footerMail = "footer";
         try
         {
            headerMail =
               res.getString(uiForm.getId() + ".mail.header") + "\n\n" + res.getString(uiForm.getId() + ".mail.user")
                  + user.getUserName() + "\n"+ res.getString(uiForm.getId() + ".mail.link");
            footerMail = "\n\n\n" + res.getString(uiForm.getId() + ".mail.footer");
         }
         catch (MissingResourceException e)
         {
            e.printStackTrace();
         }
         String host = url.substring(0, url.indexOf(requestContext.getRequestContextPath()));
         String activeLink = host + requestContext.getRequestContextPath() + "/public/" + portalName
               + "?portal:componentId=UIPortal&portal:action=RecoveryPasswordAndUsername&tokenId="
               + tokenId;
         String mailText = headerMail + "\n" + activeLink + footerMail;
         try
         {
            mailSrc.sendMessage(res.getString("UIForgetPassword.mail.from"), email, res.getString("UIForgetPassword.mail.subject"), mailText);
         }
         catch(Exception e)
         {
            requestContext.getUIApplication().addMessage(
               new ApplicationMessage("UIForgetPassword.msg.send-mail-fail", null));
View Full Code Here

Examples of org.jahia.services.mail.MailService

        settings.setMail_administrator(cfg.getTo());
        settings.setMail_from(cfg.getFrom());
        settings.setMail_paranoia(cfg.getNotificationLevel());

        // restart the mail service
        MailService mailSrv = ServicesRegistry.getInstance().getMailService();
        try {
            mailSrv.stop();
            mailSrv.start();
            request.setAttribute("jahiaDisplayInfo", getMessage(
                            "label.changeSaved"));
        } catch (JahiaException e) {
            logger
                    .error(
View Full Code Here

Examples of org.opencustomer.connector.mail.MailService

                log.info("no mails send: mail server not configurated");
        } else {
            if(log.isDebugEnabled())
                log.debug("sending reminder mail to: " + mail.getRecipients());
           
            new MailService().send(mail);
        }
    }
View Full Code Here

Examples of org.opencustomer.connector.mail.MailService

                            for(EventVO event : events)
                                mail.addEvents(event);
                           
                            if(log.isDebugEnabled())
                                log.debug("sending status mail for: " + user.getUserName());
                            new MailService().send(mail);
                        } else {
                            if(log.isDebugEnabled())
                                log.debug("no status mail for " + user.getUserName() + ", no events and no jobs today");
                        }
                    } catch (AddressException e) {
View Full Code Here

Examples of org.openeai.loggingutils.MailService

    Element eDefaultMailService = getDefaultParms().getChild(MAIL_SERVICE_CONFIG);
    if (eDefaultMailService != null) {
      MailServiceConfig mcf = new MailServiceConfig();
      mcf.init(eDefaultMailService);
      try {
        setMailService(new MailService(mcf));
      }
      catch (Exception e) {
        logger.fatal("Error configuring MailService.  Exception: " + e.getMessage(), e);
        throw new EnterpriseConfigurationObjectException(e.getMessage(), e);       
      }
    }

    // Add all attributes as 'Properties'
    try {
      java.util.List attrs = configElement.getAttributes();
      for (int i=0; i<attrs.size(); i++) {
        Attribute attr = (Attribute)attrs.get(i);
        String key = attr.getName();
        String value = attr.getValue();
        logger.debug("ScheduleConfig, Adding " + key + " - " + value);
        addProperty(key, value);
      }

      // Now the Elements.
      java.util.List props = configElement.getChildren();
      for (int i=0; i<props.size(); i++) {
        Element aProp = (Element)props.get(i);
        if (aProp.getName().equals("Commands")) {
          java.util.List defaultAttrs = aProp.getAttributes();
          java.util.List commandElements = aProp.getChildren();
          ArrayList commands = new ArrayList();
          Element eDefaultParms = new Element("DefaultParms");
          // Add default attributes
          for (int l=0; l<defaultAttrs.size(); l++) {
            org.jdom.Attribute anAttr = (org.jdom.Attribute)defaultAttrs.get(l);
            eDefaultParms.setAttribute((org.jdom.Attribute)anAttr.clone());
          }
          // Add default elements
          for (int k=0; k<commandElements.size(); k++) {
            Element eElem = (Element)commandElements.get(k);
            if (eElem.getName().equals("Command")) {
              commands.add(eElem);
            }
            else {
              eDefaultParms.addContent((Element)eElem.clone());
            }
          }
          // Instantiate and add a CommandConfig object for each Command element.
          // ...
          for (int j=0; j<commands.size(); j++) {
            Element eCommand = (Element)commands.get(j);
            CommandConfig aCommandConfig = new CommandConfig();
            aCommandConfig.setAppName(getAppName());
            aCommandConfig.setDefaultParms(eDefaultParms);
            aCommandConfig.init(eCommand);
            String commandType = aCommandConfig.getType();
            String commandClass = aCommandConfig.getClassName();
            String commandName = aCommandConfig.getName();
            String key = "";
            addProperty(commandName, commandClass);
            addCommandConfig(aCommandConfig.getName(), aCommandConfig);
          }
        }
        else if (aProp.getName().equals(RUN_TIME)) {
          // override any defaults and add the Runtimes specific to this Schedule.
          if (getScheduleRuntimes() != null) {
            getScheduleRuntimes().removeAll(getScheduleRuntimes());
          }
          addRuntimes(aProp);         
        }
        else if (aProp.getName().equals(MAIL_SERVICE_CONFIG)) {
          setMailService(null);
          MailServiceConfig mcf = new MailServiceConfig();
          mcf.init(aProp);
          setMailService(new MailService(mcf));
        }
        else {
          String key = aProp.getName();
          String value = aProp.getText();
          logger.debug("Adding " + key + " - " + value);
View Full Code Here

Examples of org.openeai.loggingutils.MailService

      StringBuffer buf = new StringBuffer();
      buf.append("Error in EnterpriseSyncErrorLogger. ");
      buf.append("\n");
      buf.append(emailBody);
      buf.append("\n");
      MailService mailService = new MailService(this.getFromAddr(), this.getToAddr() , "Error in EnterpriseSyncErrorLogger", buf.toString());
      mailService.setMailHost(this.getMailHost());
      mailService.sendMessage();
    }
    catch (Exception exc) {
      logger.info("Error sending email message - " + exc);
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.