Package pt.opensoft.msg

Examples of pt.opensoft.msg.ValidateException


  public int getPageNumber() {
    String pageStr = _request.getString(PAGE_PARAMETER);
    if( pageStr != null ) {
      if( !StringUtil.isNumeric(pageStr) ) {
        throw new ValidateException(PAGE_PARAMETER, "A P�gina indicada � inv�lida: " + pageStr);
      }
      return Integer.parseInt(pageStr);
    }
    else {
      return 1;
View Full Code Here


        _request = request;
    }

    public void checkNull(String fieldName, String fieldDescription) throws ValidateException {
        if (_request.getString(fieldName) == null || _request.getString(fieldName).length() == 0) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " tem que estar preenchido.");
        }
    }
View Full Code Here

        }
    }

    public void checkMinLength(String fieldName, String fieldDescription, int size) {
        if (_request.getString(fieldName) != null && _request.getString(fieldName).length() < size) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " deve ter pelo menos " + size + " carateres.");
        }
    }
View Full Code Here

        }
    }

    public void checkMaxLength(String fieldName, String fieldDescription, int size) {
        if (_request.getString(fieldName) != null && _request.getString(fieldName).length() > size) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " n�o pode exceder " + size + " carateres.");
        }
    }
View Full Code Here

        }
    }

    public void checkNumeric(String fieldName, String fieldDescription) {
        if (_request.getString(fieldName) != null && !StringUtil.isNumeric(_request.getString(fieldName))) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " tem que ser num�rico.");
        }
    }
View Full Code Here

        }
    }
   
    public void checkMinValue(String fieldName, String fieldDescription, int minValue) {
        if (_request.getString(fieldName) != null && _request.getInt(fieldName) < minValue) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " deve ser maior ou igual a " + minValue + ".");
        }
    }
View Full Code Here

        }
    }

    public void checkMaxValue(String fieldName, String fieldDescription, int maxValue) {
        if (_request.getString(fieldName) != null && _request.getInt(fieldName) > maxValue) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " deve ser menor ou igual a " + maxValue + ".");
        }
    }
View Full Code Here

     * @param possibleValues conjunto de valores separados por v�rgula. ex: "1,13,ab"
     */
    public void checkPossibleValues(String fieldName, String fieldDescription, String possibleValues) {
        List possibleValuesList = ListUtil.toList(possibleValues, ",");
        if (_request.getString(fieldName) != null && !possibleValuesList.contains(_request.getString(fieldName))) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " deve corresponder a um destes valores: " + possibleValues + ".");
        }
    }
View Full Code Here

        }
    }
   
    public void checkEuro(String fieldName, String fieldDescription) {
        if (_request.getString(fieldName) != null && !EuroField.isValid(_request.getString(fieldName))) {
            throw new ValidateException(fieldName, "O campo " + fieldDescription + " deve conter um valor v�lido em euros.");
        }
    }
View Full Code Here

            String originalFileExt = FileUtil.getExtension(originalFileName);
            String timestamp = new DateTime().format("yyyyMMddHHmmssssss");


            if (originalFileName == null) {
                throw new ValidateException("Por favor, indique o nome do ficheiro.", INEXISTENT_FILE_CODE);
            }
           
            // verifico se o ficheiro � v�lido
            if (uploadedFile.getSize() == 0) {
                throw new ValidateException("O ficheiro " + originalFileName + " � inv�lido!");
            }

      if (StringUtil.isEmpty(originalFileExt)) {
        throw new ValidateException("A extens�o " + originalFileExt + " � inv�lida!");
      }
            // verifico se a extens�o � v�lida
            if (possibleExtensions != null && possibleExtensions.indexOf(originalFileExt.toLowerCase()) == -1) {
                throw new ValidateException("A extens�o " + originalFileExt + " � inv�lida!");
      }
      if (originalFileName.startsWith(".")) {
        throw new ValidateException("O nome do ficheiro " + originalFileName + " � inv�lido!");
            }

            if (!inMemory) {
                File savedFileName = new File(repositoryPath + "/" + originalFileName + "." + timestamp);
                if (automaticUnzip && originalFileExt.equalsIgnoreCase("zip")) {
                    try {
                        String expectedXmlFile = StringUtil.replaceIgnoreCase(originalFileName, ".zip", ".xml");
                        savedFileName = new File(repositoryPath + "/" + expectedXmlFile + "." + timestamp);
                        OutputStream out = new FileOutputStream(savedFileName);
                        try {
                            ZipUtil.getContentFromZip(uploadedFile.getInputStream(), out, expectedXmlFile);
                        } finally {
                            out.close();

                        }
//          uploadedFile.setContent(content); //substitu�mos o conte�do original que era um zip pelo ficheiro q estava l� dentro
                    } catch (IOException e) {
                        e.printStackTrace();
                        throw new ValidateException("Formato do ficheiro ZIP inv�lido");
                    }
                } else {
                    // saves file to disk with timestamp
                    try {
                        uploadedFile.write(savedFileName);
                    } catch (FileUploadException e) {
                        throw new ValidateException("Ocorreu um erro na escrita do ficheiro para disco.");
                    }
                }

                setOriginalFileName(originalFileName);
                setUploadedFile(savedFileName);
View Full Code Here

TOP

Related Classes of pt.opensoft.msg.ValidateException

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.