mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-02-16 09:55:09 +00:00
Fixed NPEs on validation
This commit is contained in:
parent
23f3cc1f42
commit
01b1210b8a
@ -126,9 +126,12 @@ public class AddressValidatingInterceptor extends ServerOperationInterceptorAdap
|
||||
protected void validateAddress(IBase theAddress, FhirContext theFhirContext) {
|
||||
try {
|
||||
AddressValidationResult validationResult = getAddressValidator().isValid(theAddress, theFhirContext);
|
||||
ourLog.debug("Validated address {}", validationResult);
|
||||
|
||||
myExtensionHelper.setValue(theAddress, IAddressValidator.ADDRESS_VALIDATION_EXTENSION_URL,
|
||||
validationResult.isValid() ? IAddressValidator.EXT_VALUE_VALID : IAddressValidator.EXT_VALUE_INVALID, theFhirContext);
|
||||
} catch (Exception ex) {
|
||||
ourLog.warn("Unable to validate address", ex);
|
||||
myExtensionHelper.setValue(theAddress, IAddressValidator.ADDRESS_VALIDATION_EXTENSION_URL, IAddressValidator.EXT_UNABLE_TO_VALIDATE, theFhirContext);
|
||||
}
|
||||
}
|
||||
|
@ -72,4 +72,14 @@ public class AddressValidationResult {
|
||||
public void setRawResponse(String theRawResponse) {
|
||||
this.myRawResponse = theRawResponse;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return
|
||||
" isValid=" + myIsValid +
|
||||
", validatedAddressString='" + myValidatedAddressString + '\'' +
|
||||
", validationResults=" + myValidationResults + '\'' +
|
||||
", rawResponse='" + myRawResponse + '\'' +
|
||||
", myValidatedAddress='" + myValidatedAddress + '\'';
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,10 @@ public class LoquateAddressValidator extends BaseRestfulValidator {
|
||||
theResult.setValid(isValid(theMatch));
|
||||
|
||||
ourLog.debug("Address validation flag {}", theResult.isValid());
|
||||
theResult.setValidatedAddressString(theMatch.get("Address").asText());
|
||||
JsonNode addressNode = theMatch.get("Address");
|
||||
if (addressNode != null) {
|
||||
theResult.setValidatedAddressString(addressNode.asText());
|
||||
}
|
||||
|
||||
ourLog.debug("Validated address string {}", theResult.getValidatedAddressString());
|
||||
theResult.setValidatedAddress(toAddress(theMatch, theFhirContext));
|
||||
@ -137,7 +140,11 @@ public class LoquateAddressValidator extends BaseRestfulValidator {
|
||||
|
||||
private boolean isDuplicate(String theAddressLine, JsonNode theMatch) {
|
||||
for (String s : DUPLICATE_FIELDS_IN_ADDRESS_LINES) {
|
||||
theAddressLine = theAddressLine.replaceAll(theMatch.get(s).asText(""), "");
|
||||
JsonNode node = theMatch.get(s);
|
||||
if (node == null) {
|
||||
continue;
|
||||
}
|
||||
theAddressLine = theAddressLine.replaceAll(node.asText(), "");
|
||||
}
|
||||
return theAddressLine.trim().isEmpty();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user