Package ca.uhn.fhir.context

Examples of ca.uhn.fhir.context.ConfigurationException


   *             If the interface type is not an interface
   */
  @Override
  public synchronized <T extends IRestfulClient> T newClient(Class<T> theClientType, String theServerBase) {
    if (!theClientType.isInterface()) {
      throw new ConfigurationException(theClientType.getCanonicalName() + " is not an interface");
    }

    HttpClient client = getHttpClient();

    String serverBase = theServerBase;
View Full Code Here


      setValue(value);
     
    } catch (XMLStreamException e) {
      throw new DataFormatException("String does not appear to be valid XML/XHTML (error is \""+e.getMessage() + "\"): " + theValue, e);
    } catch (FactoryConfigurationError e) {
      throw new ConfigurationException(e);
    }
  }
View Full Code Here

      ew.close();
      return w.toString();
    } catch (XMLStreamException e) {
      throw new DataFormatException("Problem with the contained XML events", e);
    } catch (FactoryConfigurationError e) {
      throw new ConfigurationException(e);
    }
  }
View Full Code Here

    BaseRuntimeElementCompositeDefinition<?> currentDef = def;

    List<String> parts = Arrays.asList(thePath.split("\\."));
    List<String> subList = parts.subList(1, parts.size());
    if (subList.size() < 1) {
      throw new ConfigurationException("Invalid path: " + thePath);
    }
    return getDefinition(currentDef, subList);

  }
View Full Code Here

    Object currentObj = theResource;

    List<String> parts = Arrays.asList(thePath.split("\\."));
    List<String> subList = parts.subList(1, parts.size());
    if (subList.size() < 1) {
      throw new ConfigurationException("Invalid path: " + thePath);
    }
    return getValues(currentDef, currentObj, subList);

  }
View Full Code Here

    } else {
      if (theProvider != null && theProvider instanceof IResourceProvider) {
        RuntimeResourceDefinition def = theContext.getResourceDefinition(((IResourceProvider) theProvider).getResourceType());
        myResourceName = def.getName();
      } else {
        throw new ConfigurationException("Can not determine resource type for method '" + theMethod.getName() + "' on type " + theMethod.getDeclaringClass().getCanonicalName() + " - Did you forget to include the resourceType() value on the @"
            + Delete.class.getSimpleName() + " method annotation?");
      }
    }

    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");
    }

    Integer versionIdParameterIndex = ParameterUtil.findVersionIdParameterIndex(theMethod);
    if (versionIdParameterIndex != null) {
      throw new ConfigurationException("Method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName() + "' has a parameter annotated with the @" + VersionIdParam.class.getSimpleName()
          + " annotation but delete methods may not have this annotation");
    }

  }
