Examples of GroupDefinitionException


Examples of javax.validation.GroupDefinitionException

  private <T> Set<ConstraintViolation<T>> validateProperty(Set<Class<?>> previousGroups, T object, String propertyName, Class<?>... groups) {
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(object.getClass());
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
    for(Class<?> group : reflector.getGroupSequence()) {
      if(previousGroups.contains(group)) {
        throw new GroupDefinitionException("The group sequence on " + object.getClass().getName() + " already contains " + group.getName() + ".  Definitions may not be cyclic or circular");
      }
     
      violations.addAll(this.coreValidator.validateProperty(object, propertyName, group));
      previousGroups.add(group);
     
View Full Code Here

Examples of javax.validation.GroupDefinitionException

  private <T> Set<ConstraintViolation<T>> validateValue(Set<Class<?>> previousGroups, Class<T> beanType,  String propertyName, Object value, Class<?>... groups) {
    IReflector reflector = ReflectorFactory.INSTANCE.getReflector(beanType);
    Set<ConstraintViolation<T>> violations = new HashSet<ConstraintViolation<T>>();
    for(Class<?> group : reflector.getGroupSequence()) {
      if(previousGroups.contains(group)) {
        throw new GroupDefinitionException("The group sequence on " + beanType.getName() + " already contains " + group.getName() + ".  Definitions may not be cyclic or circular");
      }
     
      violations.addAll(this.coreValidator.validateValue(beanType, propertyName, group));
      previousGroups.add(group);
     
View Full Code Here

Examples of javax.validation.GroupDefinitionException

        for (final Class<?> groupClass : groupClasses) {
            if (groupClass.getName().equals(beanClass.getName())) {
                groupSeq.add(Group.DEFAULT);
                containsDefault = true;
            } else if (groupClass.getName().equals(Default.class.getName())) {
                throw new GroupDefinitionException("'Default.class' must not appear in @GroupSequence! Use '"
                    + beanClass.getSimpleName() + ".class' instead.");
            } else {
                groupSeq.add(new Group(groupClass));
            }
        }
        if (!containsDefault) {
            throw new GroupDefinitionException("Redefined default group sequence must contain " + beanClass.getName());
        }
        log.log(Level.FINEST, String.format("Default group sequence for bean %s is: %s", beanClass.getName(), groupSeq));
    }
View Full Code Here

Examples of javax.validation.GroupDefinitionException

      if ( ( i == 0 && index == defaultGroupIndex - 1 ) || ( i == defaultGroupList.size() - 1 && index == defaultGroupIndex + 1 ) ) {
        // if we are at the beginning or end of he defaultGroupSequence and the matches are either directly before resp after we can continue as well,
        // since we basically have two groups
        continue;
      }
      throw new GroupDefinitionException( "Unable to expand default group list" + defaultGroupList + " into sequence " + groupList );
    }
  }
View Full Code Here

Examples of javax.validation.GroupDefinitionException

    chain.insertSequence( sequence );
  }

  private List<Group> resolveSequence(Class<?> group, List<Class<?>> processedSequences) {
    if ( processedSequences.contains( group ) ) {
      throw new GroupDefinitionException( "Cyclic dependency in groups definition" );
    }
    else {
      processedSequences.add( group );
    }
    List<Group> resolvedGroupSequence = new ArrayList<Group>();
View Full Code Here

Examples of javax.validation.GroupDefinitionException

      if ( group.getName().equals( beanClass.getName() ) ) {
        defaultGroupSequence.add( Default.class );
        groupSequenceContainsDefault = true;
      }
      else if ( group.getName().equals( Default.class.getName() ) ) {
        throw new GroupDefinitionException( "'Default.class' cannot appear in default group sequence list." );
      }
      else {
        defaultGroupSequence.add( group );
      }
    }
    if ( !groupSequenceContainsDefault ) {
      throw new GroupDefinitionException( beanClass.getName() + " must be part of the redefined default group sequence." );
    }
    if ( log.isTraceEnabled() ) {
      log.trace(
          "Members of the default group sequence for bean {} are: {}",
          beanClass.getName(),
View Full Code Here

Examples of javax.validation.GroupDefinitionException

      if ( group.getName().equals( beanClass.getName() ) ) {
        defaultGroupSequence.add( Default.class );
        groupSequenceContainsDefault = true;
      }
      else if ( group.getName().equals( Default.class.getName() ) ) {
        throw new GroupDefinitionException( "'Default.class' cannot appear in default group sequence list." );
      }
      else {
        defaultGroupSequence.add( group );
      }
    }
    if ( !groupSequenceContainsDefault ) {
      throw new GroupDefinitionException( beanClass.getName() + " must be part of the redefined default group sequence." );
    }
    if ( log.isTraceEnabled() ) {
      log.trace(
          "Members of the default group sequence for bean {} are: {}",
          beanClass.getName(),
View Full Code Here

Examples of org.rhq.enterprise.server.resource.group.definition.exception.GroupDefinitionException

        GroupDefinitionAlreadyExistsException {
        String name = (definition.getName() == null ? "" : definition.getName().trim());
        String description = (definition.getDescription() == null ? "" : definition.getDescription().trim());

        if (name.equals("")) {
            throw new GroupDefinitionException("Name is a required property");
        }
        if (name.length() > 100) {
            throw new GroupDefinitionException("Name is limited to 100 characters");
        }
        if (description.length() > 100) {
            throw new GroupDefinitionException("Description is limited to 100 characters");
        }
        if (name.contains("<") || name.contains("$") || name.contains("'") || name.contains("{") || name.contains("[")) {
            throw new GroupDefinitionException("Name must not contain <,$,',[,{ characters");
        }
        if (definition.getRecalculationInterval() < 0) {
            throw new GroupDefinitionException("Recalculation interval cannot be negative");
        }
        if (definition.getRecalculationInterval() > 0 && definition.getRecalculationInterval() < 60 * 1000) {
            throw new GroupDefinitionException(
                "Recalculation interval cannot be a positive number lower than 1 minute (60000ms)");
        }
        if (definition.getExpression() == null || definition.getExpression().isEmpty()) {
            throw new GroupDefinitionException("Expression is empty");
        }
       
        try {
            ExpressionEvaluator evaluator = new ExpressionEvaluator();
            for (String expression : definition.getExpressionAsList()) {
                evaluator.addExpression(expression);
            }
        } catch (InvalidExpressionException e) {
            throw new GroupDefinitionException("Cannot parse the expression: " + e.getMessage());
        }

        Query query = entityManager.createNamedQuery(GroupDefinition.QUERY_FIND_BY_NAME);
        query.setParameter("name", name);

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.