Package org.codehaus.enunciate.contract.validation

Examples of org.codehaus.enunciate.contract.validation.ValidationException


   * @return the value of the check.
   */
  protected boolean isSimpleType(TypeDeclaration declaration) {
    if (declaration instanceof InterfaceDeclaration) {
      if (declaration.getAnnotation(javax.xml.bind.annotation.XmlType.class) != null) {
        throw new ValidationException(declaration.getPosition(), declaration.getQualifiedName() + ": an interface must not be annotated with @XmlType.");
      }

      return false;
    }

View Full Code Here


    }

    if (schema.getElementFormDefault() != XmlNsForm.UNSET) {
      for (Schema pckg : schemaInfo.getPackages()) {
        if ((pckg.getElementFormDefault() != null) && (schema.getElementFormDefault() != pckg.getElementFormDefault())) {
          throw new ValidationException(schema.getPosition(), schema.getQualifiedName() + ": inconsistent elementFormDefault declarations: " + pckg.getQualifiedName());
        }
      }
    }

    if (schema.getAttributeFormDefault() != XmlNsForm.UNSET) {
      for (Schema pckg : schemaInfo.getPackages()) {
        if ((pckg.getAttributeFormDefault() != null) && (schema.getAttributeFormDefault() != pckg.getAttributeFormDefault())) {
          throw new ValidationException(schema.getPosition(), schema.getQualifiedName() + ": inconsistent attributeFormDefault declarations: " + pckg.getQualifiedName());
        }
      }
    }

    schemaInfo.getPackages().add(schema);
View Full Code Here

      //apply the specified property order
      int propertyIndex1 = find(this.propOrder, propertyName1);
      int propertyIndex2 = find(this.propOrder, propertyName2);

      if (propertyIndex1 < 0) {
        throw new ValidationException(accessor1.getPosition(), "Property '" + propertyName1 + "' isn't included in the specified property order.");
      }
      if (propertyIndex2 < 0) {
        throw new ValidationException(accessor2.getPosition(), "Property '" + propertyName2 + "' isn't included in the specified property order.");
      }

      return propertyIndex1 - propertyIndex2;
    }
    else if (accessOrder == XmlAccessOrder.ALPHABETICAL) {
View Full Code Here

      if (enumValue != null) {
        value = enumValue.value();
      }

      if (!enumValues.add(value)) {
        throw new ValidationException(enumConstant.getPosition(), getQualifiedName() + ": duplicate enum value: " + value);
      }

      enumValueMap.put(enumConstant.getSimpleName(), value);
    }
    return enumValueMap;
View Full Code Here

        catch (MirroredTypeException e) {
          xmlType = XmlTypeFactory.getXmlType(e.getTypeMirror());
        }
      }
      catch (XmlTypeException e) {
        throw new ValidationException(getPosition(), getQualifiedName() + ": " + e.getMessage());
      }
    }

    return xmlType;
  }
View Full Code Here

        attributeAccessors.add(attribute);
        added = attribute;
      }
      else if (isValue(accessor)) {
        if (value != null) {
          throw new ValidationException(accessor.getPosition(), "Accessor " + accessor.getSimpleName() + " of " + getQualifiedName() + ": a type definition cannot have more than one xml value.");
        }

        value = new Value(accessor, this);
        added = value;
      }
      else if (isElementRef(accessor)) {
        ElementRef elementRef = new ElementRef(accessor, this);
        if (!elementAccessors.add(elementRef)) {
          //see http://jira.codehaus.org/browse/ENUNCIATE-381; the case for this is when an annotated field has an associated public property
          //we'll just silently continue
          continue;
        }
        added = elementRef;
      }
      else if (isAnyAttribute(accessor)) {
        hasAnyAttribute = true;

        XmlQNameEnumRef enumRef = accessor.getAnnotation(XmlQNameEnumRef.class);
        if (enumRef != null) {
          AnnotationProcessorEnvironment env = Context.getCurrentEnvironment();
          try {
            TypeDeclaration decl = env.getTypeDeclaration(enumRef.value().getName());
            anyAttributeQNameEnumRef = env.getTypeUtils().getDeclaredType(decl);
          }
          catch (MirroredTypeException e) {
            anyAttributeQNameEnumRef = e.getTypeMirror();
          }
        }

        continue;
      }
      else if (isAnyElement(accessor)) {
        anyElement = new AnyElement(accessor, this);
        continue;
      }
      else if (isUnsupported(accessor)) {
        throw new ValidationException(accessor.getPosition(), "Accessor " + accessor.getSimpleName() + " of " + getQualifiedName() + ": sorry, we currently don't support mixed or wildard elements. Maybe someday...");
      }
      else {
        //its an element accessor.

        if (accessor instanceof PropertyDeclaration) {
          //if the accessor is a property and either the getter or setter overrides ANY method of ANY superclass, exclude it.
          if (overrides(((PropertyDeclaration) accessor).getGetter()) || overrides(((PropertyDeclaration) accessor).getSetter())) {
            continue;
          }
        }

        Element element = new Element(accessor, this);
        if (!elementAccessors.add(element)) {
          //see http://jira.codehaus.org/browse/ENUNCIATE-381; the case for this is when an annotated field has an associated public property
          //we'll just silently continue
          continue;
        }
        added = element;
      }

      if (added.getAnnotation(XmlID.class) != null) {
        if (xmlID != null) {
          throw new ValidationException(added.getPosition(), "Accessor " + added.getSimpleName() + " of " + getQualifiedName() + ": more than one XML id specified.");
        }

        xmlID = added;
      }
    }
View Full Code Here

    if (xmlElements != null) {
      for (XmlElement element : xmlElements.value()) {
        try {
          Class clazz = element.type();
          if ((clazz == null) || (clazz == XmlElement.DEFAULT.class)) {
            throw new ValidationException(getPosition(), "Member " + getName() + " of " + typedef.getQualifiedName() + ": an element choice must have its type specified.");
          }
          else if ((clazz.isArray()) || (Collection.class.isAssignableFrom(clazz))) {
            throw new ValidationException(getPosition(), "Member " + getName() + " of " + typedef.getQualifiedName() + ": an element choice must not be a collection or an array.");
          }
        }
        catch (MirroredTypeException e) {
          // Fall through.
          // If the mirrored type exception is thrown, we couldn't load the class.  This probably
View Full Code Here

        else if (typeClass != XmlElement.DEFAULT.class) {
          return XmlTypeFactory.getXmlType(typeClass);
        }
      }
      catch (XmlTypeException e) {
        throw new ValidationException(getPosition(), "Member " + getName() + " of " + getTypeDefinition().getQualifiedName() + e.getMessage());
      }
    }

    return super.getBaseType();
  }
View Full Code Here

  public XmlType getElementXmlType() {
    try {
      return XmlTypeFactory.getXmlType(getParameters().iterator().next().getType());
    }
    catch (XmlTypeException e) {
      throw new ValidationException(getPosition(), "Method " + getSimpleName() + " of " + registry.getQualifiedName() + ": " + e.getMessage());
    }
  }
View Full Code Here

      if ((adaptedType instanceof DeclaredType && adapterType.canAdapt((DeclaredType)adaptedType)) ||
          (unwrappedAdaptedType != adaptedType && unwrappedAdaptedType instanceof ReferenceType && adapterType.canAdapt((ReferenceType) unwrappedAdaptedType))) {
        return adapterType;
      }

      throw new ValidationException(referer.getPosition(), referer.getSimpleName() + ": adapter " + adapterTypeMirror.getDeclaration().getQualifiedName() + " does not adapt " + unwrappedAdaptedType);
    }

    return null;

  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.contract.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.