Package ca.uhn.fhir.context

Examples of ca.uhn.fhir.context.ConfigurationException


      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

  private void encodeResourceToXmlStreamWriter(IResource theResource, XMLStreamWriter theEventWriter, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
    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

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

    myResourceType = theReturnResourceType;
    if (theReturnResourceType != null) {
      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

    try {
      b.append(URLEncoder.encode(nextKey, "UTF-8"));
      b.append('=');
      b.append(URLEncoder.encode(nextValue, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
      throw new ConfigurationException("Could not find UTF-8 encoding. This shouldn't happen.", e);
    }
    return first;
  }
View Full Code Here

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

    myIdParameterIndex = ParameterUtil.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 = ParameterUtil.findVersionIdParameterIndex(theMethod);
  }
View Full Code Here

          outerCollectionType = innerCollectionType;
          innerCollectionType = (Class<? extends java.util.Collection<?>>) parameterType;
          parameterType = ReflectionUtil.getGenericCollectionTypeOfMethodParameter(theMethod, paramIndex);
        }
        if (Collection.class.isAssignableFrom(parameterType)) {
          throw new ConfigurationException("Argument #" + paramIndex + " of Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is of an invalid generic type (can not be a collection of a collection of a collection)");
        }
      }
      if (parameterType.equals(HttpServletRequest.class) || parameterType.equals(ServletRequest.class)) {
        param = new ServletRequestParameter();
      } else if (parameterType.equals(HttpServletResponse.class) || parameterType.equals(ServletResponse.class)) {
        param = new ServletResponseParameter();
      } else {
        for (int i = 0; i < annotations.length && param == null; i++) {
          Annotation nextAnnotation = annotations[i];

          if (nextAnnotation instanceof RequiredParam) {
            SearchParameter parameter = new SearchParameter();
            parameter.setName(((RequiredParam) nextAnnotation).name());
            parameter.setRequired(true);
            parameter.setType(parameterType, innerCollectionType, outerCollectionType);
            extractDescription(parameter, annotations);
            param = parameter;
          } else if (nextAnnotation instanceof OptionalParam) {
            SearchParameter parameter = new SearchParameter();
            parameter.setName(((OptionalParam) nextAnnotation).name());
            parameter.setRequired(false);
            parameter.setType(parameterType, innerCollectionType, outerCollectionType);
            extractDescription(parameter, annotations);
            param = parameter;
          } else if (nextAnnotation instanceof IncludeParam) {
            Class<? extends Collection<PathSpecification>> instantiableCollectionType;
            Class<?> specType;

            if (parameterType == String.class) {
              instantiableCollectionType = null;
              specType = String.class;
            } else if (parameterType != PathSpecification.class || innerCollectionType == null || outerCollectionType != null) {
              throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + IncludeParam.class.getSimpleName() + " but has a type other than Collection<" + PathSpecification.class.getSimpleName() + ">");
            } else {
              instantiableCollectionType = (Class<? extends Collection<PathSpecification>>) CollectionBinder.getInstantiableCollectionType(innerCollectionType, "Method '" + theMethod.getName() + "'");
              specType = PathSpecification.class;
            }

            param = new IncludeParameter((IncludeParam) nextAnnotation, instantiableCollectionType, specType);
          } else if (nextAnnotation instanceof ResourceParam) {
            if (!IResource.class.isAssignableFrom(parameterType)) {
              throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + ResourceParam.class.getSimpleName() + " but has a type that is not an implemtation of " + IResource.class.getCanonicalName());
            }
            param = new ResourceParameter((Class<? extends IResource>) parameterType);
          } else if (nextAnnotation instanceof IdParam || nextAnnotation instanceof VersionIdParam) {
            param = new NullParameter();
          } else if (nextAnnotation instanceof ServerBase) {
            param = new ServerBaseParameter();
          } else if (nextAnnotation instanceof Since) {
            param = new SinceParameter();
          } else if (nextAnnotation instanceof Count) {
            param = new CountParameter();
          } else {
            continue;
          }

        }

      }

      if (param == null) {
        throw new ConfigurationException("Parameter #" + paramIndex + " of method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName()
            + "' has no recognized FHIR interface parameter annotations. Don't know how to handle this parameter");
      }

      param.initializeTypes(theMethod, outerCollectionType, innerCollectionType, parameterType);
      parameters.add(param);
View Full Code Here

        theEventWriter.writeEnd();
      } else {
        RuntimeChildUndeclaredExtensionDefinition extDef = myContext.getRuntimeChildUndeclaredExtensionDefinition();
        String childName = extDef.getChildNameByDatatype(value.getClass());
        if (childName == null) {
          throw new ConfigurationException("Unable to encode extension, unregognized child element type: " + value.getClass().getCanonicalName());
        }
        BaseRuntimeElementDefinition<?> childDef = extDef.getChildElementDefinitionByDatatype(value.getClass());
        encodeChildElementToStreamWriter(theResDef, theResource, theEventWriter, value, childDef, childName);
      }
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.