Package ca.uhn.fhir.context

Examples of ca.uhn.fhir.context.ConfigurationException


      myMethodReturnType = MethodReturnTypeEnum.LIST_OF_RESOURCES;
      Class<?> collectionType = ReflectionUtil.getGenericCollectionTypeOfMethodReturnType(theMethod);
      if (collectionType != null) {
        if (!Object.class.equals(collectionType) && !IResource.class.isAssignableFrom(collectionType)) {
          throw new ConfigurationException("Method " + theMethod.getDeclaringClass().getSimpleName() + "#" + theMethod.getName() + " returns an invalid collection generic type: " + collectionType);
        }
      }
      myResourceListCollectionType = collectionType;

    } else if (IResource.class.isAssignableFrom(methodReturnType)) {
      myMethodReturnType = MethodReturnTypeEnum.RESOURCE;
    } else if (Bundle.class.isAssignableFrom(methodReturnType)) {
      myMethodReturnType = MethodReturnTypeEnum.BUNDLE;
    } else if (IBundleProvider.class.isAssignableFrom(methodReturnType)) {
      myMethodReturnType = MethodReturnTypeEnum.BUNDLE_PROVIDER;
    } else {
      throw new ConfigurationException("Invalid return type '" + methodReturnType.getCanonicalName() + "' on method '" + theMethod.getName() + "' on type: " + theMethod.getDeclaringClass().getCanonicalName());
    }

    if (theReturnResourceType != null) {
      if (IResource.class.isAssignableFrom(theReturnResourceType)) {
        myResourceType = theReturnResourceType;
        ResourceDef resourceDefAnnotation = theReturnResourceType.getAnnotation(ResourceDef.class);
        if (resourceDefAnnotation == null) {
          throw new ConfigurationException(theReturnResourceType.getCanonicalName() + " has no @" + ResourceDef.class.getSimpleName() + " annotation");
        }
        myResourceName = resourceDefAnnotation.name();
      }
    }
  }
View Full Code Here


      }

      eventWriter.writeEndElement();
      eventWriter.close();
    } catch (XMLStreamException e) {
      throw new ConfigurationException("Failed to initialize STaX event factory", e);
    }
  }
View Full Code Here

      eventWriter = createXmlWriter(theWriter);

      encodeResourceToXmlStreamWriter(theResource, eventWriter, false);
      eventWriter.flush();
    } catch (XMLStreamException e) {
      throw new ConfigurationException("Failed to initialize STaX event factory", e);
    }
  }
View Full Code Here

      }

      eventWriter.writeEndElement();
      eventWriter.close();
    } catch (XMLStreamException e) {
      throw new ConfigurationException("Failed to initialize STaX event factory", e);
    }
  }
View Full Code Here

    try {
      streamReader = myXmlInputFactory.createXMLEventReader(theReader);
    } catch (XMLStreamException e) {
      throw new DataFormatException(e);
    } catch (FactoryConfigurationError e) {
      throw new ConfigurationException("Failed to initialize STaX event factory", e);
    }
    return streamReader;
  }
View Full Code Here

      super.containResourcesForEncoding(theResource);
    }

    RuntimeResourceDefinition resDef = myContext.getResourceDefinition(theResource);
    if (resDef == null) {
      throw new ConfigurationException("Unknown resource type: " + theResource.getClass());
    }

    theEventWriter.writeStartElement(resDef.getName());
    theEventWriter.writeDefaultNamespace(FHIR_NS);
View Full Code Here

      if (next.getValue() != null) {
        IElement nextValue = next.getValue();
        RuntimeChildUndeclaredExtensionDefinition extDef = myContext.getRuntimeChildUndeclaredExtensionDefinition();
        String childName = extDef.getChildNameByDatatype(nextValue.getClass());
        if (childName == null) {
          throw new ConfigurationException("Unable to encode extension, unregognized child element type: " + nextValue.getClass().getCanonicalName());
        }
        BaseRuntimeElementDefinition<?> childDef = extDef.getChildElementDefinitionByDatatype(nextValue.getClass());
        encodeChildElementToStreamWriter(theResDef, theResource, theWriter, nextValue, childName, childDef, null, theIncludedResource);
      }
