Package javax.validation

Examples of javax.validation.ConstraintViolationException


            try {
                Validator validator = (Validator)beanContext.getJndiContext().lookup("comp/Validator");

                Set generalSet = validator.validate(activationSpec);
                if (!generalSet.isEmpty()) {
                    throw new ConstraintViolationException("Constraint violation for ActivationSpec " + activationSpecClass.getName(), generalSet);
                }
            } catch (NamingException e) {
                logger.debug("No Validator bound to JNDI context");
            }
View Full Code Here


    }

    private void validate(Object conference) {
        Set<ConstraintViolation<Object>> violations = validator.validate(conference);
        if(!violations.isEmpty()) {
            throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(violations));
        }
    }
View Full Code Here

        for (ConstraintViolation<?> violation : constraintViolations) {
          builder.append( "\t" ).append( violation.toString() ).append("\n");
        }
        builder.append( "]" );

        throw new ConstraintViolationException(
            builder.toString(), propagatedViolations
        );
      }
    }
  }
View Full Code Here

        for (ConstraintViolation<?> violation : constraintViolations) {
          builder.append( "\t" ).append( violation.toString() ).append("\n");
        }
        builder.append( "]" );

        throw new ConstraintViolationException(
            builder.toString(), propagatedViolations
        );
      }
    }
  }
View Full Code Here

            Set errors = validator.validate(spec, vargs);

            if (errors != null && errors.size() > 0)
            {
               throw new ResourceException(bundle.validationException(), new ConstraintViolationException(errors));
            }
         }
         catch (RuntimeException re)
         {
            throw new ResourceException(bundle.validationException(), re);
View Full Code Here

        SFSB1 sfsb1 = lookup("SFSB1", SFSB1.class);
        try {
            sfsb1.createEmployee("name", null, 2);
            fail("should of thrown validation error for null address in Employee entity");
        } catch (Throwable throwable) {
            ConstraintViolationException constraintViolationException = null;
            // find the ConstraintViolationException
            while(throwable != null && ! (throwable instanceof ConstraintViolationException)) {
                throwable = throwable.getCause();
            }
            // should be null or instanceof ConstraintViolationException
View Full Code Here

    private void validateMember(Member member) throws ConstraintViolationException, ValidationException {
        // Create a bean validator and check for issues.
        Set<ConstraintViolation<Member>> violations = validator.validate(member);

        if (!violations.isEmpty()) {
            throw new ConstraintViolationException(new HashSet<ConstraintViolation<?>>(violations));
        }

        // Check the uniqueness of the email address
        if (emailAlreadyExists(member.getEmail())) {
            throw new ValidationException("Unique Email Violation");
View Full Code Here

        constraintViolations.addAll( methodValidator.validateParameters( clazz, method, arguments, groups ) );

        if ( !constraintViolations.isEmpty() )
        {
            throw getException( new ConstraintViolationException( format( "Validation error when calling method '%s' with arguments %s",
                                                                          method,
                                                                          deepToString( arguments ) ),
                                                                  constraintViolations ),
                                validate.rethrowExceptionsAs(),
                                validate.exceptionMessage(),
                                arguments );
        }

        Object returnedValue = invocation.proceed();

        if ( validate.validateReturnedValue() )
        {
            constraintViolations.addAll( methodValidator.validateReturnedValue( clazz, method, returnedValue, groups ) );

            if ( !constraintViolations.isEmpty() )
            {
                throw getException( new ConstraintViolationException( format( "Method '%s' returned a not valid value %s",
                                                                              method,
                                                                              returnedValue ),
                                                                      constraintViolations ),
                                    validate.rethrowExceptionsAs(),
                                    validate.exceptionMessage(),
View Full Code Here

        if (validatorFactory != null) {
            Validator validator = validatorFactory.getValidator();

            Set generalSet = validator.validate(managedConnectionFactory);
            if (!generalSet.isEmpty()) {
                throw new ConstraintViolationException("Constraint violation for ManagedConnectionFactory " + managedConnectionFactoryClass, generalSet);
            }
        }
        //register with resource adapter
        if (managedConnectionFactory instanceof ResourceAdapterAssociation) {
            if (resourceAdapterWrapper == null) {
View Full Code Here

        builder.append( classNames );
        builder.append( " during " );
        builder.append( operation.getName() );
        builder.append( " time for groups " );
        builder.append( toString( groups ) );
        throw new ConstraintViolationException(
            builder.toString(), propagatedViolations
        );
      }
    }
  }
View Full Code Here

TOP

Related Classes of javax.validation.ConstraintViolationException

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.