Package org.apache.struts.action

Examples of org.apache.struts.action.DynaActionForm


    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();

    String returnStatus = "";
    try
    {
      DynaActionForm dynaForm = (DynaActionForm)form;
      HttpSession session = request.getSession();
      session.setAttribute("highlightmodule", "preferences");

      int individualID = 0;
      UserObject userObject = (UserObject)session.getAttribute("userobject");

      if (userObject != null)
      {
        // get current user's individualID
        individualID = userObject.getIndividualID();
      }

      Vector vecleft = new Vector();
      Vector vecright = new Vector();

      PreferenceHome prefHome = (PreferenceHome)CVUtility.getHomeObject("com.centraview.preference.PreferenceHome", "Preference");
      Preference prefRemote = prefHome.create();
      prefRemote.setDataSource(dataSource);
      UserPrefererences up = prefRemote.getUserPreferences(individualID);

      if (up.getEmail().equals("YES"))
        vecright.addElement(new DDNameValue("email", AdminConstantKeys.EMAIL));
      else
        vecleft.addElement(new DDNameValue("email", AdminConstantKeys.EMAIL));
      if (up.getTodaysCalendar().equals("YES"))
        vecright.addElement(new DDNameValue("todayscalendar", AdminConstantKeys.TODAYSCALENDAR));
      else
        vecleft.addElement(new DDNameValue("todayscalendar", AdminConstantKeys.TODAYSCALENDAR));
      if (up.getUnscheduledActivities().equals("YES"))
        vecright.addElement(new DDNameValue("unscheduledactivities", AdminConstantKeys.UNSCHEDULEDACTIVITIES));
      else
        vecleft.addElement(new DDNameValue("unscheduledactivities", AdminConstantKeys.UNSCHEDULEDACTIVITIES));
      if (up.getScheduledOpportunities().equals("YES"))
        vecright.addElement(new DDNameValue("scheduledopportunities", AdminConstantKeys.SCHEDULEDOPPORTUNUITIES));
      else
        vecleft.addElement(new DDNameValue("scheduledopportunities", AdminConstantKeys.SCHEDULEDOPPORTUNUITIES));
      if (up.getProjectTasks().equals("YES"))
        vecright.addElement(new DDNameValue("projecttasks", AdminConstantKeys.PROJECTTASKS));
      else
        vecleft.addElement(new DDNameValue("projecttasks", AdminConstantKeys.PROJECTTASKS));
      if (up.getSupportTickets().equals("YES"))
        vecright.addElement(new DDNameValue("supporttickets", AdminConstantKeys.SUPPORTTICKETS));
      else
        vecleft.addElement(new DDNameValue("supporttickets", AdminConstantKeys.SUPPORTTICKETS));
      if (up.getCompanyNews().equals("YES"))
        vecright.addElement(new DDNameValue("companynews", AdminConstantKeys.COMPANYNEWS));
      else
        vecleft.addElement(new DDNameValue("companynews", AdminConstantKeys.COMPANYNEWS));

      request.setAttribute("vecleft", vecleft);
      request.setAttribute("vecright", vecright);
      dynaForm.set("minutes", up.getHomeRefreshMin());
      dynaForm.set("seconds", up.getHomeRefreshSec());

      request.setAttribute(AdminConstantKeys.PREFERENCEPAGE, "HOME");
      FORWARD_final = FORWARD_homesettingsprofile;
    }
    catch (Exception e)