View Full Code Here

      myParamBinder = new QueryParameterAndBinder((Class<? extends IQueryParameterAnd<?>>) type, myCompositeTypes);
    } else if (String.class.equals(type)) {
      myParamBinder = new StringBinder();
      myParamType = SearchParamTypeEnum.STRING;
    } else {
      throw new ConfigurationException("Unsupported data type for parameter: " + type.getCanonicalName());
    }

    SearchParamTypeEnum typeEnum = ourParamTypes.get(type);
    if (typeEnum != null) {
      Set<String> builtInQualifiers = ourParamQualifiers.get(typeEnum);
      if (builtInQualifiers != null) {
        if (myQualifierWhitelist != null) {
          HashSet<String> qualifierWhitelist = new HashSet<String>();
          qualifierWhitelist.addAll(myQualifierWhitelist);
          qualifierWhitelist.addAll(builtInQualifiers);
          myQualifierWhitelist = qualifierWhitelist;
        } else {
          myQualifierWhitelist = Collections.unmodifiableSet(builtInQualifiers);
        }
      }
    }

    if (myParamType == null) {
      myParamType = typeEnum;
    }

    if (myParamType != null) {
      // ok
    } else if (StringDt.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.STRING;
    } else if (QualifiedDateParam.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.DATE;
    } else if (CodingListParam.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.TOKEN;
    } else if (IdentifierDt.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.TOKEN;
    } else if (QuantityDt.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.QUANTITY;
    } else if (ReferenceParam.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.REFERENCE;
    } else if (IdentifierListParam.class.isAssignableFrom(type)) {
      myParamType = SearchParamTypeEnum.TOKEN;
    } else {
      throw new ConfigurationException("Unknown search parameter type: " + type);
    }

    // NB: Once this is enabled, we should return true from handlesMissing if
    // it's a collection type
    // if (theInnerCollectionType != null) {
View Full Code Here

    } else {
      myType = theTypeFromMethodAnnotation;
    }

    if (myType.equals(IResource.class)) {
      throw new ConfigurationException("Method '" + theMethod.getName() + "' does not specify a resource type, but has an @" + IdParam.class.getSimpleName() + " parameter. Please specity a resource type in the method annotation on this method");
    }
    myResourceName = theConetxt.getResourceDefinition(myType).getName();

    myIdParamIndex = MethodUtil.findIdParameterIndex(theMethod);
    myVersionIdParamIndex = MethodUtil.findVersionIdParameterIndex(theMethod);
    myTagListParamIndex = MethodUtil.findTagListParameterIndex(theMethod);

    if (myIdParamIndex == null) {
      throw new ConfigurationException("Method '" + theMethod.getName() + "' does not have an @" + IdParam.class.getSimpleName() + " parameter.");
    }

    if (myTagListParamIndex == null) {
      throw new ConfigurationException("Method '" + theMethod.getName() + "' does not have a parameter of type " + TagList.class.getSimpleName() + ", or paramater is not annotated with the @" + TagListParam.class.getSimpleName() + " annotation");
    }

  }
View Full Code Here

  public UpdateMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) {
    super(theMethod, theContext, Update.class, theProvider);

    myIdParameterIndex = MethodUtil.findIdParameterIndex(theMethod);
    if (myIdParameterIndex == null) {
      throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has no parameter annotated with the @" + IdParam.class.getSimpleName() + " annotation");
    }
    myVersionIdParameterIndex = MethodUtil.findVersionIdParameterIndex(theMethod);
  }
View Full Code Here

TOP

Related Classes of ca.uhn.fhir.context.ConfigurationException

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.