001package org.hl7.fhir.r5.utils.validation;
002
003import org.hl7.fhir.exceptions.FHIRException;
004import org.hl7.fhir.r5.elementmodel.Element;
005import org.hl7.fhir.r5.model.CanonicalResource;
006
007import java.io.IOException;
008import java.net.URISyntaxException;
009import java.util.List;
010import java.util.Locale;
011import java.util.Set;
012
013public interface IValidatorResourceFetcher {
014
015  Element fetch(IResourceValidator validator, Object appContext, String url) throws FHIRException, IOException;
016
017  boolean resolveURL(IResourceValidator validator, Object appContext, String path, String url, String type, boolean canonical) throws IOException, FHIRException;
018
019  byte[] fetchRaw(IResourceValidator validator, String url) throws IOException; // for attachment checking
020
021  IValidatorResourceFetcher setLocale(Locale locale);
022
023  /**
024   * this is used when the validator encounters a reference to a structure definition, value set or code system at some random URL reference
025   * while validating.
026   * <p>
027   * Added in v5.2.2. return null to leave functionality as it was before then.
028   *
029   * @return an R5 version of the resource
030   * @throws URISyntaxException
031   */
032  CanonicalResource fetchCanonicalResource(IResourceValidator validator, Object appContext, String url) throws URISyntaxException;
033
034  /**
035   * Whether to try calling fetchCanonicalResource for this reference (not whether it will succeed - just throw an exception from fetchCanonicalResource if it doesn't resolve. This is a policy thing.
036   * <p>
037   * Added in v5.2.2. return false to leave functionality as it was before then.
038   *
039   * @param url
040   * @return
041   */
042  boolean fetchesCanonicalResource(IResourceValidator validator, String url);
043
044  Set<String> fetchCanonicalResourceVersions(IResourceValidator validator, Object appContext, String url);
045}