View Full Code Here


      EmailFacadeHome cfh = (EmailFacadeHome)CVUtility.getHomeObject("com.centraview.email.emailfacade.EmailFacadeHome", "EmailFacade");
      EmailFacade remote = (EmailFacade)cfh.create();
      remote.setDataSource(dataSource);

      RuleDetails ruledetails = remote.getRuleDetails(ruleID);
      DynaActionForm dynaForm = (DynaActionForm)form;
      dynaForm.set("RuleID", ruledetails.getRuleID());
      dynaForm.set("AccountID", ruledetails.getAccountID());
      dynaForm.set("name", ruledetails.getName());
      dynaForm.set("description", ruledetails.getDescription());
      dynaForm.set("enabled", ruledetails.getEnabled());
      dynaForm.set("colA", ruledetails.getcolA());
      dynaForm.set("colB", ruledetails.getcolB());
      dynaForm.set("colC", ruledetails.getcolC());
      dynaForm.set("colD", ruledetails.getcolD());
      dynaForm.set("movemessageto", ruledetails.getMovemessageto());
      dynaForm.set("movemessagetofolder", ruledetails.getMovemessagetofolder());
      dynaForm.set("markasread", ruledetails.getMarkasread());
      dynaForm.set("deletemessage", ruledetails.getDeleteMessage());
      HttpSession session = request.getSession(true);
      FolderList fl = (FolderList)session.getAttribute("folderlist");
      AccountDetail ad = (AccountDetail)fl.get(new Integer(ruledetails.getAccountID()));

      ArrayList al = ad.getFolderList();