View Full Code Here

      }
      for (String next : propFileName) {
        loadProperties(next);
      }
    } catch (IOException e) {
      throw new ConfigurationException("Can not load property file " + propFileName, e);
    }

    {
      myProfileTemplateEngine = new TemplateEngine();
      TemplateResolver resolver = new TemplateResolver();
View Full Code Here

        String narrativePropName = name + ".narrative";
        String narrativeName = file.getProperty(narrativePropName);
        String titlePropName = name + ".title";
        String titleName = file.getProperty(titlePropName);
        if (isBlank(narrativeName) && isBlank(titleName)) {
          throw new ConfigurationException("Found property '" + nextKey + "' but no corresponding property '" + narrativePropName + "' or '" + titlePropName + "' in file " + propFileName);
        }

        myProfileToName.put(file.getProperty(nextKey), name);

        if (StringUtils.isNotBlank(narrativeName)) {
          String narrative = IOUtils.toString(loadResource(narrativeName));
          myNameToNarrativeTemplate.put(name, narrative);
        }
        if (StringUtils.isNotBlank(titleName)) {
          String title = IOUtils.toString(loadResource(titleName));
          myNameToTitleTemplate.put(name, title);
        }

      } else if (nextKey.endsWith(".class")) {

        String name = nextKey.substring(0, nextKey.indexOf(".class"));
        if (isBlank(name)) {
          continue;
        }

        String className = file.getProperty(nextKey);

        Class<?> clazz;
        try {
          clazz = Class.forName(className);
        } catch (ClassNotFoundException e) {
          ourLog.warn("Unknown datatype class '{}' identified in narrative file {}", name, propFileName);
          continue;
        }

        String narrativePropName = name + ".narrative";
        String narrativeName = file.getProperty(narrativePropName);
        String titlePropName = name + ".title";
        String titleName = file.getProperty(titlePropName);
        if (isBlank(narrativeName) && isBlank(titleName)) {
          throw new ConfigurationException("Found property '" + nextKey + "' but no corresponding property '" + narrativePropName + "' or '" + titlePropName + "' in file " + propFileName);
        }

        myClassToName.put(clazz, name);

        if (StringUtils.isNotBlank(narrativeName)) {
          String narrative = IOUtils.toString(loadResource(narrativeName));
          myNameToNarrativeTemplate.put(name, narrative);
        }
        if (StringUtils.isNotBlank(titleName)) {
          String title = IOUtils.toString(loadResource(titleName));
          myNameToTitleTemplate.put(name, title);
        }

      } else if (nextKey.endsWith(".narrative")) {
        continue;
      } else if (nextKey.endsWith(".title")) {
        continue;
      } else {
        throw new ConfigurationException("Invalid property name: " + nextKey);
      }

    }
  }
