Package org.apache.struts.action

Examples of org.apache.struts.action.DynaActionForm


  public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, CommunicationException, NamingException
  {
    String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
   
    String returnStatus = ".view.contacts.view_related_address";
    DynaActionForm dynaform = (DynaActionForm) form;
    AccountHelperHome home = (AccountHelperHome)
    CVUtility.getHomeObject("com.centraview.account.helper.AccountHelperHome", "AccountHelper");
   
    try {
      AccountHelper remote = home.create();
      remote.setDataSource(dataSource);
     
      Vector taxJurisdiction = remote.getTaxJurisdiction();
     
      dynaform.set("jurisdictionVec",taxJurisdiction);
      dynaform.set("recordID", request.getParameter("recordID"));
      dynaform.set("recordName", request.getParameter("recordName"));
      dynaform.set("listType", request.getParameter("listType"));
      dynaform.set("listFor", request.getParameter("listFor"));
      dynaform.set("operation", "add");
    }catch(Exception e){
      logger.error("[Exception] NewAddressHandler.Execute Handler ", e);
      returnStatus = "failure";
    }
    return (mapping.findForward(returnStatus));
View Full Code Here


    try
    {
      HttpSession session = request.getSession(true);
      request.setAttribute("TypeOfOperation", "Event");
      //have this so an empty list shows up at the bottom.
      DynaActionForm dynaForm = (DynaActionForm) form;
      dynaForm.initialize(mapping);

      UserObject userObject = (UserObject)session.getAttribute("userobject");

      int individualId = userObject.getIndividualID();
View Full Code Here

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

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

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

      // now, check the message ID on the form...
      if (messageID == null || messageID.intValue() <= 0 )
      {
        // if Message 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", "Message ID"));
        return(mapping.findForward(forward));
      }

      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      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);
     
      // now when we go back to FolderList.do, we'll be in the folder that this message is in
      session.setAttribute("currentMailFolder", folderID);
      emailForm.set("private",(String)messageVO.getPrivate());
      String fromAddress = (String)messageVO.getFromAddress();
      if (fromAddress != null && !fromAddress.equals("") && CVUtility.isEmailAddressValid(fromAddress))
      {
        emailForm.set("from", new InternetAddress(fromAddress));
      }else{
    InternetAddress blankfromAddress = new InternetAddress();
    blankfromAddress.setAddress("");
        emailForm.set("from", blankfromAddress);
      }
     
      // the the To: list. Make sure it contains InternetAddress objects
      ArrayList toListVO = (ArrayList)messageVO.getToList();
      ArrayList toList = new ArrayList();
      Iterator toIter = toListVO.iterator();
      while (toIter.hasNext())
      {
        Object toListObject = toIter.next();
        if (toListObject instanceof InternetAddress){
          toList.add((InternetAddress) toListObject);
        }
        if (toListObject instanceof String){
          toList.add((String) toListObject);
        }
      }
      emailForm.set("toList", toList);
      request.setAttribute("toSize", new Integer(toList.size()));

      // the the cc: list. Make sure it contains InternetAddress objects
      ArrayList ccListVO = (ArrayList)messageVO.getCcList();
      ArrayList ccList = new ArrayList();
      Iterator ccIter = ccListVO.iterator();
      while (ccIter.hasNext())
      {
        Object ccListObject = ccIter.next();
        if (ccListObject instanceof InternetAddress){
          ccList.add((InternetAddress) ccListObject);
        }
        if (ccListObject instanceof String){
          ccList.add((String) ccListObject);
        }       
      }
      emailForm.set("ccList", ccList);
      request.setAttribute("ccSize", new Integer(ccList.size()));

      ArrayList bccList = new ArrayList();
      emailForm.set("bccList", bccList);

      emailForm.set("messageDate", messageVO.getReceivedDate());

      emailForm.set("subject", messageVO.getSubject());

      emailForm.set("attachmentList", messageVO.getAttachedFiles());
      request.setAttribute("attachmentSize", new Integer(messageVO.getAttachedFiles().size()));

      String body = (String)messageVO.getBody();

      // figure out if the message's Content-Type: is text/plain
      // If so, replace newlines with <br>'s.
      String contentType = (String)messageVO.getContentType();
      if (contentType != null && contentType.equals(MailMessageVO.PLAIN_TEXT_TYPE))
      {
        // we need to make it pretty
        body = body.replaceAll("\r", "");
        body = body.replaceAll("\n", "<br>\n");
      }

      emailForm.set("body", body);

      HashMap folderList = remote.getFolderList(messageVO.getEmailAccountID());
      emailForm.set("folderList", folderList);

      HashMap prevNextMap = remote.getPreviousNextLinks(individualID, messageID.intValue());
      emailForm.set("previousMessage", (Integer)prevNextMap.get("previousMessage"));
      emailForm.set("nextMessage", (Integer)prevNextMap.get("nextMessage"));

      String headers = (String)messageVO.getHeaders();
      String webformType = this.isMessageWebformImport(headers);

      if (webformType.equals("Contact"))
      {
        emailForm.set("showImportContactButton", new Boolean(true));
      }

      if (! messageVO.isMessageRead())
      {
        // if the message is not marked as read, mark it read now
View Full Code Here

      HttpSession session = request.getSession();
      UserObject userobject = (UserObject)session.getAttribute("userobject");
      String timeZone = userobject.getUserPref().getTimeZone();
      int userId = userobject.getIndividualID();
      int reportId = getTheId("reportId", request);
      DynaActionForm adHocReportForm = (DynaActionForm)form;
      ReportVO reportVO = null;

      ReportFacade remote = getReportFacade();

      // searchCriteria should always have at least one row.
      SearchCriteriaVO[] searchCriteria = (SearchCriteriaVO[])adHocReportForm.get("searchCriteria");

      String addRow = (String)adHocReportForm.get("addRow");
      String removeRow = (String)adHocReportForm.get("removeRow");
      // we may just be doing search criteria row manipulation.
      if (addRow.equals("true")) {
        searchCriteria = AdvancedSearchUtil.addRow(searchCriteria);
        adHocReportForm.set("addRow", "false");
        adHocReportForm.set("searchCriteria", searchCriteria);
        reportVO = remote.getAdHocReport(userId, reportId);
        reportVO.setSelectedFields(getSelectedFieldsWithNames((String)adHocReportForm.get("contentFields"), (String)adHocReportForm.get("contentOrders"), (String)adHocReportForm.get("contentFieldNames")));
        request.setAttribute("pagedata", reportVO);
      } else if (!removeRow.equals("false")) {
        searchCriteria = AdvancedSearchUtil.removeRow(searchCriteria, removeRow);
        adHocReportForm.set("removeRow", "false");
        adHocReportForm.set("searchCriteria", searchCriteria);
        reportVO = remote.getAdHocReport(userId, reportId);
        reportVO.setSelectedFields(getSelectedFieldsWithNames((String)adHocReportForm.get("contentFields"), (String)adHocReportForm.get("contentOrders"), (String)adHocReportForm.get("contentFieldNames")));
        request.setAttribute("pagedata", reportVO);
      } else { // So it isn't search criteria row manipulation.
        // if action is null, it means we are displaying the form for editing,
        // otherwise we are going to save and possibly run the report.
        String action = request.getParameter("action");
        if (action == null) {
          String showFields = (String)adHocReportForm.get("showFields");
          String createNew = (String)adHocReportForm.get("createNew");
          if (createNew != null && createNew.equals("true")) {
            adHocReportForm.initialize(mapping);
          }
          reportVO = remote.getAdHocReport(userId, reportId);
          // I guess showFields is used to determine if the user edited any of the fields, that are on the form
          // but not yet in the database.  So we know to pull the report stuff from the DB
          // and then change the selected fields based on the current form.
          // it is initially "false" in the struts config
          if (!showFields.equals("true")) {
            // if it isn't true we update the form with the info from the reportVO from the database.
            adHocReportForm = (DynaActionForm)getAdHocReportFormFromReportVO(reportVO, adHocReportForm, request);
          } else {
            // otherwise we analyze the fields from the form and show that.
            reportVO.setSelectedFields(getSelectedFieldsWithNames((String)adHocReportForm.get("contentFields"), (String)adHocReportForm.get("contentOrders"), (String)adHocReportForm.get("contentFieldNames")));
          }
          moduleId = reportVO.getModuleId();
          request.setAttribute("pagedata", reportVO);
        } else { // action is telling us to do something for real, check for errors.
          ActionErrors errors = adHocReportForm.validate(mapping, request);
          if (0 < errors.size()) {
            saveErrors(request, errors);
            reportVO = remote.getAdHocReport(userId, reportId);
            moduleId = reportVO.getModuleId();
            request.setAttribute("pagedata", reportVO);
          } else { // the form passed validation
            // So we need to build a reportVO based on the form.
            // and either save a new one to the database (if we are duplicate)
            // or update the existing one in the database.
            reportVO = getAdHocReportVOFromForm(timeZone, adHocReportForm);
            // I guess "copy" is used for duplicate?  So if copy is true we will
            // be creating a new one, otherwise we will be updating.
            if (((Boolean)adHocReportForm.get("copy")).booleanValue()) {
              reportId = remote.addAdHocReport(userId, reportVO);
              reportVO.setReportId(reportId);
            } else {
              remote.updateAdHocReport(userId, reportVO);
            }
            if (action.equals("save")) {
              moduleId = reportVO.getModuleId();
              // It may be better to actually store of the Selects and
              // whatever else outside the VO on the formbean, so we can
              // not have to round trip here.  But for now we need to get the
              // reportVO from the EJB layer because it has the field definitions in it.
              reportVO = remote.getAdHocReport(userId, reportId);
              request.setAttribute("pagedata", reportVO);
            } else if (action.equals("close")) {
              adHocReportForm.set("createNew", "true");
              nextURL = "showadhocreportlist";
            } else if (action.equals("run")) {
              nextURL = "showadhocreportresult";
            }
          } // end else for if (0 < errors.size())
        } // end else for if (action == null)
      } // end else for if (addRow.equals("true"))
      adHocReportForm.set("moduleId", new Integer(moduleId));
      request.setAttribute("reportId", String.valueOf(reportId));
      request.setAttribute("reportType", String.valueOf(ReportConstants.ADHOC_REPORT_CODE));
    } catch (Exception e) {
      logger.error("[execute] Exception thrown.", e);
      throw new ServletException(e);
View Full Code Here

   
    ActionErrors allErrors = new ActionErrors();
    String forward = "closeWindow";
   
    // "mailFolderForm", defined in struts-config-email.xml
    DynaActionForm folderForm = (DynaActionForm)form;

    try
    {
      // get the folder ID from the form bean
      Integer folderID = (Integer)folderForm.get("folderID");
     
      // 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", "Folder ID"));
        return(mapping.findForward(forward));
      }
     
      MailHome home = (MailHome)CVUtility.getHomeObject("com.centraview.mail.MailHome", "Mail");
      Mail remote = (Mail)home.create();
      remote.setDataSource(dataSource);

      MailFolderVO folderVO = remote.getEmailFolder(folderID.intValue());

      int accountID = folderVO.getEmailAccountID();

      int numberDeleted = remote.deleteFolder(individualID, accountID, folderID.intValue());

      if (numberDeleted > 0)
      {
        // tell /jsp/mail/view_folder.jsp to refresh the parent window, and close itself...
        folderForm.set("folderDeleted", new Boolean(true));
        folderForm.set("closeWindow", new Boolean(true));
      }
    }catch(Exception e){
      System.out.println("[Exception][DeleteFolderHandler] Exception thrown in execute(): " + e);
      // e.printStackTrace();
    }
View Full Code Here

    int individualID = 0;
    if (userobject != null) {
      individualID = userobject.getIndividualID();
    }
    DynaActionForm dynaForm = (DynaActionForm)form;
    int contactID = Integer.parseInt((String)dynaForm.get("ContactID"));
    boolean isEntity = ((String)dynaForm.get("EntityType")).equalsIgnoreCase("TRUE");
    try {
      ContactVO contactObject = new ContactVO();
      ContactFacadeHome aa = (ContactFacadeHome)CVUtility.getHomeObject(
          "com.centraview.contact.contactfacade.ContactFacadeHome", "ContactFacade");

      ContactFacade remote = aa.create();
      remote.setDataSource(dataSource);

      if (isEntity) {
        EntityVO entityVO = remote.getEntity(contactID);
        contactObject = entityVO;
        dynaForm.set("name", entityVO.getName());
      } else {
        IndividualVO individualVO = remote.getIndividual(contactID);
        contactObject = individualVO;
        dynaForm.set("name", individualVO.getFirstName() + " " + individualVO.getLastName());
      }
      request.setAttribute("rowId", new String[] { Integer.toString(contactID) });
      String[] primaryEmailAddress = (String[])dynaForm.get("primaryEmailAddress");
      String[] primaryPhoneNumbers = (String[])dynaForm.get("primaryPhoneNumbers");
      // Putting the phone numbers in an arraylist because it's a bit easier to
      // deal with.
      ArrayList phoneNumbers = new ArrayList();
      for (int i = 0; i < primaryPhoneNumbers.length; i++) {
        phoneNumbers.add(i, primaryPhoneNumbers[i]);
View Full Code Here

    ActionMessages allErrors = new ActionMessages();
    String forward = "closeWindow";
    String errorForward = "errorOccurred";

    DynaActionForm emailForm = (DynaActionForm)form;

    // Populate the Attachments In-Case. If we face any problem while sending
    // email.
    // Populating the ArrayList with the DDNameValue.
    ArrayList attachments = new ArrayList();
    ArrayList attachmentFileIDs = new ArrayList();
    String[] tempAttachmentMap = (String[])emailForm.get("attachments");
    if (tempAttachmentMap != null && tempAttachmentMap.length > 0) {
      for (int i = 0; i < tempAttachmentMap.length; i++) {
        String fileKeyName = tempAttachmentMap[i];

        if (fileKeyName != null) {
          int indexOfHash = fileKeyName.indexOf("#");
          if (indexOfHash != -1) {
            int lenString = fileKeyName.length();
            String fileID = fileKeyName.substring(0, indexOfHash);
            String fileName = fileKeyName.substring(indexOfHash + 1, lenString);
            attachments.add(new DDNameValue(fileID + "#" + fileName, fileName));
            attachmentFileIDs.add(new Integer(fileID));
          }
        }
      }// end of while (attachIter.hasNext())
    }// end of if (tempAttachmentMap != null && tempAttachmentMap.size() > 0)

    // 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("");
View Full Code Here

    try {
      UserObject userobjectd = (UserObject)session.getAttribute("userobject");//get the user object
      int userId = userobjectd.getIndividualID();
      int reportId = 0;
      String timeZone = userobjectd.getUserPref().getTimeZone();
      DynaActionForm reportForm = (DynaActionForm)actionForm;

      String action = request.getParameter("action");
      if (action == null) {
        // if action wasn't passed then we set the data from the EJB layer on the form
        setPageData(request, moduleId);
        nextURL = "addadhocreport";
      } else if (action.equals("new") || action.equals("close") || action.equals("run")) {
        // Validate the form
        ActionErrors errors = reportForm.validate(actionMapping, request);
        if (0 < errors.size()) {
          // if it doesn't pass muster show the wankers some errors.
          saveErrors(request, errors);
          setPageData(request, moduleId);
          nextURL = "addadhocreport";
        } else {
          // Insert a new report into the database.
          ReportVO reportVO = getAdHocReportVOFromForm(timeZone, reportForm);
          ReportFacade remote = getReportFacade();
          reportId = remote.addAdHocReport(userId, reportVO);
          if (action.equals("new")) {
            // if save&new then show a blank form.
            reportForm.initialize(actionMapping);
            nextURL = "newaddhocreport";
          } else if (action.equals("run")) {
            reportForm.set("createNew", "true");
            request.setAttribute("reportId", String.valueOf(reportId));
            nextURL = "showadhocreportresult";
          } else {
            // save and close.
            reportForm.set("createNew", "true");
            nextURL = "showadhocreportlist";
          }
        }
      } else {
        // if it is some other value besides new, close, or run
        // reinitialize the form.
        reportForm.initialize(actionMapping);
        nextURL = "addadhocreport";
      }
      session.setAttribute("moduleId", String.valueOf(moduleId));
      // unless ViewAdHocReport.do needs the following whack it.
      request.setAttribute("reportType", String.valueOf(ReportConstants.ADHOC_REPORT_CODE));
View Full Code Here

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

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

    try {
      // get the account ID from the form bean
      Integer accountID = (Integer)ruleForm.get("accountID");

      // now, check the account ID on the form...
      if (accountID == null || accountID.intValue() <= 0 ) {
        // if account 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", "Account ID"));
        return(mapping.findForward(forward));
      }

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

      SearchCriteriaVO [] searchCriteria = (SearchCriteriaVO [])ruleForm.get("searchCriteria");

      HashMap conditionMap = SearchVO.getConditionOptions();
      ArrayList conditionList = this.buildSelectOptionList(conditionMap);
      ruleForm.set("conditionList", conditionList);

      // Get Saved search EJB
      AdvancedSearch remoteAdvancedSearch = null;
      try {
        AdvancedSearchHome advancedSearchHome = (AdvancedSearchHome)CVUtility.getHomeObject("com.centraview.advancedsearch.AdvancedSearchHome", "AdvancedSearch");
        remoteAdvancedSearch = advancedSearchHome.create();
        remoteAdvancedSearch.setDataSource(dataSource);
      }catch(Exception e){
        System.out.println("[Exception][SearchForm.execute] Exception Thrown getting EJB connection: " + e);
        throw new ServletException(e);
      }

      final int emailTableID = 33;
      final int emailModuleID = 79;

      HashMap tableFields = remoteAdvancedSearch.getSearchFieldsForTable(individualID, emailTableID, emailModuleID);
      ArrayList tableFieldList = this.buildSelectOptionList(tableFields);
      ruleForm.set("fieldList", tableFieldList);

      // See if we should add a row.
      String addRow = (String)ruleForm.get("addRow");
      if(addRow.equals("true")) {
        searchCriteria = this.addRow(searchCriteria);
        ruleForm.set("addRow","false");
      }

      // see if we should delete a row
      String removeRow = (String)ruleForm.get("removeRow");
      if(!removeRow.equals("false")) {
        searchCriteria = this.removeRow(searchCriteria, removeRow);
        ruleForm.set("removeRow","false");
      }

      ruleForm.set("searchCriteria", searchCriteria);

      // get the user's list of folders for this account
      HashMap folderList = remote.getFolderList(accountID.intValue());

      // remove the "root" folder from the list
      Set keySet = folderList.keySet();
      Iterator iter = keySet.iterator();
      while (iter.hasNext()) {
        Number key = (Number)iter.next();
        String value = (String)folderList.get(key);
        if (value.equals("root")) {
          iter.remove();
        }
      }
      ruleForm.set("folderList", folderList);

    }catch(Exception e){
      System.out.println("[Exception][ViewFolderHandler] Exception thrown in execute(): " + e);
      // TODO: remove stack trace
      e.printStackTrace();
View Full Code Here

    ModuleFieldRightMatrix mfrm = null;
    LoginHome lh = (LoginHome)CVUtility.getHomeObject("com.centraview.login.LoginHome","Login");

    try {
      // first, let's get the username and password from the HTML form
      DynaActionForm daf = (DynaActionForm)form;
      formUsername = (String)daf.get("username");
      formPassword = (String) daf.get("password");

      // next, let's check for the existence of the CVRMID cookie.
      boolean rmCookieExists = false;
      Cookie requestCookie = null;
      Cookie cookieList[] = request.getCookies();

      if (cookieList != null) {
        for (int i = 0; i < cookieList.length; i++) {
          Cookie tmpCookie = cookieList[i];
          if (tmpCookie.getName().equals("CVRMID")) {
            rmCookieExists = true;
            requestCookie = tmpCookie;
          }
        }
      }
      String cookieUsername = "";
      String cookiePassword = "";

      boolean useFormValues = false;

      // now, if the cookie exists, then get the content
      if (rmCookieExists) {
        // unencode the content of the cookie
        String unEncodedString = new String(Base64.decode(requestCookie.getValue()));

        // split the parts of the string on the "/" character
        String stringParts[] = unEncodedString.split("/");

        // get the username and password values and save for use
        cookieUsername = stringParts[0];
        cookiePassword = stringParts[1];

        // Note: In login.jsp, we checked to see if the cookie was set. If so, we
        // got the username and password from the cookie; we set the username form
        // value to the username from the cookie, and the password to "CVRMID-xxxxxxxx".
        // Therefore, we will check the form password value here; if it is NOT
        // "CVRMID-xxxxxxxx", the we know the user has manually typed in a different
        // password, and we will use the form password vs. the cookie password.
        if (formPassword != null && ! formPassword.equals("CVRMID-xxxxxxxx")) {
          useFormValues = true;
        }

        if (remember == null || remember.equals("")) {
          // if the user has *UN*-checked the Remember Me
          // checkbox, then get rid of their cookie
          this.forgetMe(response);
        }
      }

      String username = "";
      String password = "";

      if (rmCookieExists) {
        if (cookieUsername.equals(formUsername) && ! useFormValues) {
          // if the userName in the cookie equals the username in the form,
          // then, we'll authenticate on the cookie content
          username = cookieUsername;
          password = cookiePassword;
        } else {
          // if the username in the cookie does not match the username in the form,
          // then, we'll authenticate on the form content
          username = formUsername;
          password = formPassword;
        }
      } else {
        // if the cookie does not exist at all, authenticate on the form values
        username = formUsername;
        password = formPassword;
      }

      if (lh == null) {
        return (mapping.findForward("dataerror"));
      }

      Login remote = lh.create();
      remote.setDataSource(dataSource);
      usrResult = remote.authenticateUser(username, password);
      // Check to make sure the usrResult has all the fields we expect of it.
      // if so then it was a valid login, if not, then we will fail with a general
      // authentication error.
      if (usrResult.containsKey("individualid") && usrResult.containsKey("firstName") && usrResult.containsKey("lastName") && usrResult.containsKey("type")) {
        int individualId = Integer.parseInt((String)usrResult.get("individualid"));
        userType = (String)usrResult.get("type");
        String firstName = (String)usrResult.get("firstName");
        String lastName = (String)usrResult.get("lastName");

        if ((! userType.equalsIgnoreCase((String)daf.get("userType"))) && ! ("EMPLOYEE".equals(daf.get("userType")) && userType.equalsIgnoreCase("ADMINISTRATOR"))) {
          String errorHeader = "Error occurred during login.";
          errorMap.put(new Integer(0), errorHeader);
          String error = "The username or password was incorrect, or the user is disabled.";
          errorMap.put(new Integer(1), error);
          request.setAttribute("error", errorMap);
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.