Package com.dotmarketing.util

Examples of com.dotmarketing.util.URLEncoder


      }

      /**
       * Setting content values
       */
      URLEncoder encoder = new URLEncoder();
      StringBuilder paramsBuff=new StringBuilder();
      List<String> parametersName = new ArrayList<String>();
      List<String[]> values = new ArrayList<String[]>();
      List<String> parametersfileName = new ArrayList<String>();
      List<String[]> filevalues = new ArrayList<String[]>();
      java.util.Enumeration<String> parameterNames = request.getParameterNames();
      Map <String, String> parameters=  new HashMap <String, String> ();
      String parameterName;
      String emailvalues;
      String []emailvaluessep;
      List <String> emails= new ArrayList <String>();
      if (st.getStructureType() == Structure.STRUCTURE_TYPE_FORM) {
        emailvalues = st.getFieldVar("formEmail").getValues();
        if(UtilMethods.isSet(emailvalues)){
          emailvalues = emailvalues.trim().toLowerCase();
        }
        else {
            emailvalues = "";
        }
        if (UtilMethods.isSet(emailvalues)) {
          if (emailvalues.contains(",")) {
            emailvaluessep = emailvalues.split(",");
            for (String email : emailvaluessep) {
              if(RegEX.contains(email.trim(),"^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z]{2,}){1}$)"))
                emails.add(email.trim());
              else throw new Exception("The email list provided by the Form is incorrectly formmated, please enter on the Form properties a valid email addresses separated by a comma.");
            }
          }else
            if(RegEX.contains(emailvalues.trim(),"^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z]{2,}){1}$)"))
              emails.add(emailvalues.trim());
            else throw new Exception("The email provided by the Form is incorrect, please enter on the Form properties valid email address. ");
        }

        parameters.put("formTitle", st.getFieldVar("formTitle").getValues());
        parameters.put("formEmail", emailvalues);
        parameters.put("formReturnPage", st.getFieldVar("formReturnPage").getValues());


      }

      for (; parameterNames.hasMoreElements();) {
        parameterName = parameterNames.nextElement();
        Field  field = st.getFieldVar(parameterName);
        String fieldTypeStr = field!=null?field.getFieldType():"";
        Field.FieldType fieldType =  Field.FieldType.getFieldType(fieldTypeStr);
        String[] fieldValues = request.getParameterValues(parameterName);
        String value = "";
        if(fieldValues.length>1){
          for(String val:fieldValues){
            value+=","+val;
          }
          parameters.put(parameterName,value.substring(1));
        }else{
          parameters.put(parameterName,fieldValues[0]);
        }

        if(fieldType == null || (fieldType!=null && !fieldType.equals(Field.FieldType.IMAGE) && !fieldType.equals(Field.FieldType.FILE)&& !fieldType.equals(Field.FieldType.BINARY))){
          parametersName.add(parameterName);
          String[] vals = request.getParameterValues(parameterName);
          values.add(vals);
          if(!parameterName.equals("dispatch") && !parameterName.equals("captcha") && !parameterName.equals("options") && !parameterName.equals("structure") && !parameterName.equals("userId") && !parameterName.equals("referrer")){
            if(!SubmitContentUtil.imageOrFileParam(st, parameterName) && !UtilMethods.isImage(parameterName)){
              for(String val : vals){
                if(val.length() < 512) {
                  paramsBuff.append("&").append(parameterName).append("=").append(encoder.encode(val));
                }
              }
            }
          }
        }
        else {
          parametersfileName.add(parameterName);
          String[] vals = request.getParameterValues(parameterName);
          filevalues.add(vals);

          if(!parameterName.equals("dispatch") && !parameterName.equals("captcha") && !parameterName.equals("options") && !parameterName.equals("structure") && !parameterName.equals("userId") && !parameterName.equals("referrer")){
            if(!SubmitContentUtil.imageOrFileParam(st, parameterName)){
              for(String val : vals){
                paramsBuff.append("&").append(parameterName).append("=").append(encoder.encode(val));
              }
            }
          }
        }
      }
View Full Code Here

TOP

Related Classes of com.dotmarketing.util.URLEncoder

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.