View Full Code Here

    Class<? extends IResource> returnTypeFromRp = null;
    if (theProvider instanceof IResourceProvider) {
      returnTypeFromRp = ((IResourceProvider) theProvider).getResourceType();
      if (!verifyIsValidResourceReturnType(returnTypeFromRp)) {
        throw new ConfigurationException("getResourceType() from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returned " + toLogString(returnTypeFromRp) + " - Must return a resource type");
      }
    }

    Class<?> returnTypeFromMethod = theMethod.getReturnType();
    if (getTags != null) {
      if (!TagList.class.equals(returnTypeFromMethod)) {
        throw new ConfigurationException("Method '" + theMethod.getName() + "' from type " + theMethod.getDeclaringClass().getCanonicalName() + " is annotated with @" + GetTags.class.getSimpleName() + " but does not return type " + TagList.class.getName());
      }
    } else if (MethodOutcome.class.equals(returnTypeFromMethod)) {
      // returns a method outcome
    } else if (IBundleProvider.class.equals(returnTypeFromMethod)) {
      // returns a bundle provider
    } else if (Bundle.class.equals(returnTypeFromMethod)) {
      // returns a bundle
    } else if (void.class.equals(returnTypeFromMethod)) {
      // returns a bundle
    } else if (Collection.class.isAssignableFrom(returnTypeFromMethod)) {
      returnTypeFromMethod = ReflectionUtil.getGenericCollectionTypeOfMethodReturnType(theMethod);
      if (!verifyIsValidResourceReturnType(returnTypeFromMethod) && !IResource.class.equals(returnTypeFromMethod)) {
        throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns a collection with generic type " + toLogString(returnTypeFromMethod)
            + " - Must return a resource type or a collection (List, Set) with a resource type parameter (e.g. List<Patient> or List<IResource> )");
      }
    } else {
      if (!IResource.class.equals(returnTypeFromMethod) && !verifyIsValidResourceReturnType(returnTypeFromMethod)) {
        throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns " + toLogString(returnTypeFromMethod)
            + " - Must return a resource type (eg Patient, " + Bundle.class.getSimpleName() + ", " + IBundleProvider.class.getSimpleName() + ", etc., see the documentation for more details)");
      }
    }

    Class<? extends IResource> returnTypeFromAnnotation = IResource.class;
    if (read != null) {
      returnTypeFromAnnotation = read.type();
    } else if (search != null) {
      returnTypeFromAnnotation = search.type();
    } else if (history != null) {
      returnTypeFromAnnotation = history.type();
    } else if (delete != null) {
      returnTypeFromAnnotation = delete.type();
    } else if (create != null) {
      returnTypeFromAnnotation = create.type();
    } else if (update != null) {
      returnTypeFromAnnotation = update.type();
    } else if (validate != null) {
      returnTypeFromAnnotation = validate.type();
    } else if (getTags != null) {
      returnTypeFromAnnotation = getTags.type();
    } else if (addTags != null) {
      returnTypeFromAnnotation = addTags.type();
    } else if (deleteTags != null) {
      returnTypeFromAnnotation = deleteTags.type();
    }

    if (returnTypeFromRp != null) {
      if (returnTypeFromAnnotation != null && returnTypeFromAnnotation != IResource.class) {
        if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) {
          throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " returns type " + returnTypeFromMethod.getCanonicalName() + " - Must return " + returnTypeFromRp.getCanonicalName()
              + " (or a subclass of it) per IResourceProvider contract");
        }
        if (!returnTypeFromRp.isAssignableFrom(returnTypeFromAnnotation)) {
          throw new ConfigurationException("Method '" + theMethod.getName() + "' in type " + theMethod.getDeclaringClass().getCanonicalName() + " claims to return type " + returnTypeFromAnnotation.getCanonicalName() + " per method annotation - Must return "
              + returnTypeFromRp.getCanonicalName() + " (or a subclass of it) per IResourceProvider contract");
        }
        returnType = returnTypeFromAnnotation;
      } else {
        returnType = returnTypeFromRp;
      }
    } else {
      if (returnTypeFromAnnotation != IResource.class) {
        if (!verifyIsValidResourceReturnType(returnTypeFromAnnotation)) {
          throw new ConfigurationException("Method '" + theMethod.getName() + "' from " + IResourceProvider.class.getSimpleName() + " type " + theMethod.getDeclaringClass().getCanonicalName() + " returns " + toLogString(returnTypeFromAnnotation)
              + " according to annotation - Must return a resource type");
        }
        returnType = returnTypeFromAnnotation;
      } else {
        returnType = (Class<? extends IResource>) returnTypeFromMethod;
      }
    }

    if (read != null) {
      return new ReadMethodBinding(returnType, theMethod, theContext, theProvider);
    } else if (search != null) {
      return new SearchMethodBinding(returnType, theMethod, theContext, theProvider);
    } else if (conformance != null) {
      return new ConformanceMethodBinding(theMethod, theContext, theProvider);
    } else if (create != null) {
      return new CreateMethodBinding(theMethod, theContext, theProvider);
    } else if (update != null) {
      return new UpdateMethodBinding(theMethod, theContext, theProvider);
    } else if (delete != null) {
      return new DeleteMethodBinding(theMethod, theContext, theProvider);
    } else if (history != null) {
      return new HistoryMethodBinding(theMethod, theContext, theProvider);
    } else if (validate != null) {
      return new ValidateMethodBinding(theMethod, theContext, theProvider);
    } else if (getTags != null) {
      return new GetTagsMethodBinding(theMethod, theContext, theProvider, getTags);
    } else if (addTags != null) {
      return new AddTagsMethodBinding(theMethod, theContext, theProvider, addTags);
    } else if (deleteTags != null) {
      return new DeleteTagsMethodBinding(theMethod, theContext, theProvider, deleteTags);
    } else if (transaction != null) {
      return new TransactionMethodBinding(theMethod, theContext, theProvider);
    } else {
      throw new ConfigurationException("Did not detect any FHIR annotations on method '" + theMethod.getName() + "' on type: " + theMethod.getDeclaringClass().getCanonicalName());
    }

    // // each operation name must have a request type annotation and be
    // unique
    // if (null != read) {
View Full Code Here

    for (Object object : theAnnotations) {
      if (object != null) {
        if (obj1 == null) {
          obj1 = object;
        } else {
          throw new ConfigurationException("Method " + theNextMethod.getName() + " on type '" + theNextMethod.getDeclaringClass().getSimpleName() + " has annotations @" + obj1.getClass().getSimpleName() + " and @" + object.getClass().getSimpleName()
              + ". Can not have both.");
        }

      }
    }
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.