Package com.centraview.mail

Examples of com.centraview.mail.MailAccountVO


    try {
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      // build a MailAccountVO
      MailAccountVO accountVO = new MailAccountVO();

      // the owner is always the logged in user
      accountVO.setOwnerID(individualID);

      // account name - required
      String accountName = (String)accountForm.get("accountName");
      if (accountName == null || accountName.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Account Name"));
      }
      accountVO.setAccountName(accountName);

      // server type - "pop3" by default
      String accountType = MailAccountVO.POP3_TYPE;
      if ((String)accountForm.get("serverType") != null) {
        if (((String)accountForm.get("serverType")).equals("imap")) {
          accountType = MailAccountVO.IMAP_TYPE;
        }
      }
      accountVO.setAccountType(accountType);

      // default account - if user has no other accounts,
      // then make this one the default, else not default
      boolean defaultAccount = false;
      int defaultAccountID = remote.getDefaultAccountID(individualID);

      if (defaultAccountID == 0) {
        defaultAccount = true;
      }
      accountVO.setDefaultAccount(defaultAccount);

      // email address - must be a valid InternetAddress
      String emailAddress = (String)accountForm.get("emailAddress");
      if (emailAddress == null) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Email Address"));
      } else if (! CVUtility.isEmailAddressValid(emailAddress)) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.email.invalidAddress", emailAddress));
      }
      accountVO.setEmailAddress(emailAddress);

      // leave on server - false by default
      Boolean leaveOnServerForm = (Boolean)accountForm.get("leaveOnServer");
      boolean leaveOnServer = false;
      if (leaveOnServerForm != null && leaveOnServerForm.booleanValue() == true) {
        leaveOnServer = true;
      }
      accountVO.setLeaveMessagesOnServer(leaveOnServer);

      // user name - required
      String username = (String)accountForm.get("username");
      if (username == null || username.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "User Name (login)"));
      }
      accountVO.setLogin(username);

      // password - required
      String password = (String)accountForm.get("password");
      if (password == null || password.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Password"));
      }
      accountVO.setPassword(password);

      // mail server (POP3 or IMAP) - required
      String mailServer = (String)accountForm.get("mailServer");
      if (mailServer == null || mailServer.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Mail Server Address"));
      }
      accountVO.setMailServer(mailServer);
     
      // reply to - optional
      String replyTo = (String)accountForm.get("replyTo");
      accountVO.setReplyToAddress(replyTo);

      // signature - optional
      String signature = (String)accountForm.get("signature");
      accountVO.setSignature(signature);

      // port - required, must be valid Integer
      Integer smtpPort = (Integer)accountForm.get("port");
      if (smtpPort == null || smtpPort.intValue() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "SMTP Port"));
      }
      accountVO.setSmtpPort(smtpPort.intValue());

      // smtp server - required
      String smtpServer = (String)accountForm.get("smtpServer");
      if (smtpServer == null || smtpServer.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "SMTP Server"));
      }
      accountVO.setSmtpServer(smtpServer);

      Boolean authenticationRequiredForSMTP = (Boolean)accountForm.get("authenticationRequiredForSMTP");
      if (authenticationRequiredForSMTP != null) {
        if (authenticationRequiredForSMTP.booleanValue()) {
          accountVO.setAuthenticationRequiredForSMTP(true);
        } else {
          accountVO.setAuthenticationRequiredForSMTP(false);
        }
      }


      // These are all the default settings for an account. They should not change
      accountVO.setLastFetchedCount(0);
      accountVO.setLastFetchedDate(new java.util.Date());
      accountVO.setLastUID("");
      accountVO.setSupportAccount(false);

      // TODO: implement setForceSecureConnection in the future
      accountVO.setForceSecureConnection(false);

      // TODO: implement setPopRequiredBeforeSMTP in the future
      accountVO.setPopRequiredBeforeSMTP(false);

      // TODO: implement setPopRequiredBeforeSMTP in the future
      accountVO.setPopRequiredBeforeSMTP(false);


      if (! allErrors.isEmpty()) {
        saveErrors(request, allErrors);
        return(mapping.findForward(errorForward));
View Full Code Here


        if (accountIDList.size() > 0) {
          // get the details of each account
          Iterator iter = accountIDList.iterator();
          while (iter.hasNext()) {
            Number accountID = (Number) iter.next();
            MailAccountVO accountVO = mailRemote.getMailAccountVO(accountID.intValue());
            InternetAddress address = new InternetAddress(accountVO.getEmailAddress(), accountVO.getAccountName());
            LabelValueBean accountDetails = new LabelValueBean(address.toString(), accountID.toString());
            accountList.add(accountDetails);
          }
        }
        dynaform.set("accountList", accountList);
View Full Code Here

     
      while (iter.hasNext()) {
        Number accountID = (Number)iter.next();
       
        if (accountID != null && accountID.intValue() > 0) {
          MailAccountVO accountVO = remote.getMailAccountVO(accountID.intValue());
          accountList.add(accountVO);
        }
      }
     
      accountForm.set("accountList", accountList);
View Full Code Here

      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      MailAccountVO accountVO = remote.getMailAccountVO(accountID.intValue());

      accountForm.set("accountName", accountVO.getAccountName());
      accountForm.set("emailAddress", accountVO.getEmailAddress());
      accountForm.set("replyTo", accountVO.getReplyToAddress());
      accountForm.set("serverType", accountVO.getAccountType());
      accountForm.set("mailServer", accountVO.getMailServer());
      accountForm.set("smtpServer", accountVO.getSmtpServer());
      accountForm.set("authenticationRequiredForSMTP", new Boolean(accountVO.isAuthenticationRequiredForSMTP()));
      accountForm.set("username", accountVO.getLogin());
      accountForm.set("password", accountVO.getPassword());
      accountForm.set("port", new Integer(accountVO.getSmtpPort()));
      accountForm.set("leaveOnServer", new Boolean(accountVO.isLeaveMessagesOnServer()));
      accountForm.set("signature", accountVO.getSignature());
    } catch (Exception e) {
      System.out.println("[Exception][EditAccountHandler] Exception thrown in execute(): " + e);
      e.printStackTrace();
      forward = errorForward;
    }
