Package org.codehaus.enunciate.contract.validation

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


          String typeFqn;

          try {
            Class adaptedClass = adaptedTypeInfo.type();
            if (adaptedClass == XmlJavaTypeAdapter.DEFAULT.class) {
              throw new ValidationException(pckg.getPosition(), "Package " + pckg.getSimpleName() + ": a type must be specified in " + XmlJavaTypeAdapter.class.getName() + " at the package-level.");
            }
            typeFqn = adaptedClass.getName();

          }
          catch (MirroredTypeException e) {
            TypeMirror adaptedType = e.getTypeMirror();
            if (!(adaptedType instanceof DeclaredType)) {
              throw new ValidationException(pckg.getPosition(), "Package " + pckg.getSimpleName() + ": unadaptable type: " + adaptedType);
            }
            TypeDeclaration typeDeclaration = ((DeclaredType) adaptedType).getDeclaration();
            if (typeDeclaration == null) {
              throw new IllegalStateException("Class not found: " + adaptedType);
            }
View Full Code Here


    String unknownQNameConstant = null;
    for (EnumConstantDeclaration enumConstant : enumConstants) {
      XmlUnknownQNameEnumValue unknownQNameEnumValue = enumConstant.getAnnotation(XmlUnknownQNameEnumValue.class);
      if (unknownQNameEnumValue != null) {
        if (unknownQNameConstant != null) {
          throw new ValidationException(enumConstant.getPosition(), getQualifiedName() + ": no more than two constants can be annotated with @XmlUnknownQNameEnumValue.");
        }

        unknownQNameConstant = enumConstant.getSimpleName();
        continue;
      }

      String ns = namespace;
      String localPart = enumConstant.getSimpleName();
      XmlQNameEnumValue enumValueInfo = enumConstant.getAnnotation(XmlQNameEnumValue.class);
      if (enumValueInfo != null) {
        if (enumValueInfo.exclude()) {
          continue;
        }

        if (!"##default".equals(enumValueInfo.namespace())) {
          ns = enumValueInfo.namespace();
        }
        if (!"##default".equals(enumValueInfo.localPart())) {
          localPart = enumValueInfo.localPart();
        }
      }

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

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

    ClassDeclaration adapterDeclaration = adapterType.getDeclaration();

    ClassType adaptorInterfaceType = findXmlAdapterType(adapterDeclaration);
    if (adaptorInterfaceType == null) {
      throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() + " is not an instance of javax.xml.bind.annotation.adapters.XmlAdapter.");
    }

    Collection<TypeMirror> adaptorTypeArgs = adaptorInterfaceType.getActualTypeArguments();
    if ((adaptorTypeArgs == null) || (adaptorTypeArgs.size() != 2)) {
      throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() +
        " must specify both a value type and a bound type.");
    }

    Iterator<TypeMirror> formalTypeIt = adaptorTypeArgs.iterator();
    this.adaptingType = TypeMirrorDecorator.decorate(formalTypeIt.next());
    TypeMirror boundTypeMirror = formalTypeIt.next();
    if (!(boundTypeMirror instanceof ReferenceType)) {
      throw new ValidationException(adapterDeclaration.getPosition(), adapterDeclaration.getQualifiedName() + ": illegal XML adapter: not adapting a reference type (" + boundTypeMirror + ").");
    }
    else while (boundTypeMirror instanceof TypeVariable) {
      //unwrap the type variable to find the bounds.
      TypeParameterDeclaration declaration = ((TypeVariable) boundTypeMirror).getDeclaration();
      if (declaration == null) {
View Full Code Here

        xmlType = XmlTypeFactory.getXmlType(getType());
      }
      return xmlType;
    }
    catch (XmlTypeException e) {
      throw new ValidationException(method.getPosition(), "Result of method " + getWebMethod().getSimpleName() + " of " + getWebMethod().getDeclaringEndpointInterface().getQualifiedName() + ": " + e.getMessage());
    }
  }
View Full Code Here

      if (xmlType == null) {
        TypeMirror type = getType();
        if (isHolder()) {
          Collection<TypeMirror> typeArgs = ((DeclaredType) type).getActualTypeArguments();
          if ((typeArgs == null) || (typeArgs.size() == 0)) {
            throw new ValidationException(getPosition(), "Parameter " + getSimpleName() + ": unable to get the type of the holder.");
          }

          type = typeArgs.iterator().next();
        }
        xmlType = XmlTypeFactory.getXmlType(type);
      }
      return xmlType;
    }
    catch (XmlTypeException e) {
      throw new ValidationException(getPosition(), "Parameter " + getSimpleName() + ": " + e.getMessage());
    }
  }
