@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 void findResourceMethods(Object theProvider) { ourLog.info("Scanning type for RESTful methods: {}", theProvider.getClass()); int count = 0; Class<?> clazz = theProvider.getClass(); Class<?> supertype = clazz.getSuperclass(); while (!Object.class.equals(supertype)) { count += findResourceMethods(theProvider, supertype); supertype = supertype.getSuperclass(); } try { count += findResourceMethods(theProvider, clazz); } catch (ConfigurationException e) { throw new ConfigurationException("Failure scanning class " + clazz.getSimpleName() + ": " + e.getMessage(), e); } if (count == 0) { throw new ConfigurationException("Did not find any annotated RESTful methods on provider class " + theProvider.getClass().getCanonicalName()); } }
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 || theInnerCollectionType != null || theParameterType.equals(String.class) == false) { throw new ConfigurationException("Parameters annotated with @" + ConditionalUrlParam.class.getSimpleName() + " must be of type String, found incorrect parameteter in method \"" + theMethod + "\""); } }
@Override public void initializeTypes(Method theMethod, Class<? extends Collection<?>> theOuterCollectionType, Class<? extends Collection<?>> theInnerCollectionType, Class<?> theParameterType) { if (theOuterCollectionType != null || theInnerCollectionType != null || theParameterType.equals(String.class) == false) { throw new ConfigurationException( "Parameters annotated with @" + ConditionalUrlParam.class.getSimpleName() + " must be of type String, found incorrect parameteter in method \"" + theMethod + "\""); } }
@Override public InputStream getFhirVersionPropertiesFile() { String path = "org/hl7/fhir/r4/model/fhirversion.properties"; InputStream str = FhirR4.class.getResourceAsStream("/" + path); if (str == null) { str = FhirR4.class.getResourceAsStream(path); } if (str == null) { throw new ConfigurationException("Can not find model property file on classpath: " + path); } return str; }
@Override public InputStream getFhirVersionPropertiesFile() { InputStream str = FhirDstu2_1.class.getResourceAsStream("/org/hl7/fhir/dstu2016may/model/fhirversion.properties"); if (str == null) { str = FhirDstu2_1.class.getResourceAsStream("/org/hl7/fhir/dstu2016may/model/fhirversion.properties"); } if (str == null) { throw new ConfigurationException("Can not find model property file on classpath: " + "/ca/uhn/fhir/model/dstu2016may/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) { throw new ConfigurationException("Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName() + "' is of type " + SummaryEnum.class + " but can not be a collection of collections"); } }
@Override public InputStream getFhirVersionPropertiesFile() { String path = "/org/hl7/fhir/instance/model/fhirversion.properties"; InputStream str = FhirDstu2Hl7Org.class.getResourceAsStream(path); if (str == null) { str = FhirDstu2Hl7Org.class.getResourceAsStream(path.substring(1)); } if (str == null) { throw new ConfigurationException("Can not find model property file on classpath: " + path); } return str; }
public CompositeParam(Class<A> theLeftType, Class<B> theRightType) { Validate.notNull(theLeftType); Validate.notNull(theRightType); try { myLeftType = theLeftType.newInstance(); } catch (InstantiationException e) { throw new ConfigurationException("Failed to instantiate type: " + myLeftType, e); } catch (IllegalAccessException e) { throw new ConfigurationException("Failed to instantiate type: " + myLeftType, e); } try { myRightType = theRightType.newInstance(); } catch (InstantiationException e) { throw new ConfigurationException("Failed to instantiate type: " + myRightType, e); } catch (IllegalAccessException e) { throw new ConfigurationException("Failed to instantiate type: " + myRightType, e); } }
public static <T> T newInstance(Class<T> theType, Class<?> theArgumentType, Object theArgument) { Validate.notNull(theType, "theType must not be null"); try { Constructor<T> constructor = theType.getConstructor(theArgumentType); return constructor.newInstance(theArgument); } catch (Exception e) { throw new ConfigurationException("Failed to instantiate " + theType.getName(), e); } }
@SuppressWarnings("unchecked") @Override public List<IBase> getValues(Object theTarget) { List<IBase> retVal; try { retVal = (List<IBase>) myField.get(theTarget); } catch (Exception e) { throw new ConfigurationException("Failed to get value", e); } if (retVal == null) { retVal = Collections.emptyList(); } return retVal; } }
@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 (!String.class.equals(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 one of Integer or IntegerType"); } myType = theParameterType; }
@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 || 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 List<IBase> getValues(Object theTarget) { try { Object values = myField.get(theTarget); if (values == null) { return Collections.emptyList(); } List<IBase> retVal = Collections.singletonList((IBase) values); return retVal; } catch (Exception e) { throw new ConfigurationException("Failed to get value", e); } } }
@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"); } }