Package com.centraview.mail

Examples of com.centraview.mail.Mail


    DynaActionForm accountForm = (DynaActionForm)form;

    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");

    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));
      }
     
      int newAccountID = 0;
      try {
        newAccountID = remote.addEmailAccount(accountVO);
      } catch (MessagingException me) {
        String errorMessage = me.getMessage();
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "Error while creating email account, "+errorMessage));
        saveErrors(request, allErrors);
        return mapping.findForward(errorForward);
View Full Code Here


        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Account ID"));
        return(mapping.findForward(forward));
      }

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

      remote.deleteEmailAccount(individualID, accountID.intValue());
    } catch (Exception e) {
      System.out.println("[Exception][DeleteAccountHandler] Exception thrown in execute(): " + e);
      e.printStackTrace();
    }
    return mapping.findForward(forward);
View Full Code Here

      // Check wheather the User is have any email account set up already.
      // if user as more then one accout we will set the value to true. so that
      // it will not show EMAIL
      // else it will be false
      MailHome home = (MailHome) CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = home.create();
      remote.setDataSource(dataSource);

      int numberOfAccounts = remote.getNumberOfAccountsForUser(individualID);
      boolean emailFlag = false;
      if (numberOfAccounts <= 0) {
        emailFlag = true;
      }
      request.setAttribute("emailDisableFlag", new Boolean(emailFlag));
View Full Code Here

      String savedsearch1 = "";
      String specificentity = "";
      String entitysavedsearch = "";
      if (mergeType.equals("EMAIL")) {
        // collect the Account List and set it to the dynaActionForm.
        Mail mailRemote = mailHome.create();
        mailRemote.setDataSource(dataSource);
        ArrayList accountIDList = mailRemote.getUserAccountList(individualID);
        // also adding delegated accounts
        accountIDList.addAll(mailRemote.getDelegatedAccountList(individualID));
        ArrayList accountList = new ArrayList(); // this, we're sending to the
                                                  // form
        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);
          }
        }
View Full Code Here

    // Setting the Attachments to form.
    emailForm.set("attachmentList", attachments);

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

      // create a MailMessageVO
      MailMessageVO messageVO = new MailMessageVO();

      String from = (String)emailForm.get("from");
      messageVO.setFromAddress(from);
      String replyTo = (String)emailForm.get("replyTo");
      messageVO.setReplyTo(replyTo);

      String subject = (String)emailForm.get("subject");
      if (subject == null || subject.equals("")) {
        messageVO.setSubject("[No Subject] ");
      } else {
        messageVO.setSubject(subject);
      }

      String body = (String)emailForm.get("body");
      if (body == null) {
        body = "";
      }
      messageVO.setBody(body);

      Boolean composeInHTML = (Boolean)emailForm.get("composeInHTML");
      if (composeInHTML.booleanValue()) {
        messageVO.setContentType(MailMessageVO.HTML_TEXT_TYPE);
      } else {
        messageVO.setContentType(MailMessageVO.PLAIN_TEXT_TYPE);
      }

      ArrayList toList = this.parseAddresses((String)emailForm.get("to"));
      if (toList.size() <= 0) {
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
            "error.general.requiredField", "To:"));
      } else {
        messageVO.setToList(toList);
      }

      ArrayList ccList = this.parseAddresses((String)emailForm.get("cc"));
      messageVO.setCcList(ccList);

      ArrayList bccList = this.parseAddresses((String)emailForm.get("bcc"));
      messageVO.setBccList(bccList);

      // TODO: figure out what headers to set when sending mail
      messageVO.setHeaders("");

      messageVO.setReceivedDate(new java.util.Date());

      // Handle attachments - the attachment handler puts a ArrayList
      // This ArrayList contains the list of attached fileIDs.
      // So we'll get that ArrayList, iterate through it, creating a
      // CvFileVO object for each attachment, then add that file VO
      // to the messageVO object which will take care of the rest in
      // the EJB layer. Note that in the future, we'll want to make
      // this better by not saving the attachment list on the session.
      // So if you intend to modify this code, please consult the rest
      // of the team to see if it makes sense to make that change now.
      // Also, if you make a change here, you must make sure the
      // attachment handling code in ForwardHandler reflects your changes.
      if (attachmentFileIDs != null && attachmentFileIDs.size() > 0) {
        CvFileFacade fileRemote = new CvFileFacade();

        for (int i = 0; i < attachmentFileIDs.size(); i++) {
          int fileID = ((Integer)attachmentFileIDs.get(i)).intValue();
          // get the CvFileVO from the EJB layer
          CvFileVO fileVO = fileRemote.getFile(individualID, fileID, dataSource);
          if (fileVO != null) {
            // add this attachment to the messageVO
            messageVO.addAttachedFiles(fileVO);
          }
        } // end while (attachIter.hasNext())
      } // end if (attachmentMap != null && attachmentMap.size() > 0)

      if (!allErrors.isEmpty()) {
        // we encountered error above and built a list of messages,
        // so save the errors to be shown to the users, and quit
        saveErrors(request, allErrors);
        return (mapping.findForward(errorForward));
      }

      try {
        // send the message
        remote.simpleMessage(individualID, messageVO);
        session.removeAttribute("AttachfileList");
      } catch (SendFailedException sfe) {

        String errorMessage = sfe.getMessage();
View Full Code Here

        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Message ID"));
        return(mapping.findForward(forward));
      }

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

      MailMessageVO messageVO = remote.getEmailMessageVO(individualID, messageID.intValue());

      emailForm.set("accountID", new Integer(messageVO.getEmailAccountID()));
      Integer folderID = new Integer(messageVO.getEmailFolderID());
      emailForm.set("folderID", folderID);
     
View Full Code Here

    // Get the mailHome and the dataSource from the JobDataMap
    // start a mail check.
    try
    {
      MailHome mailHome = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail mailremote = mailHome.create();
      mailremote.setDataSource(this.dataSource);
      mailremote.checkAllSupportAccounts();
    } catch (Exception e) {
      logger.error("[run] Exception thrown.", e);
    }
  }
View Full Code Here

    DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
    DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);

    // email portlet
    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
    Mail remote = home.create();
    remote.setDataSource(dataSource);
    ArrayList emailFolders = remote.getHomeFolderList(individualId);
    // this modifier gets stuck right in the html of the "Compose" button
    String emailButtonModifier = "";
    if ((emailFolders == null) || (emailFolders.size() < 1)) {
      emailButtonModifier = "disabled=\"true\"";
    }
View Full Code Here

      HttpSession session = request.getSession(true);
     
      UserObject userObject = (UserObject)session.getAttribute("userobject");
     
      MailHome mailHome = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail mailRemote = (Mail)mailHome.create();
      mailRemote.setDataSource(dataSource);

      Vector accountList = (Vector)mailRemote.getAccountList();
     
      AppSettingsHome appHome = (AppSettingsHome)CVUtility.getHomeObject("com.centraview.administration.applicationsettings.AppSettingsHome","AppSettings");
      AppSettings appRemote = (AppSettings)appHome.create();
      appRemote.setDataSource(dataSource);
     
View Full Code Here

    // "mailAccountListform" defined in struts-config-preference.xml
    DynaActionForm accountForm = (DynaActionForm)form;
   
    try {
      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      ArrayList accountList = new ArrayList();

      ArrayList accountIDList = remote.getUserAccountList(individualID);
      Iterator iter = accountIDList.iterator();
     
      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

TOP

Related Classes of com.centraview.mail.Mail

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.