public static void validateResourceListNotNull(List<? extends IBaseResource> theResourceList) { if (theResourceList == null) { throw new InternalErrorException("IBundleProvider returned a null list of resources - This is not allowed"); } }
@Override public InputStream getInputStream() { try { return new FileInputStream(nextFile); } catch (FileNotFoundException theE) { throw new InternalErrorException(theE); } } });
private UrlEncodedFormEntity createFormEntity(List<NameValuePair> parameters) { try { return new UrlEncodedFormEntity(parameters, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new InternalErrorException("Server does not support UTF-8 (should not happen)", e); } }
RestulfulServerConfiguration getServerConfiguration() { try { return myServerConfiguration.call(); } catch (Exception e) { throw new InternalErrorException(e); } }
@Override public InputStream getInputStream() { try { return new FileInputStream(nextTemporaryFile); } catch (FileNotFoundException e) { throw new InternalErrorException(e); } } });
RestulfulServerConfiguration getServerConfiguration() { try { return myServerConfiguration.call(); } catch (Exception e) { throw new InternalErrorException(e); } }
RestulfulServerConfiguration getServerConfiguration() { try { return myServerConfiguration.call(); } catch (Exception e) { throw new InternalErrorException(e); } }
public T newInstance() { try { final Object[] args = new Object[myCompositeTypes.size()]; for (int i = 0; i < myCompositeTypes.size();i++) { args[i] = myCompositeTypes.get(i);//.newInstance(); } T dt = myConstructor.newInstance(args); return dt; } catch (final Exception e) { throw new InternalErrorException(e); } }
@CoverageIgnore protected IQueryParameterAnd newInstanceAnd(String chain) { IQueryParameterAnd type; Class<? extends IQueryParameterAnd> clazz = ResourceMetaParams.RESOURCE_META_AND_PARAMS.get(chain); try { type = clazz.newInstance(); } catch (Exception e) { throw new InternalErrorException("Failure creating instance of " + clazz, e); } return type; }
@CoverageIgnore public IQueryParameterType newInstanceType(String chain) { IQueryParameterType type; Class<? extends IQueryParameterType> clazz = ResourceMetaParams.RESOURCE_META_PARAMS.get(chain); try { type = clazz.newInstance(); } catch (Exception e) { throw new InternalErrorException("Failure creating instance of " + clazz, e); } return type; } }
private BaseServerResponseException preprocessException(final Throwable theException, final JaxRsRequest requestDetails) { try { Throwable theExceptionToConvert = theException; if (!(theException instanceof BaseServerResponseException) && (theException.getCause() instanceof BaseServerResponseException)) { theExceptionToConvert = theException.getCause(); } return exceptionHandler.preProcessOutgoingException(requestDetails, theExceptionToConvert, null); } catch (final ServletException e) { return new InternalErrorException(e); } }
private T refresh() { T retVal; try { retVal = myFetcher.call(); } catch (Exception e) { throw new InternalErrorException(e); } myCapabilityStatement.set(retVal); myLastFetched = now(); return retVal; }
public static IBaseOperationOutcome newInstance(FhirContext theCtx) { RuntimeResourceDefinition ooDef = theCtx.getResourceDefinition("OperationOutcome"); try { return (IBaseOperationOutcome) ooDef.getImplementingClass().newInstance(); } catch (InstantiationException e) { throw new InternalErrorException("Unable to instantiate OperationOutcome", e); } catch (IllegalAccessException e) { throw new InternalErrorException("Unable to instantiate OperationOutcome", e); } }
private static String getStringFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<String> theKey) { Object retValObj = theResourceMetadata.get(theKey); if (retValObj == null) { return null; } else if (retValObj instanceof String) { if (StringUtils.isBlank(((String) retValObj))) { return null; } return (String) retValObj; } throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected " + String.class.getCanonicalName()); }
@SuppressWarnings("unchecked") private static <T extends Enum<?>> T getEnumFromMetadataOrNullIfNone(Map<ResourceMetadataKeyEnum<?>, Object> theResourceMetadata, ResourceMetadataKeyEnum<T> theKey, Class<T> theEnumType, IValueSetEnumBinder<T> theBinder) { Object retValObj = theResourceMetadata.get(theKey); if (retValObj == null) { return null; } else if (theEnumType.equals(retValObj.getClass())) { return (T) retValObj; } else if (retValObj instanceof String) { return theBinder.fromCodeString((String) retValObj); } throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + theKey.name() + " - Expected " + InstantDt.class.getCanonicalName()); }
private IBaseResource findResource(Map<String, IBaseResource> theCandidateResources, IIdType theId) { IBaseResource retVal = theCandidateResources.get(theId.toUnqualifiedVersionless().getValue()); if (retVal == null) { throw new InternalErrorException("Unknown reference in ImplementationGuide: " + theId); } return retVal; }
private Source loadXml(String theSystemId, String theSchemaName) { String pathToBase = myCtx.getVersion().getPathToSchemaDefinitions() + '/' + theSchemaName; ourLog.debug("Going to load resource: {}", pathToBase); InputStream baseIs = FhirValidator.class.getResourceAsStream(pathToBase); if (baseIs == null) { throw new InternalErrorException("Schema not found. " + RESOURCES_JAR_NOTE); } baseIs = new BOMInputStream(baseIs, false); InputStreamReader baseReader = new InputStreamReader(baseIs, Charset.forName("UTF-8")); Source baseSource = new StreamSource(baseReader, theSystemId); //FIXME resource leak return baseSource; }
@Override public ExtensionDt get(IResource theResource) { Object retValObj = theResource.getResourceMetadata().get(this); if (retValObj == null) { return null; } else if (retValObj instanceof ExtensionDt) { return (ExtensionDt) retValObj; } throw new InternalErrorException("Found an object of type '" + retValObj.getClass().getCanonicalName() + "' in resource metadata for key " + this.name() + " - Expected " + ExtensionDt.class.getCanonicalName()); }
public IFhirVersion getVersionImplementation() { if (!isPresentOnClasspath()) { throw new IllegalStateException("Version " + name() + " is not present on classpath"); } if (myVersionImplementation == null) { try { myVersionImplementation = (IFhirVersion) Class.forName(myVersionClass).newInstance(); } catch (Exception e) { throw new InternalErrorException("Failed to instantiate FHIR version " + name(), e); } } return myVersionImplementation; }
@Override protected org.hl7.fhir.r4.model.CodeSystem getCodeSystemFromContext(String theSystem) { CodeSystem codeSystem = myValidationSupport.fetchCodeSystem(myContext, theSystem); try { return VersionConvertor_30_40.convertCodeSystem(codeSystem); } catch (FHIRException e) { throw new InternalErrorException(e); } }