View Full Code Here

      }

      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      MailAccountVO accountVO = remote.getMailAccountVO(accountID.intValue());

      // account name - required
      String accountName = (String)accountForm.get("accountName");
      if (accountName == null || accountName.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Account Name"));
      }
      accountVO.setAccountName(accountName);

      // email address - must be a valid InternetAddress
      String emailAddress = (String)accountForm.get("emailAddress");
      if (emailAddress == null) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Email Address"));
      } else if (! CVUtility.isEmailAddressValid(emailAddress)) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.email.invalidAddress", emailAddress));
      }
      accountVO.setEmailAddress(emailAddress);

      // leave on server - false by default
      Boolean leaveOnServerForm = (Boolean)accountForm.get("leaveOnServer");
      boolean leaveOnServer = false;
      if (leaveOnServerForm != null && leaveOnServerForm.booleanValue() == true) {
        leaveOnServer = true;
      }
      accountVO.setLeaveMessagesOnServer(leaveOnServer);

      // user name - required
      String username = (String)accountForm.get("username");
      if (username == null || username.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "User Name (login)"));
      }
      accountVO.setLogin(username);

      // password - required
      String password = (String)accountForm.get("password");
      if (password == null || password.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Password"));
      }
      accountVO.setPassword(password);

      // mail server (POP3 or IMAP) - required
      String mailServer = (String)accountForm.get("mailServer");
      if (mailServer == null || mailServer.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Mail Server Address"));
      }
      accountVO.setMailServer(mailServer);

      // reply to - optional
      String replyTo = (String)accountForm.get("replyTo");
      accountVO.setReplyToAddress(replyTo);

      // signature - optional
      String signature = (String)accountForm.get("signature");
      accountVO.setSignature(signature);

      // port - required, must be valid Integer
      Integer smtpPort = (Integer)accountForm.get("port");
      if (smtpPort == null || smtpPort.intValue() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "SMTP Port"));
      }
      accountVO.setSmtpPort(smtpPort.intValue());

      // smtp server - required
      String smtpServer = (String)accountForm.get("smtpServer");
      if (smtpServer == null || smtpServer.length() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "SMTP Server"));
      }
      accountVO.setSmtpServer(smtpServer);

      accountVO.setAuthenticationRequiredForSMTP(false);    // set false by default
      Boolean authenticationRequiredForSMTP = (Boolean)accountForm.get("authenticationRequiredForSMTP");
      if (authenticationRequiredForSMTP != null) {
        if (authenticationRequiredForSMTP.booleanValue()) {
          accountVO.setAuthenticationRequiredForSMTP(true);
        }
      }

      if (! allErrors.isEmpty()) {
        saveErrors(request, allErrors);
View Full Code Here

      MailLocal remote = home.create();
      remote.setDataSource(dataSource);

      messageVO.setEmailAccountID(accountID);

      MailAccountVO accountVO = remote.getMailAccountVO(accountID);
      if (accountVO == null) {
        accountVO = new MailAccountVO();
      }
      if (accountVO.getAccountID() != -1) {
        InternetAddress fromAddress = new InternetAddress(accountVO.getEmailAddress(), accountVO.getAccountName());
        messageVO.setFromAddress(fromAddress.toString());
        messageVO.setReplyTo(fromAddress.toString());
        messageVO.setSubject(subject);
        messageVO.setHeaders("");
        messageVO.setContentType(MailMessageVO.HTML_TEXT_TYPE);
        messageVO.setReceivedDate(new java.util.Date());
        if (content != null && content.size() != 0) {
          // content is an arrayList of strings which are the customized messages
          for (int i = 0; i < content.size(); i++) {
            String bodyContent = (String)content.get(i);
            messageVO.setBody(bodyContent);
            // to is an arraylist of corresponding addresses
            String toAddress = (String)to.get(i);
            if (CVUtility.isEmailAddressValid(toAddress)) {
              ArrayList toList = new ArrayList();
              toList.add(toAddress);
              messageVO.setToList(toList);
              try {
                boolean messageSent = remote.sendMessage(accountVO, messageVO);
                if (messageSent) {
                  logger.debug("["+dataSource+"]Successfully Sent Mail Merge to: "+toAddress);
                } else {
                  logger.error("["+dataSource+"]Mail Merge Failed sending message to: "+messageVO.getToList()+", from account: "+accountVO.getAccountID());
                }
              } catch (SendFailedException sfe) {
                logger.debug("["+dataSource+"]Failed sending Mail Merge to: "+toAddress);
                logger.error("[sendPTEmail] Exception thrown.", sfe);
              }
View Full Code Here

TOP

Related Classes of com.centraview.mail.MailAccountVO

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.