Package javax.validation

Examples of javax.validation.ValidationException


            // spec says: If more than one META-INF/validation.xml file
            // is found in the classpath, a ValidationException is raised.
            if ( path.equals("META-INF/validation.xml") ) {
                Enumeration<URL> urls = loader.getResources(path);
                if ( urls.hasMoreElements() && (urls.nextElement() != null) && urls.hasMoreElements() ) {
                    throw new ValidationException("More than one " + path + " is found in the classpath");
                }
            }
        }
       
        return inputStream;
View Full Code Here


            log.debug("Trying to open input stream for {}", mappingFileName);
            InputStream in = null;
            try {
                in = getInputStream(mappingFileName);
                if (in == null) {
                    throw new ValidationException(
                          "Unable to open input stream for mapping file " +
                                mappingFileName);
                }
            } catch (IOException e) {
                throw new ValidationException("Unable to open input stream for mapping file " +
                      mappingFileName, e);
            }
            target.addMapping(in);
        }
    }
View Full Code Here

            for (BeanType bean : mapping.getBean()) {
                Class<?> beanClass = loadClass(bean.getClazz(), defaultPackage);
                if (!processedClasses.add(beanClass)) {
                    // spec: A given class must not be described more than once amongst all
                    //  the XML mapping descriptors.
                    throw new ValidationException(
                          beanClass.getName() + " has already be configured in xml.");
                }
                factory.getAnnotationIgnores()
                      .setDefaultIgnoreAnnotation(beanClass, bean.isIgnoreAnnotations());
                processClassLevel(bean.getClassType(), beanClass, defaultPackage);
View Full Code Here

            StreamSource stream = new StreamSource(in);
            JAXBElement<ConstraintMappingsType> root =
                  unmarshaller.unmarshal(stream, ConstraintMappingsType.class);
            mappings = root.getValue();
        } catch (JAXBException e) {
            throw new ValidationException("Failed to parse XML deployment descriptor file.",
                  e);
        } finally {
            IOUtils.closeQuietly(in);
        }
        return mappings;
View Full Code Here

    }

    private void checkValidName(String name) {
        for (String each : RESERVED_PARAMS) {
            if (each.equals(name)) {
                throw new ValidationException(each + " is a reserved parameter name.");
            }
        }
    }
View Full Code Here

    private <A extends Annotation> Class<?> getAnnotationParameterType(
          Class<A> annotationClass, String name) {
        Method m = SecureActions.getMethod(annotationClass, name);
        if (m == null) {
            throw new ValidationException("Annotation of type " + annotationClass.getName() +
                  " does not contain a parameter " + name + ".");
        }
        return m.getReturnType();
    }
View Full Code Here

        removeEmptyContentElements(elementType);

        boolean isArray = returnType.isArray();
        if (!isArray) {
            if (elementType.getContent().size() != 1) {
                throw new ValidationException(
                      "Attempt to specify an array where single value is expected.");
            }
            return getSingleValue(elementType.getContent().get(0), returnType, defaultPackage);
        } else {
            List<Object> values = new ArrayList<Object>();
View Full Code Here

            try {
                Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) returnType;
                returnValue =
                      createAnnotation(annotationType, annotationClass, defaultPackage);
            } catch (ClassCastException e) {
                throw new ValidationException("Unexpected parameter value");
            }
        } else {
            throw new ValidationException("Unexpected parameter value");
        }
        return returnValue;

    }
View Full Code Here

        List<Class<? extends Payload>> payloadList = new ArrayList<Class<? extends Payload>>();
        for (JAXBElement<String> groupClass : payloadType.getValue()) {
            Class<?> payload = loadClass(groupClass.getValue(), defaultPackage);
            if (!Payload.class.isAssignableFrom(payload)) {
                throw new ValidationException("Specified payload class " + payload.getName() +
                      " does not implement javax.validation.Payload");
            } else {
                payloadList.add((Class<? extends Payload>) payload);
            }
        }
View Full Code Here

                                   String defaultPackage) {
        List<String> fieldNames = new ArrayList<String>();
        for (FieldType fieldType : fields) {
            String fieldName = fieldType.getName();
            if (fieldNames.contains(fieldName)) {
                throw new ValidationException(fieldName +
                      " is defined more than once in mapping xml for bean " +
                      beanClass.getName());
            } else {
                fieldNames.add(fieldName);
            }
            final Field field = SecureActions.getDeclaredField(beanClass, fieldName);
            if (field == null) {
                throw new ValidationException(
                      beanClass.getName() + " does not contain the fieldType  " + fieldName);
            }

            // ignore annotations
            boolean ignoreFieldAnnotation = fieldType.isIgnoreAnnotations() == null ? false :
View Full Code Here

TOP

Related Classes of javax.validation.ValidationException

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.