Fix null exception for debug messages in BaseWorkerContext
This commit is contained in:
parent
7c6e7b278a
commit
25d9439fa9
|
@ -53,9 +53,7 @@ import org.hl7.fhir.exceptions.FHIRException;
|
||||||
import org.hl7.fhir.exceptions.NoTerminologyServiceException;
|
import org.hl7.fhir.exceptions.NoTerminologyServiceException;
|
||||||
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
import org.hl7.fhir.exceptions.TerminologyServiceException;
|
||||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||||
import org.hl7.fhir.r5.context.BaseWorkerContext.ResourceProxy;
|
|
||||||
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
|
import org.hl7.fhir.r5.context.CanonicalResourceManager.CanonicalResourceProxy;
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.PackageVersion;
|
|
||||||
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
|
||||||
import org.hl7.fhir.r5.context.TerminologyCache.CacheToken;
|
import org.hl7.fhir.r5.context.TerminologyCache.CacheToken;
|
||||||
import org.hl7.fhir.r5.model.BooleanType;
|
import org.hl7.fhir.r5.model.BooleanType;
|
||||||
|
@ -128,8 +126,6 @@ import org.hl7.fhir.utilities.validation.ValidationOptions.ValueSetMode;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import ca.uhn.fhir.model.valueset.BundleEntrySearchModeEnum;
|
|
||||||
|
|
||||||
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext{
|
public abstract class BaseWorkerContext extends I18nBase implements IWorkerContext{
|
||||||
|
|
||||||
public class ResourceProxy {
|
public class ResourceProxy {
|
||||||
|
@ -388,7 +384,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
|
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
|
||||||
map.put(r.getId(), new ResourceProxy(r));
|
map.put(r.getId(), new ResourceProxy(r));
|
||||||
} else {
|
} else {
|
||||||
logger.logDebugMessage(LogCategory.PROGRESS,"Ignore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
|
logDebugMessage(LogCategory.PROGRESS,"Ignore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
||||||
|
@ -399,7 +395,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
CanonicalResource m = (CanonicalResource) r;
|
CanonicalResource m = (CanonicalResource) r;
|
||||||
String url = m.getUrl();
|
String url = m.getUrl();
|
||||||
if (!allowLoadingDuplicates && hasResource(r.getClass(), url)) {
|
if (!allowLoadingDuplicates && hasResource(r.getClass(), url)) {
|
||||||
// spcial workaround for known problems with existing packages
|
// special workaround for known problems with existing packages
|
||||||
if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
|
if (Utilities.existsInList(url, "http://hl7.org/fhir/SearchParameter/example")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -633,8 +629,15 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void logDebugMessage(LogCategory category, String message) {
|
||||||
|
if (logger != null) {
|
||||||
|
logger.logDebugMessage(category, message);
|
||||||
|
} else {
|
||||||
|
System.out.println(" -"+ category.name().toLowerCase() + ": " +message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void tlog(String msg) {
|
protected void txLog(String msg) {
|
||||||
if (tlogging ) {
|
if (tlogging ) {
|
||||||
if (logger != null) {
|
if (logger != null) {
|
||||||
logger.logDebugMessage(LogCategory.TX, msg);
|
logger.logDebugMessage(LogCategory.TX, msg);
|
||||||
|
@ -692,7 +695,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("_limit", Integer.toString(expandCodesLimit ));
|
params.put("_limit", Integer.toString(expandCodesLimit ));
|
||||||
params.put("_incomplete", "true");
|
params.put("_incomplete", "true");
|
||||||
tlog("$expand on "+txCache.summary(vs));
|
txLog("$expand on "+txCache.summary(vs));
|
||||||
try {
|
try {
|
||||||
ValueSet result = txClient.expandValueset(vs, p, params);
|
ValueSet result = txClient.expandValueset(vs, p, params);
|
||||||
res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId());
|
res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId());
|
||||||
|
@ -786,7 +789,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
Map<String, String> params = new HashMap<String, String>();
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
params.put("_limit", Integer.toString(expandCodesLimit ));
|
params.put("_limit", Integer.toString(expandCodesLimit ));
|
||||||
params.put("_incomplete", "true");
|
params.put("_incomplete", "true");
|
||||||
tlog("$expand on "+txCache.summary(vs));
|
txLog("$expand on "+txCache.summary(vs));
|
||||||
try {
|
try {
|
||||||
ValueSet result = txClient.expandValueset(vs, p, params);
|
ValueSet result = txClient.expandValueset(vs, p, params);
|
||||||
if (!result.hasUrl()) {
|
if (!result.hasUrl()) {
|
||||||
|
@ -895,7 +898,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (batch.getEntry().size() > 0) {
|
if (batch.getEntry().size() > 0) {
|
||||||
tlog("$batch validate for "+batch.getEntry().size()+" codes on systems "+systems.toString());
|
txLog("$batch validate for "+batch.getEntry().size()+" codes on systems "+systems.toString());
|
||||||
if (txClient == null) {
|
if (txClient == null) {
|
||||||
throw new FHIRException(formatMessage(I18nConstants.ATTEMPT_TO_USE_TERMINOLOGY_SERVER_WHEN_NO_TERMINOLOGY_SERVER_IS_AVAILABLE));
|
throw new FHIRException(formatMessage(I18nConstants.ATTEMPT_TO_USE_TERMINOLOGY_SERVER_WHEN_NO_TERMINOLOGY_SERVER_IS_AVAILABLE));
|
||||||
}
|
}
|
||||||
|
@ -983,9 +986,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
}
|
}
|
||||||
String csumm = txCache != null ? txCache.summary(code) : null;
|
String csumm = txCache != null ? txCache.summary(code) : null;
|
||||||
if (txCache != null) {
|
if (txCache != null) {
|
||||||
tlog("$validate "+csumm+" for "+ txCache.summary(vs));
|
txLog("$validate "+csumm+" for "+ txCache.summary(vs));
|
||||||
} else {
|
} else {
|
||||||
tlog("$validate "+csumm+" before cache exists");
|
txLog("$validate "+csumm+" before cache exists");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Parameters pIn = constructParameters(options, code);
|
Parameters pIn = constructParameters(options, code);
|
||||||
|
@ -1107,7 +1110,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
if (noTerminologyServer) {
|
if (noTerminologyServer) {
|
||||||
return new ValidationResult(IssueSeverity.ERROR, "Error validating code: running without terminology services", TerminologyServiceErrorClass.NOSERVICE);
|
return new ValidationResult(IssueSeverity.ERROR, "Error validating code: running without terminology services", TerminologyServiceErrorClass.NOSERVICE);
|
||||||
}
|
}
|
||||||
tlog("$validate "+txCache.summary(code)+" for "+ txCache.summary(vs));
|
txLog("$validate "+txCache.summary(code)+" for "+ txCache.summary(vs));
|
||||||
try {
|
try {
|
||||||
Parameters pIn = constructParameters(options, code);
|
Parameters pIn = constructParameters(options, code);
|
||||||
res = validateOnServer(vs, pIn, options);
|
res = validateOnServer(vs, pIn, options);
|
||||||
|
|
|
@ -314,7 +314,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
||||||
|
|
||||||
public String connectToTSServer(TerminologyClient client, String log) {
|
public String connectToTSServer(TerminologyClient client, String log) {
|
||||||
try {
|
try {
|
||||||
tlog("Connect to "+client.getAddress());
|
txLog("Connect to "+client.getAddress());
|
||||||
txClient = client;
|
txClient = client;
|
||||||
if (log != null && log.endsWith(".txt")) {
|
if (log != null && log.endsWith(".txt")) {
|
||||||
txLog = new TextClientLogger(log);
|
txLog = new TextClientLogger(log);
|
||||||
|
@ -359,7 +359,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon
|
||||||
Bundle bnd = (Bundle) f;
|
Bundle bnd = (Bundle) f;
|
||||||
for (BundleEntryComponent e : bnd.getEntry()) {
|
for (BundleEntryComponent e : bnd.getEntry()) {
|
||||||
if (e.getFullUrl() == null) {
|
if (e.getFullUrl() == null) {
|
||||||
logger.logDebugMessage(LogCategory.CONTEXT, "unidentified resource in " + name+" (no fullUrl)");
|
logDebugMessage(LogCategory.CONTEXT, "unidentified resource in " + name+" (no fullUrl)");
|
||||||
}
|
}
|
||||||
if (filter == null || filter.isOkToLoad(e.getResource())) {
|
if (filter == null || filter.isOkToLoad(e.getResource())) {
|
||||||
String path = loader != null ? loader.getResourcePath(e.getResource()) : null;
|
String path = loader != null ? loader.getResourcePath(e.getResource()) : null;
|
||||||
|
|
Loading…
Reference in New Issue