View Full Code Here

   * @return The calculated namespace uri.
   */
  protected String calculateNamespaceURI() {
    PackageDeclaration pkg = getPackage();
    if ((pkg == null) || ("".equals(pkg.getQualifiedName()))) {
      throw new ValidationException(getPosition(), getQualifiedName() + ": a web service in no package must specify a target namespace.");
    }

    String[] tokens = pkg.getQualifiedName().split("\\.");
    String uri = "http://";
    for (int i = tokens.length - 1; i >= 0; i--) {
View Full Code Here

          for (XmlSchemaType specifiedType : allSpecifiedTypes) {
            String typeFqn;
            try {
              Class specifiedClass = specifiedType.type();
              if (specifiedClass == XmlSchemaType.DEFAULT.class) {
                throw new ValidationException(pckg.getPosition(), pckg.getQualifiedName() + ": a type must be specified in " + XmlSchemaType.class.getName() + " at the package-level.");
              }
              typeFqn = specifiedClass.getName();
            }
            catch (MirroredTypeException e) {
              TypeMirror explicitTypeMirror = e.getTypeMirror();
              if (!(explicitTypeMirror instanceof DeclaredType)) {
                throw new ValidationException(pckg.getPosition(), pckg.getQualifiedName() + ": only a declared type can be adapted.  Offending type: " + explicitTypeMirror);
              }
              typeFqn = ((DeclaredType) explicitTypeMirror).getDeclaration().getQualifiedName();
            }

            explicitTypes.put(typeFqn, specifiedType);
View Full Code Here

    try {
      XmlType xmlType = XmlTypeFactory.findSpecifiedType(this);
      return (xmlType != null) ? xmlType : XmlTypeFactory.getXmlType(getAccessorType());
    }
    catch (XmlTypeException e) {
      throw new ValidationException(getPosition(), "Accessor " + getName() + " of " + getTypeDefinition().getQualifiedName() + ": " + e.getMessage());
    }
  }
View Full Code Here

                  MediaType type = MediaType.valueOf(contentTypeToId.getKey());
                  if (producesType.isCompatible(type)) {
                    String id = '/' + contentTypeToId.getValue();
                    String fullpath = resourceMethod.getFullpath();
                    if (fullpath.startsWith(id) || fullpath.startsWith(contentTypeToId.getValue())) {
                      throw new ValidationException(resourceMethod.getPosition(), String.format("The path of this resource starts with \"%s\" and you've got path-based conneg enabled. So Enunciate can't tell whether a request for \"%s\" is a request for this resource or a request for the \"%s\" representation of resource \"%s\". You're going to have to either adjust the path of the resource or disable path-based conneg in the enunciate config (e.g. usePathBasedConneg=\"false\").", id, fullpath, id, fullpath.substring(fullpath.indexOf(contentTypeToId.getValue()) + contentTypeToId.getValue().length())));
                    }

                    debug("Resource method %s of resource %s to be made accessible at subcontext \"%s\" because it produces %s/%s.",
                          resourceMethod.getSimpleName(), resourceMethod.getParent().getQualifiedName(), id, producesType.getType(), producesType.getSubtype());
                    String contentTypeValue = String.format("%s/%s", type.getType(), type.getSubtype());
View Full Code Here

      //we're going to process the JAX-RS thrown types annotated with @WebFault in case we ever want to serialize the fault beans as XML...
      for (RootResource rootResource : model.getRootResources()) {
        for (ResourceMethod resourceMethod : rootResource.getResourceMethods(true)) {
          for (ReferenceType referenceType : resourceMethod.getThrownTypes()) {
            if (!(referenceType instanceof DeclaredType)) {
              throw new ValidationException(resourceMethod.getPosition(), "Method " + resourceMethod + " of " + resourceMethod.getParent().getQualifiedName() + ": thrown type must be a declared type.");
            }

            TypeDeclaration declaration = ((DeclaredType) referenceType).getDeclaration();

            if (declaration == null) {
              throw new ValidationException(resourceMethod.getPosition(), "Method " + resourceMethod + " of " + resourceMethod.getParent().getQualifiedName() + ": unknown declaration for " + referenceType);
            }
            else if (declaration.getAnnotation(javax.xml.ws.WebFault.class) != null) {
              WebFault fault = new WebFault((ClassDeclaration) declaration);
              if (fault.isImplicitSchemaElement() && visitedFaults.add(fault)) {
                model.put("message", fault);
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.