View Full Code Here

  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
  {
    String forwardPage = "relatedInfoBottom"; // by default, this is the page to forward to

    // get the URL parameters from the RelatedInfoListForm FormBean object
    DynaActionForm relatedInfoListForm = (DynaActionForm)form;
    HttpSession session = request.getSession(true);
    String sessionListFor = (String)session.getAttribute("sessionRelatedListFor");
    try {
      // listType is the type of the list being shown, ie "Address",
      // "Individual", "Notes" etc
      String riListType = (String)relatedInfoListForm.get("riListType");
      // listFor is the type of record in the top frame, ie "Entity",
      // "Individual", "Opportunity"
      String listFor = (String)relatedInfoListForm.get("listFor");
      // If we changed listfors we need to clear out whatever the
      // form gave us.  For now only if we are currently looking at
      // Entity or Individual, because otherwise it is set on the JSP
      session.setAttribute("sessionRelatedListFor", listFor);

      if (!listFor.equals(sessionListFor) && (listFor.equals("Entity") || listFor.equals("Individual"))) {
        riListType = "";
      }

      if (riListType.equals("")) {
        // set the type of list to show in the bottom frame, depending
        // on what type of record is in the top frame. Default to Individuals
        if (listFor.equals("Individual")) {
          riListType = "Activity";
        } else if (listFor.equals("Opportunity")){
          riListType = "Proposal";
        } else {
          riListType = "Individual";
        }
      } else if (riListType.equals("BottomIndividual")) {
        riListType = "Individual";
      }

      // After performing the logic in the DeleteHanlder, we are generate a new request for the list
      // So we will not be carrying the old error. So that we will try to collect the error from the Session variable
      // Then destory it after getting the Session value
      if (session.getAttribute("listErrorMessage") != null) {
        ActionErrors allErrors = (ActionErrors)session.getAttribute("listErrorMessage");
        saveErrors(request, allErrors);
        session.removeAttribute("listErrorMessage");
      }

      relatedInfoListForm.set("riListType", riListType);
      // recordID is the ID of the record in the top frame
      Integer recordID = (Integer)relatedInfoListForm.get("recordId");
      // record name is the title or name of the record in the top frame.
      // It is show in the header of the bottom frame
      String recordName = (String)relatedInfoListForm.get("recordName");
      // parentId is the ID of the parent record for Individual it is the EntityId for
      // Entity it is the marketing list Id.
      Integer parentId = (Integer)relatedInfoListForm.get("parentId");
      // parent name is the entity name for individual it is invalid for entity
      String parentName = (String)relatedInfoListForm.get("parentName");
      // now that we got the information from the FormBean, set
      // each variable as a request attribute so that the handlers
      // can all access this data on the request
      request.setAttribute("listType", riListType);
      request.setAttribute("listFor", listFor);
      request.setAttribute("recordID", recordID);
      request.setAttribute("recordName", recordName);
      request.setAttribute("parentId", parentId);
      request.setAttribute("parentName", parentName);

      // generate the dropdown at the top of the frame, based on
      // a method in this class. Then set a request attribute
      // that will contain this data (as a HashMap)
      ArrayList dropdownCollection = this.getDropdownMap(listFor);
      relatedInfoListForm.set("dropdownCollection", dropdownCollection);

      ArrayList buttonList = this.setupButtons(listFor, riListType, recordID, recordName, parentId, parentName);
      request.setAttribute("buttonList", buttonList);
     
      // ok, now forward to the appripriate handler based on the
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = ".view.email.compose";

    // "composeMailForm", defined in struts-config-email.xml
    DynaActionForm emailForm = (DynaActionForm)form;

    try {
      // figure out if we're 1. showing the FCKEditor and 2. setting content type == HTML
      UserPrefererences userPref= userObject.getUserPref();
      boolean composeInHTML = false;
      if ((userPref.getContentType()).equals("HTML")) {
        composeInHTML = true;
      }
      emailForm.set("composeInHTML", new Boolean(composeInHTML));

      Mail remote = (Mail)CVUtility.setupEJB("Mail", "com.centraview.mail.MailHome", dataSource);

      ArrayList accountIDList = remote.getUserAccountList(individualID);

      // also adding delegated accounts 
      accountIDList.addAll(remote.getDelegatedAccountList(individualID));

      ArrayList accountList = new ArrayList();    // this, we're sending to the form
      if (accountIDList.size() > 0) {
        MailUtils mailUtils = new MailUtils();
        // get the details of each account
        Iterator iter = accountIDList.iterator();
        while (iter.hasNext()) {
          Number accountID = (Number)iter.next();
          MailAccountVO accountVO = remote.getMailAccountVO(accountID.intValue());
          HashMap accountDetails = new HashMap();
          accountDetails.put("accountID", new Integer(accountID.intValue()));
          accountDetails.put("accountName", new InternetAddress(accountVO.getEmailAddress(), mailUtils.stripInvalidCharsFromName(accountVO.getIndividualName())));
          accountList.add(accountDetails);
        }
      }
      emailForm.set("accountList", accountList);

      int defaultAccountID = remote.getDefaultAccountID(individualID);

      ArrayList templateList = remote.getTemplateList(individualID, defaultAccountID);
      emailForm.set("templateList", templateList);

      if (defaultAccountID > 0) {
        MailAccountVO accountVO = remote.getMailAccountVO(defaultAccountID);
        StringBuffer body = new StringBuffer((String)emailForm.get("body"));
        String signature = (String)accountVO.getSignature();
        if (signature != null && signature.length() > 0) {
          signature = "\n\n-- \n" + signature;
          if (composeInHTML) {
            signature = signature.replaceAll("\n","<BR>");
          }
         
          // Don't append the signature if we're using a saved template
          // (it already has the signature appended).
          Boolean composeFromTemplate = (Boolean)request.getAttribute("composeFromTemplate");
          Boolean saveTemplate = (Boolean)request.getAttribute("saveTemplate");
          Boolean saveDraft = (Boolean)request.getAttribute("saveDraft");
          if (composeFromTemplate == null || composeFromTemplate.booleanValue() == false) {
            if (saveTemplate == null || saveTemplate.booleanValue() == false) {
              if (saveDraft == null || saveDraft.booleanValue() == false) {
                body.append(signature);
              }
            }
          }
        }
        emailForm.set("body", body.toString());
      }

    }catch(Exception e){
      System.out.println("[Exception][ComposeHandler] Exception thrown in execute(): " + e.toString());
      e.printStackTrace();
View Full Code Here

    boolean syncAsPrivate = (prefValue != null && prefValue.equals("YES")) ? true : false;

    int individualID = userObject.getIndividualID();    // logged in user

    // "sycnContactForm", defined in struts-config-sync.xml
    DynaActionForm contactForm = (DynaActionForm)form;
    SyncUtils syncUtils = new SyncUtils();

    try
    {
      // check to see if CompanionLink Agent has signed in
      if (syncUtils.checkSession(userObject, contactForm) == false)
      {
        writer.print("FAIL: You are not logged in.");
        return(null);
      }
     
      // decode all characters that are encoded by CompanionLink Agent
      contactForm = syncUtils.parseSpecialChars(contactForm);

      String firstName = (String)contactForm.get("firstName");
      String lastName = (String)contactForm.get("lastName");
      // now validate the form data
      if (firstName == null || firstName.equals(""))
      {
        if (lastName == null || lastName.equals(""))
        {
          return(null);
        }
      }

      String primaryContact = (String)contactForm.get("primaryContact");
      if (! primaryContact.equals("Yes") && ! primaryContact.equals("No"))
      {
        return(null);
      }

      // if CompanionLink Agent did not send us an Entity name,
      // then set the entity name equal to the individual's name
      String companyName = (String)contactForm.get("companyName");
      if (companyName == null || companyName.equals(""))
      {
        companyName = firstName + " " + lastName;
      }

      ContactFacadeHome cfh = (ContactFacadeHome)CVUtility.getHomeObject("com.centraview.contact.contactfacade.ContactFacadeHome","ContactFacade");
      ContactFacade remote = (ContactFacade)cfh.create();
      remote.setDataSource(dataSource);
     
      SyncFacadeHome syncHome = (SyncFacadeHome)CVUtility.getHomeObject("com.centraview.syncfacade.SyncFacadeHome", "SyncFacade");
      com.centraview.syncfacade.SyncFacade sfremote = (com.centraview.syncfacade.SyncFacade)syncHome.create();
      sfremote.setDataSource(dataSource);

      // this will represent the new Individual we are creating
      IndividualVO individualVO = new IndividualVO();

      individualVO.setFirstName(firstName);
      individualVO.setMiddleName((String)contactForm.get("MI"));
      individualVO.setLastName(lastName);
      individualVO.setTitle((String)contactForm.get("title"));
      individualVO.setIsPrimaryContact(primaryContact);
      individualVO.setContactType(2);   // contactType 2 is "Individual"

      AddressVO primaryAddress = new AddressVO();

      primaryAddress.setIsPrimary("YES");
      primaryAddress.setStreet1((String)contactForm.get("street1"));
      primaryAddress.setStreet2((String)contactForm.get("street2"));
      primaryAddress.setCity((String)contactForm.get("city"));
      primaryAddress.setStateName((String)contactForm.get("state"));
      primaryAddress.setZip((String)contactForm.get("zipCode"));
      primaryAddress.setCountryName((String)contactForm.get("country"));
     
      individualVO.setPrimaryAddress(primaryAddress);

      // save email address
      String email = (String)contactForm.get("email");
      if (email != null && ! email.equals(""))
      {
        MethodOfContactVO emailVO = new MethodOfContactVO();
        emailVO.setContent(email);
        emailVO.setMocType(Constants.MOC_EMAIL);   // hardcoded to "Email" type
        emailVO.setIsPrimary("YES")// always set as the primary email address
        individualVO.setMOC(emailVO);
      }

      // set workPhone
      String workPhone = (String)contactForm.get("workPhone");
      if (workPhone != null && (! workPhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO workPhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String workPhoneExt = (String)contactForm.get("workPhoneExt");
        if (workPhoneExt != null && ! workPhoneExt.equals(""))
        {
          workPhone = workPhone + "EXT" + workPhoneExt;
        }
        workPhoneMocVO.setContent(workPhone);
        workPhoneMocVO.setSyncAs("Work");
        workPhoneMocVO.setMocType(Constants.MOC_WORK);   // hardcoded to "Phone" type

        individualVO.setMOC(workPhoneMocVO);
      }

      // set homePhone
      String homePhone = (String)contactForm.get("homePhone");
      if (homePhone != null && (! homePhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO homePhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String homePhoneExt = (String)contactForm.get("homePhoneExt");
        if (homePhoneExt != null && ! homePhoneExt.equals(""))
        {
          homePhone = homePhone + "EXT" + homePhoneExt;
        }
        homePhoneMocVO.setContent(homePhone);
        homePhoneMocVO.setSyncAs("Home");
        homePhoneMocVO.setMocType(Constants.MOC_HOME);   // hardcoded to "Phone" type

        individualVO.setMOC(homePhoneMocVO);
      }

      // set faxPhone
      String faxPhone = (String)contactForm.get("faxPhone");
      if (faxPhone != null && (! faxPhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO faxPhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String faxPhoneExt = (String)contactForm.get("faxPhoneExt");
        if (faxPhoneExt != null && ! faxPhoneExt.equals(""))
        {
          faxPhone = faxPhone + "EXT" + faxPhoneExt;
        }
        faxPhoneMocVO.setContent(faxPhone);
        faxPhoneMocVO.setSyncAs("Fax");
        faxPhoneMocVO.setMocType(Constants.MOC_FAX);   // hardcoded to "Fax" type

        individualVO.setMOC(faxPhoneMocVO);
      }

      // set otherPhone
      String otherPhone = (String)contactForm.get("otherPhone");
      if (otherPhone != null && (! otherPhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO otherPhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String otherPhoneExt = (String)contactForm.get("otherPhoneExt");
        if (otherPhoneExt != null && ! otherPhoneExt.equals(""))
        {
          otherPhone = otherPhone + "EXT" + otherPhoneExt;
        }
        otherPhoneMocVO.setContent(otherPhone);
        otherPhoneMocVO.setSyncAs("Other");
        otherPhoneMocVO.setMocType(Constants.MOC_OTHER);   // hardcoded to "Phone" type

        individualVO.setMOC(otherPhoneMocVO);
      }

      // set mainPhone
      String mainPhone = (String)contactForm.get("mainPhone");
      if (mainPhone != null && (! mainPhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO mainPhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String mainPhoneExt = (String)contactForm.get("mainPhoneExt");
        if (mainPhoneExt != null && ! mainPhoneExt.equals(""))
        {
          mainPhone = mainPhone + "EXT" + mainPhoneExt;
        }
        mainPhoneMocVO.setContent(mainPhone);
        mainPhoneMocVO.setSyncAs("Main");
        mainPhoneMocVO.setMocType(Constants.MOC_MAIN);   // hardcoded to "Phone" type

        individualVO.setMOC(mainPhoneMocVO);
      }

      // set pagerPhone
      String pagerPhone = (String)contactForm.get("pagerPhone");
      if (pagerPhone != null && (! pagerPhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO pagerPhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String pagerPhoneExt = (String)contactForm.get("pagerPhoneExt");
        if (pagerPhoneExt != null && ! pagerPhoneExt.equals(""))
        {
          pagerPhone = pagerPhone + "EXT" + pagerPhoneExt;
        }
        pagerPhoneMocVO.setContent(pagerPhone);
        pagerPhoneMocVO.setSyncAs("Pager");
        pagerPhoneMocVO.setMocType(Constants.MOC_PAGER);   // hardcoded to "Phone" type

        individualVO.setMOC(pagerPhoneMocVO);
      }

      // set mobilePhone
      String mobilePhone = (String)contactForm.get("mobilePhone");
      if (mobilePhone != null && (! mobilePhone.equals("")))
      {
        // create new MocVO object
        MethodOfContactVO mobilePhoneMocVO = new MethodOfContactVO();
       
        // set properties
        String mobilePhoneExt = (String)contactForm.get("mobilePhoneExt");
        if (mobilePhoneExt != null && ! mobilePhoneExt.equals(""))
        {
          mobilePhone = mobilePhone + "EXT" + mobilePhoneExt;
        }
        mobilePhoneMocVO.setContent(mobilePhone);
        mobilePhoneMocVO.setSyncAs("Mobile");
        mobilePhoneMocVO.setMocType(Constants.MOC_MOBILE);   // hardcoded to "Mobile" type

        individualVO.setMOC(mobilePhoneMocVO);
      }

      // get notes field
      String notes = (String)contactForm.get("notes");
      boolean addNote = (notes != null && notes.length() > 0) ? true : false;

      // first, we need to get the entityID based on the CompanyName
      // passed into the form. If the entity name doesn't match something
      // in the database, then set a flag to create a new entity.
View Full Code Here

    long start = 0L;
    if (logger.isDebugEnabled()) {
      start = System.currentTimeMillis();
    }
   
    DynaActionForm emailForm = (DynaActionForm)form;
    Integer accountID = (Integer)emailForm.get("accountID");
   
    HttpSession session = request.getSession(true);
   
    // Check the session for an existing error message (possibly from the delete handler)
    ActionErrors allErrors =
View Full Code Here

    int individualID = userObject.getIndividualID();    // logged in user

    ActionErrors allErrors = new ActionErrors();

    DynaActionForm profileForm = (DynaActionForm)form;

  EmailSettingsHome emailSettingsHome = (EmailSettingsHome)CVUtility.getHomeObject("com.centraview.administration.emailsettings.EmailSettingsHome","EmailSettings");
   
    try {
    EmailSettings emailSettingsRemote = (EmailSettings)emailSettingsHome.create();
    emailSettingsRemote.setDataSource(dataSource);

    // Its a predefined Template for the replying message for the Change Of user Information Information
    EmailTemplateForm userInfoTemplateForm = emailSettingsRemote.getEmailTemplate(AdministrationConstantKeys.EMAIL_TEMPLATE_USER_PROFILE);
    String toAddress = userInfoTemplateForm.getToAddress();
    String fromAddress = userInfoTemplateForm.getFromAddress();
    String replyTo = userInfoTemplateForm.getReplyTo();
    String emailSubject = userInfoTemplateForm.getSubject();
    String emailBody = userInfoTemplateForm.getBody();

    MailMessageVO mailMessage = new MailMessageVO();
    ArrayList toList = new ArrayList();
    toList.add(toAddress);
    mailMessage.setToList(toList);
    mailMessage.setHeaders("Change Of User Information");
    mailMessage.setContentType("text/plain");
    mailMessage.setFromAddress(fromAddress);
    mailMessage.setReplyTo(replyTo);
    mailMessage.setSubject(emailSubject);


    StringBuffer body = new StringBuffer("");
    body.append(emailBody);
    body.append("\n\nUser Information Change Request:\n\n");

    DynaActionForm dynaForm = (DynaActionForm)form;

    String entityName = (String)dynaForm.get("individualName");
    body.append("Individual Name: " + entityName + "\n");

    String title = (String)dynaForm.get("title");
    body.append("Title: " + title + "\n");

    String street1 = (String)dynaForm.get("street1");
    body.append("Street1: " + street1 + "\n");

    String street2 = (String)dynaForm.get("street2");
    body.append("Street2: " + street2 + "\n");

    String city = (String)dynaForm.get("city");
    body.append("City: " + city + "\n");

    String state = (String)dynaForm.get("state");
    body.append("State: " + state + "\n");

    String zipCode = (String)dynaForm.get("zipCode");
    body.append("Zip Code: " + zipCode + "\n");

    String country = (String)dynaForm.get("country");
    body.append("Country: " + country + "\n");

    String mocContent = "";
    String mocTypeName = "";
      if (dynaForm.get("email") != null) {
        mocContent = (dynaForm.get("email") == null) ? "" : (String)dynaForm.get("email");
      body.append("Email: " + mocContent + "\n");
      }

    for(int i=1 ; i<4 ; i++ ){
      mocContent = CVUtility.getMOCContent(dynaForm, i+"");
      int mocType = Integer.parseInt((String)dynaForm.get("mocType"+i));
      mocTypeName = CVUtility.getSyncAs(mocType);
      body.append(mocTypeName+": " + mocContent + "\n");
      }

    body.append("\n\n\nLogin Information Change Request:\n\n");

    Integer userID = (Integer)dynaForm.get("userID");
    body.append("UserID: " + userID.toString() +"\n");

    String username = (String)dynaForm.get("username");
    body.append("Username: " + username +"\n");

    String oldPassword = (String)dynaForm.get("oldPassword");
    body.append("Old Password: " + oldPassword + "\n");

    String newPassword = (String)dynaForm.get("newPassword");
    body.append("New Password: " + newPassword + "\n");

    String newPasswordConf = (String)dynaForm.get("newPasswordConf");
    body.append("Confirm Password: " + newPasswordConf  + "\n");

    body.append("\n\nEnd CentraView Web Request\n");

    mailMessage.setBody(body.toString());
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = ".view.email.newfolder";
    String errorForward = "errorOccurred";
   
    // "newMailFolderForm", defined in struts-config-email.xml
    DynaActionForm emailForm = (DynaActionForm)form;

    try
    {
      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);
     
      // get the parent ID from the form bean
      Integer parentID = (Integer)emailForm.get("parentID");
     
      // now, check the parent ID on the form...
      if (parentID == null || parentID.intValue() <= 0)
      {
        int defaultAccountID = remote.getDefaultAccountID(individualID);
        MailFolderVO folderVO = remote.getPrimaryEmailFolder(defaultAccountID);
        parentID = new Integer(folderVO.getFolderID());
        emailForm.set("parentID", parentID);
        emailForm.set("accountID", new Integer(defaultAccountID));
      }

      // generate the fullPath to the parent folder
      ArrayList fullPathList = (ArrayList)remote.getFolderFullPath(parentID.intValue());
      StringBuffer fullPath = new StringBuffer("");
      if (fullPathList != null)
      {
        Iterator pathIter = fullPathList.iterator();
        while (pathIter.hasNext())
        {
          HashMap folderInfo = (HashMap)pathIter.next();
          fullPath.append("/" + (String)folderInfo.get("name"));
        }
      }
      emailForm.set("fullPath", fullPath.toString());

    }catch(Exception e){
      System.out.println("[Exception][NewFolderHandler] Exception thrown in execute(): " + e);
      e.printStackTrace();
    }
View Full Code Here

    ActionErrors allErrors = new ActionErrors();
    String forward = ".view.common.folderlookup";

    // "folderLookupForm", defined in struts config
    DynaActionForm emailForm = (DynaActionForm)form;

    try {
      // get the folder ID from the form bean
      Integer folderID = (Integer)emailForm.get("folderID");

      // get the actionType from the form bean
      String actionType = (String)emailForm.get("actionType");
      emailForm.set("actionType", actionType);

      // now, check the folder ID on the form...
      if (folderID == null || folderID.intValue() <= 0) {
        // if folder ID is not set on the form, then there is
        // no point in continuing forward. Show user the door. :-)
        allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
            "error.general.requiredField", "Parent Folder ID"));
        return (mapping.findForward(forward));
      }

      String tableName = "cvfolder";
      if (actionType != null && actionType.equals("EMAIL")) {
        tableName = "emailfolder";
      }

      CommonHelperHome home = (CommonHelperHome)CVUtility.getHomeObject(
          "com.centraview.common.helper.CommonHelperHome", "CommonHelper");
      CommonHelper remote = home.create();
      remote.setDataSource(dataSource);

      // get the list of folders that represents the full path
      // to the current folder selected. This will be shown at
      // the top of the screen with navigation
      ArrayList fullPathList = remote.getFolderFullPath(folderID.intValue(), tableName);
      emailForm.set("fullPathList", fullPathList);

      ArrayList subfolderList = remote.getSubFolderList(individualID, folderID.intValue(),
          tableName);

      long curFolderId = 0;
      if (request.getParameter("curFolderID") != null) {
        curFolderId = Long.parseLong(request.getParameter("curFolderID"));
      }

      HashMap hm;
      Iterator it = subfolderList.iterator();
      while (it.hasNext()) {
        hm = (HashMap)it.next();
        Long fID = (Long)hm.get("folderID");

        if (curFolderId == fID.longValue()) {
          it.remove();
        }
      }
      emailForm.set("folderList", subfolderList);

    } catch (Exception e) {
      logger.error("[execute]: Exception", e);
    }
    return (mapping.findForward(forward));
View Full Code Here

    long start = 0L;
    if (logger.isDebugEnabled()) {
      start = System.currentTimeMillis();
    }

    DynaActionForm emailListForm = (DynaActionForm)form;
    Integer folderID = (Integer)emailListForm.get("folderID");
    int currentAccountID = 0;

    MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
    try {
      // check for a valid email account
      Mail mailRemote = home.create();
      mailRemote.setDataSource(dataSource);

      int numberAccounts = mailRemote.getNumberOfAccountsForUser(individualId);

      if (numberAccounts < 1) {
        // if the user has less than 1 mail account
        // set up, then show them the door
        return (mapping.findForward(".view.email.setup"));
      }

      MailFolderVO folderVO;
      if (folderID != null) {
        folderVO = MailUtil.getFolderVO(folderID.intValue(), individualId, dataSource);
      } else {
        folderVO = MailUtil.getFolderVO(0, individualId, dataSource);
      }

      folderID = new Integer(folderVO.getFolderID());
      String folderName = folderVO.getFolderName();
      currentAccountID = folderVO.getEmailAccountID();
      HashMap folderList = mailRemote.getFolderList(currentAccountID);

      MailAccountVO accountVO = mailRemote.getMailAccountVO(currentAccountID);
      emailListForm.set("accountID", new Integer(currentAccountID));

      String accountType = accountVO.getAccountType();
      emailListForm.set("accountType", accountType);

      // This approach dirties the session, try to clean it up a bit.
      Enumeration nameEnum = session.getAttributeNames();
      while (nameEnum.hasMoreElements()) {
        String element = (String)nameEnum.nextElement();
        Object o = session.getAttribute(element);
        if (o instanceof BackgroundMailCheck) {
          if (!((BackgroundMailCheck)o).isAlive()) {
            session.removeAttribute("element");
          }
        }
      }

      /*
       * We check mail every time a user clicks on an IMAP folder. Thread
       * sychronization is taken care of in the EJB layer. We create a unique
       * session variable for each folder so each page knows if it should be
       * refreshing.
       */
      // We create the condition where the page continues to check because on
      // every refresh it doesn't
      // that it just checked. So it does again and again and again... "checked"
      // is to alleviate that.
      String clicked = request.getParameter("clicked");
      String checked = request.getParameter("checked");
      if ((checked == null || !checked.equals("true"))
          && (clicked != null && clicked.equals("true"))) {
        if (accountType.equals(MailAccountVO.IMAP_TYPE)) {
          // First check mailDaemon which will be for first timers
          BackgroundMailCheck mailDaemon = (BackgroundMailCheck)session.getAttribute("mailDaemon");
          if (mailDaemon == null || !mailDaemon.isAlive()) {
            // Then check the indivdual folder daemon
            String daemonName = folderName + "MailCheck";
            mailDaemon = (BackgroundMailCheck)session.getAttribute(daemonName);
            if (mailDaemon == null || !mailDaemon.isAlive()) {
              mailDaemon = new BackgroundMailCheck(daemonName + individualId, individualId,
                  dataSource, folderID.intValue());
              mailDaemon.start();
              session.setAttribute(daemonName, mailDaemon);
              request.setAttribute("checked", "true");
            }
          }
        }
      }
      // We must have to add the FolderName to the request
      // We will use this value from the tag lib.
      // To Identify wheather which folder we are processing
      request.setAttribute("folderName", folderName);

      // populate the moveTO button in Tag Lib
      // we will use this folderList
      request.setAttribute("folderList", folderList);
      request.setAttribute("folderID", folderID);

      emailListForm.set("folderList", folderList);
      emailListForm.set("folderType", folderVO.getFolderType());
      emailListForm.set("folderID", folderID);

      // now, we need to set some stuff up for the folder bar which
      // shows where the user is located within the folder hierarchy
      ArrayList folderPathList = mailRemote.getFolderFullPath(folderID.intValue());
      emailListForm.set("folderPathList", folderPathList);
    } catch (Exception e) {
      logger.error("[execute] Exception thrown.", e);
    }

    ListPreference listPreference = userObject.getListPreference("Email");
View Full Code Here

TOP

Related Classes of org.apache.struts.action.DynaActionForm

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.