-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00bf823
commit f6e7905
Showing
3 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
hapi-fhir-cli/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package ca.uhn.fhir.cli; | ||
|
||
import org.hl7.fhir.instance.model.ValueSet; | ||
import org.hl7.fhir.instance.model.ValueSet.ConceptSetComponent; | ||
import org.hl7.fhir.instance.model.ValueSet.ValueSetExpansionComponent; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
|
||
import ca.uhn.fhir.context.FhirContext; | ||
import ca.uhn.fhir.rest.client.IGenericClient; | ||
import ca.uhn.fhir.rest.client.ServerValidationModeEnum; | ||
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; | ||
import ca.uhn.fhir.validation.IValidationSupport; | ||
|
||
public class LoadingValidationSupport implements IValidationSupport { | ||
|
||
private static FhirContext myCtx = FhirContext.forDstu2Hl7Org(); | ||
|
||
@Override | ||
public ValueSetExpansionComponent expandValueSet(ConceptSetComponent theInclude) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public ValueSet fetchCodeSystem(String theSystem) { | ||
return null; | ||
} | ||
|
||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(LoadingValidationSupport.class); | ||
|
||
@Override | ||
public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri) { | ||
String resName = myCtx.getResourceDefinition(theClass).getName(); | ||
ourLog.info("Attempting to fetch {} at URL: {}", resName, theUri); | ||
|
||
myCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER); | ||
IGenericClient client = myCtx.newRestfulGenericClient("http://example.com"); | ||
|
||
T result; | ||
try { | ||
result = client.read(theClass, theUri); | ||
} catch (BaseServerResponseException e) { | ||
throw new CommandFailureException("FAILURE: Received HTTP " + e.getStatusCode() + ": " + e.getMessage()); | ||
} | ||
ourLog.info("Successfully loaded resource"); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean isCodeSystemSupported(String theSystem) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public CodeValidationResult validateCode(String theCodeSystem, String theCode, String theDisplay) { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters