Package com.dotmarketing.portlets.webforms.model

Examples of com.dotmarketing.portlets.webforms.model.WebForm


    // Saving the form in the database and the submitted file to the dotCMS
    String formType = getMapValue("formType", parameters) != null?
        (String)getMapValue("formType", parameters):(String)getMapValue("formName", parameters);

        WebForm formBean = saveFormBean(parameters, host, formType, ignoreString, filesLinks);


        // Setting up the email
        // Email variables - decrypting crypted email addresses
View Full Code Here


    //Fields predefined for the form reports
    String predefinedFields = ":prefix:title:firstName:middleInitial:middleName:lastName:fullName:organization:address:address1:address2:city:state:zip:country:phone:email:";

    //Return variable
    WebForm formBean = new WebForm();
    formBean.setFormType(formType);

    // Copy the common fields set in the form
    try {
      for (Entry<String, Object> param : parameters.entrySet()) {
        BeanUtils.setProperty(formBean, param.getKey(), getMapValue(param.getKey(), parameters));
      }
    } catch (Exception e1) {
      Logger.error(EmailFactory.class, "sendForm: Error ocurred trying to copy the form bean parameters", e1);
    }

    try {
      HibernateUtil.save(formBean);
    } catch (DotHibernateException e) {
      Logger.error(EmailFactory.class, e.getMessage(), e);
    }   
    String formId = formBean.getWebFormId();

    // Loop over the request Map or the ordered Map to set the custom
    // fields and also saving the submitted files
    StringBuffer customFields = new StringBuffer();

    Set<Entry<String, Object>> paramSet = parameters.entrySet();

    for (Entry<String, Object> param : paramSet) {

      String key = (String) param.getKey();


      String value = null;

      Object paramValue = getMapValue(key, parameters);
      if (paramValue instanceof File) {

        File f = (File) param.getValue();
        String submittedFileName = f.getName();
        String fileName = key + "." + UtilMethods.getFileExtension(submittedFileName);
        if(getMapValue(fileName.substring(4, key.length()) + "FName", parameters) != null) {
          fileName = getMapValue(fileName.substring(4, key.length()) + "FName", parameters) +
            "." + UtilMethods.getFileExtension(submittedFileName);
        }

        //Saving the file
        try {
          if(f.exists()) {
            String filesFolder = getMapValue("formFolder", parameters) instanceof String?(String)getMapValue("formFolder", parameters):null;
           
            String fileLink = saveFormFile(formId, formType, fileName, f, host, filesFolder);
            filesLinks.append(filesLinks.toString().equals("")? "http://" + host.getHostname() + fileLink : ",http://" + host.getHostname() + fileLink);
          }
        } catch (Exception e) {
          Logger.error(EmailFactory.class, "sendForm: couldn't saved the submitted file into the cms = " + fileName, e);         
          try {
            HibernateUtil.delete(formBean);
          } catch (DotHibernateException e1) {
            Logger.error(EmailFactory.class, e1.getMessage(), e1);           
          }
          throw new DotRuntimeException("sendForm: couldn't saved the submitted file into the cms = " + fileName, e);
        }

      } else if (paramValue instanceof String)
        value = (String)paramValue;

      List<String> cFields = new ArrayList<String>();
      if (predefinedFields.indexOf(":" + key + ":") < 0
          && ignoreString.indexOf(":" + key + ":") < 0
          && UtilMethods.isSet(value)) {
        value = value.replaceAll("\\|", " ").replaceAll("=", " ");
        if(key.equals("ccNumber"))
          value = UtilMethods.obfuscateCreditCard(value);

        String capKey = UtilMethods.capitalize(key);
        int aux = 2;
        String capKeyAux = capKey;
        while (cFields.contains(capKeyAux)) {
          capKeyAux = capKey + aux;
          ++aux;
        }
        cFields.add(capKeyAux);
        String cField = capKeyAux + "=" + value;
        customFields.append(cField + "|");
      }
    }

    customFields.append("Files=" + filesLinks);

    //Setting the custom fields and saving them
    formBean.setCustomFields(customFields.toString());
    formBean.setSubmitDate(new Date());

    if(UtilMethods.isSet(formType)){
      try {
        HibernateUtil.saveOrUpdate(formBean);
      } catch (DotHibernateException e) {
View Full Code Here

        parameters.put(stringKey, (String) hashCategories.get(stringKey));
      }
      parameters.remove("categories");
    }

    WebForm webForm = new WebForm();
    try
    {
      /*validation parameter should ignore the returnUrl and erroURL field in the spam check*/
      String[] removeParams = ignoredParameters.split(":");
      for(String param : removeParams){
        toValidate.remove(param);
      }
     
     
     
      parameters.put("request", request);
      parameters.put("response", response);
     
      //Sending the email     
      webForm = EmailFactory.sendParameterizedEmail(parameters, toValidate, currentHost, currentUser);
     
     
     
      webForm.setCategories(categories);

      if(UtilMethods.isSet(request.getParameter("createAccount")) && request.getParameter("createAccount").equals("true"))
      {
        //if we create account set to true we create a user account and add user comments.
        createAccount(webForm, request);
        try{
            String userInode = webForm.getUserInode();
            String customFields = webForm.getCustomFields();
            customFields += " User Inode = " + String.valueOf(userInode) + " | ";
            webForm.setCustomFields(customFields);
        }
        catch(Exception e){
           
        }

      }

     
            if(UtilMethods.isSet(webForm.getFormType())){
                HibernateUtil.saveOrUpdate(webForm);
            }
     
     
      if (request.getParameter("return") != null)
View Full Code Here

TOP

Related Classes of com.dotmarketing.portlets.webforms.model.WebForm

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.