Package org.codehaus.enunciate.contract.validation

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


    QName refQName = null;
    if (refType.isInstanceOf(JAXBElement.class.getName())) {
      String localName = xmlElementRef != null && !"##default".equals(xmlElementRef.name()) ? xmlElementRef.name() : null;
      String namespace = xmlElementRef != null ? xmlElementRef.namespace() : "";
      if (localName == null) {
        throw new ValidationException(getPosition(), "Member " + getName() + " of " + getTypeDefinition().getQualifiedName() + ": @XmlElementRef annotates a type JAXBElement without specifying the name of the JAXB element.");
      }
      refQName = new QName(namespace, localName);
    }
    else if (declaration instanceof ClassDeclaration && declaration.getAnnotation(XmlRootElement.class) != null) {
      ClassDeclaration classDeclaration = (ClassDeclaration) declaration;
      RootElementDeclaration refElement = new RootElementDeclaration(classDeclaration, ((EnunciateFreemarkerModel) FreemarkerModel.get()).findTypeDefinition(classDeclaration));
      refQName = new QName(refElement.getNamespace(), refElement.getName());
    }

    if (refQName == null) {
      throw new ValidationException(getPosition(), "Member " + getSimpleName() + " of " + getTypeDefinition().getQualifiedName() + ": " + elementDeclaration + " is neither JAXBElement nor a root element declaration.");
    }

    return refQName;
  }
View Full Code Here


    if (baseType == null) {
      try {
        baseType = XmlTypeFactory.getXmlType(getSuperclass());
      }
      catch (XmlTypeException e) {
        throw new ValidationException(getPosition(), getQualifiedName() + ": " + e.getMessage());
      }
    }

    return baseType;
  }
View Full Code Here

    }

    if ((faultInfoProperty != null) && (faultInfoProperty.getPropertyType() instanceof ClassType)) {
      ClassType faultInfoType = (ClassType) faultInfoProperty.getPropertyType();
      if (faultInfoType.getDeclaration() == null) {
        throw new ValidationException(getPosition(), getQualifiedName() + ": class not found: " + faultInfoType + ".");
      }

      boolean messageConstructorFound = false;
      boolean messageAndThrowableConstructorFound = false;
      Collection<ConstructorDeclaration> constructors = getConstructors();
      for (ConstructorDeclaration constructor : constructors) {
        if (constructor.getModifiers().contains(Modifier.PUBLIC)) {
          ParameterDeclaration[] parameters = constructor.getParameters().toArray(new ParameterDeclaration[constructor.getParameters().size()]);
          if (parameters.length >= 2) {
            DecoratedTypeMirror param0Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[0].getType());
            DecoratedTypeMirror param1Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[1].getType());
            if (parameters.length == 2) {
              messageConstructorFound |= param0Type.isInstanceOf(String.class.getName()) && param1Type.isInstanceOf(faultInfoType.getDeclaration().getQualifiedName());
            }
            else if (parameters.length == 3) {
              DecoratedTypeMirror param2Type = (DecoratedTypeMirror) TypeMirrorDecorator.decorate(parameters[2].getType());
              messageAndThrowableConstructorFound |= param0Type.isInstanceOf(String.class.getName())
                && param1Type.isInstanceOf(faultInfoType.getDeclaration().getQualifiedName())
                && param2Type.isInstanceOf(Throwable.class.getName());
            }
          }
        }
      }

      if (messageConstructorFound && messageAndThrowableConstructorFound) {
        explicitFaultBeanType = faultInfoType;
      }
    }

    if (faultInfoProperty != null && explicitFaultBeanType == null) {
      throw new ValidationException(faultInfoProperty.getPosition(), "The 'getFaultInfo' method is only allowed on a web fault if you're " +
        "declaring an explicit fault bean, and you don't have the right constructor signatures set up in order for '" +
        faultInfoProperty.getPropertyType() + "' to be an explicit fault bean.");
    }

    this.explicitFaultBeanType = explicitFaultBeanType;
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 fault 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

            }
          }


          if (index1 < 0) {
            throw new ValidationException(WebFault.this.getPosition(), WebFault.this.getQualifiedName() + ": @WebFaultPropertyOrder doesn't specify a property '" + o1.getElementName() + "'.");
          }
          else if (index2 < 0) {
            throw new ValidationException(WebFault.this.getPosition(), WebFault.this.getQualifiedName() + ": @WebFaultPropertyOrder doesn't specify a property '" + o2.getElementName() + "'.");
          }
          else {
            return index1 - index2;
          }
        }
View Full Code Here

          xmlType = XmlTypeFactory.getXmlType(getType());
        }
        return xmlType;
      }
      catch (XmlTypeException e) {
        throw new ValidationException(property.getPosition(), "Error with property '" + property.getPropertyName() + "' of fault '" +
          webFault.getQualifiedName() + "'. " + e.getMessage());
      }
    }
View Full Code Here

          return null;
        }
        return new ResourceRepresentationMetadata(typeMirror, returnType.getDocValue());
      }
      else {
        throw new ValidationException(getPosition(), "Illegal output type (must be a declared type): " + typeMirror);
      }
    }

    return null;
  }
View Full Code Here

        else {
          return new ResourceEntityParameter(((DeclaredType) typeMirror).getDeclaration(), typeMirror);
        }
      }
      else {
        throw new ValidationException(getPosition(), "Illegal input type (must be a declared type): " + typeMirror);
      }
    }

    return null;
  }
View Full Code Here

    this.webParams = webParameters;

    Collection<WebFault> webFaults = new ArrayList<WebFault>();
    for (ReferenceType referenceType : getThrownTypes()) {
      if (!(referenceType instanceof DeclaredType)) {
        throw new ValidationException(getPosition(), "Method " + getSimpleName() + " of " + endpointInterface.getQualifiedName() + ": Thrown type must be a declared type.");
      }

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

      if (declaration == null) {
        throw new ValidationException(getPosition(), "Method " + getSimpleName() + " of " + endpointInterface.getQualifiedName() + ": unknown declaration for " + referenceType);
      }

      webFaults.add(new WebFault((ClassDeclaration) declaration));
    }
    this.webFaults = webFaults;
View Full Code Here

        return declaration;
      }
      else {
        ClassDeclaration adaptingDeclaration = ((ClassType) adaptingType).getDeclaration();
        if (adaptingDeclaration == null) {
          throw new ValidationException(declaration.getPosition(), String.format("Class %s is being adapted by a type (%s) that doesn't seem to be on the classpath.", declaration.getQualifiedName(), adaptingType));
        }
        return adaptingDeclaration;
      }
    }
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.