@Override public void addValue(Object theTarget, IBase theValue) { try { myField.set(theTarget, theValue); } catch (Exception e) { throw new ConfigurationException("Failed to set value", e); } }
private String parseWarmUrlParamPart(String theNextUrl) { int paramIndex = theNextUrl.indexOf('?'); if (paramIndex == -1) { throw new ConfigurationException("Invalid warm cache URL (must have ? character)"); } return theNextUrl.substring(paramIndex); }
@Override public InputStream getFhirVersionPropertiesFile() { InputStream str = FhirDstu2.class.getResourceAsStream("/ca/uhn/fhir/model/dstu2/fhirversion.properties"); if (str == null) { str = FhirDstu2.class.getResourceAsStream("ca/uhn/fhir/model/dstu2/fhirversion.properties"); } if (str == null) { throw new ConfigurationException("Can not find model property file on classpath: " + "/ca/uhn/fhir/model/dstu2/fhirversion.properties"); } return str; }
@Override public void initializeTypes(Method theMethod, Class<? extends Collection<?>> theOuterCollectionType, Class<? extends Collection<?>> theInnerCollectionType, Class<?> theParameterType) { if (theOuterCollectionType != null) { throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is of type " + SummaryEnum.class + " but can not be a collection of collections"); } }
static Object toEnumFactory(Class<?> theEnumerationType) { Class<?> clazz; String className = theEnumerationType.getName() + "EnumFactory"; Object retVal; try { clazz = Class.forName(className); retVal = clazz.newInstance(); } catch (Exception e) { throw new ConfigurationException("Failed to instantiate " + className, e); } return retVal; }
@Override public void initializeTypes(Method theMethod, Class<? extends Collection<?>> theOuterCollectionType, Class<? extends Collection<?>> theInnerCollectionType, Class<?> theParameterType) { if (theOuterCollectionType != null || theInnerCollectionType != null) { throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is annotated with @" + Sort.class.getName() + " but can not be of collection type"); } if (!theParameterType.equals(SortSpec.class)) { throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is annotated with @" + Sort.class.getName() + " but is an invalid type, must be: " + SortSpec.class.getCanonicalName()); } }
@Override public void initializeTypes(Method theMethod, Class<? extends Collection<?>> theOuterCollectionType, Class<? extends Collection<?>> theInnerCollectionType, Class<?> theParameterType) { if (theOuterCollectionType != null) { throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is annotated with @" + Count.class.getName() + " but can not be of collection type"); } if (!ParameterUtil.isBindableIntegerType(theParameterType)) { throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is annotated with @" + Count.class.getName() + " but type '" + theParameterType + "' is an invalid type, must be Integer or IntegerType"); } }
public ConformanceMethodBinding(Method theMethod, FhirContext theContext, Object theProvider) { super(theMethod.getReturnType(), theMethod, theContext, theProvider); MethodReturnTypeEnum methodReturnType = getMethodReturnType(); Class<?> genericReturnType = (Class<?>) theMethod.getGenericReturnType(); if (methodReturnType != MethodReturnTypeEnum.RESOURCE || !IBaseConformance.class.isAssignableFrom(genericReturnType)) { throw new ConfigurationException("Conformance resource provider method '" + theMethod.getName() + "' should return a Conformance resource class, returns: " + theMethod.getReturnType()); } }
static XMLOutputFactory newOutputFactory() throws FactoryConfigurationError { XMLOutputFactory outputFactory; try { outputFactory = XMLOutputFactory.newInstance(); throwUnitTestExceptionIfConfiguredToDoSo(); } catch (Throwable e) { throw new ConfigurationException("Unable to initialize StAX - XML processing is disabled", e); } return outputFactory; }
@Override public void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { super.sealAndInitialize(theContext, theClassToElementDefinitions); if (myProfileOfType != null) { myProfileOf = theClassToElementDefinitions.get(myProfileOfType); if (myProfileOf == null) { throw new ConfigurationException("Unknown profileOf value: " + myProfileOfType); } } }
public BaseOutcomeReturningMethodBinding(Method theMethod, FhirContext theContext, Class<?> theMethodAnnotation, Object theProvider) { super(theMethod, theContext, theProvider); if (!theMethod.getReturnType().equals(MethodOutcome.class)) { if (!allowVoidReturnType()) { throw new ConfigurationException("Method " + theMethod.getName() + " in type " + theMethod.getDeclaringClass().getCanonicalName() + " is a @" + theMethodAnnotation.getSimpleName() + " method but it does not return " + MethodOutcome.class); } else if (theMethod.getReturnType() == void.class) { myReturnVoid = true; } } }
public BaseOutcomeReturningMethodBinding(Method theMethod, FhirContext theContext, Class<?> theMethodAnnotation, Object theProvider) { super(theMethod, theContext, theProvider); if (!theMethod.getReturnType().equals(MethodOutcome.class)) { if (!allowVoidReturnType()) { throw new ConfigurationException("Method " + theMethod.getName() + " in type " + theMethod.getDeclaringClass().getCanonicalName() + " is a @" + theMethodAnnotation.getSimpleName() + " method but it does not return " + MethodOutcome.class); } else if (theMethod.getReturnType() == void.class) { myReturnVoid = true; } } }
static Class<?> determineElementType(Field next) { Class<?> nextElementType = next.getType(); if (List.class.equals(nextElementType)) { nextElementType = ReflectionUtil.getGenericCollectionTypeOfField(next); } else if (Collection.class.isAssignableFrom(nextElementType)) { throw new ConfigurationException("Field '" + next.getName() + "' in type '" + next.getClass().getCanonicalName() + "' is a Collection - Only java.util.List curently supported"); } return nextElementType; }
public BaseRuntimeChildDefinition getDefinition(Class<? extends IBaseResource> theResourceType, String thePath) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResourceType); 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); }
/** * The default constructor. */ protected AbstractJaxRsPageProvider() { try { myBinding = new PageMethodBinding(getFhirContext(), PageProvider.class.getMethod("getPage")); } catch (Exception e) { throw new ca.uhn.fhir.context.ConfigurationException(e); } }
@Override public void doEncodeResourceToWriter(IBaseResource theResource, Writer theWriter) throws DataFormatException { XMLStreamWriter eventWriter; try { eventWriter = createXmlWriter(theWriter); encodeResourceToXmlStreamWriter(theResource, eventWriter, false, false); eventWriter.flush(); } catch (XMLStreamException e) { throw new ConfigurationException("Failed to initialize STaX event factory", e); } }
/** * Provides the ability to set the {@link FhirContext} instance. * @param ctx the {@link FhirContext} instance. */ protected AbstractJaxRsPageProvider(FhirContext ctx) { super(ctx); try { myBinding = new PageMethodBinding(getFhirContext(), PageProvider.class.getMethod("getPage")); } catch (Exception e) { throw new ca.uhn.fhir.context.ConfigurationException(e); } }
public T newInstance(Object theArgument) { try { if (theArgument == null) { return getConstructor(null).newInstance(); } return getConstructor(theArgument).newInstance(theArgument); } catch (Exception e) { throw new ConfigurationException("Failed to instantiate type:" + getImplementingClass().getName(), e); } }
/** * Express {@link #getImplementingClass()} as theClass (to prevent casting warnings) */ @SuppressWarnings("unchecked") public <T> Class<T> getImplementingClass(Class<T> theClass) { if (!theClass.isAssignableFrom(getImplementingClass())) { throw new ConfigurationException("Unable to convert " + getImplementingClass() + " to " + theClass); } return (Class<T>) getImplementingClass(); }
public CanonicalSubscription canonicalize(S theSubscription) { switch (myFhirContext.getVersion().getVersion()) { case DSTU2: return canonicalizeDstu2(theSubscription); case DSTU3: return canonicalizeDstu3(theSubscription); case R4: return canonicalizeR4(theSubscription); default: throw new ConfigurationException("Subscription not supported for version: " + myFhirContext.getVersion().getVersion()); } }