Revert change to treat Canonical URLs as Locals (#3483)
* Revert change added in MR: https://github.com/hapifhir/hapi-fhir/pull/3050 to add support for treating Canonical Urls as locals. This is no longer needed as the issue reported in #2843 (_include not working for Canonicals) has been addressed in MR: https://github.com/hapifhir/hapi-fhir/pull/3440
This commit is contained in:
parent
50e6e94105
commit
3eb3014d25
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
type: change
|
||||||
|
issue: 2843
|
||||||
|
title: "Reverting the change to treat canonical references as local when setting the flag `getTreatBaseUrlsAsLocal()`. This
|
||||||
|
was added to address a limitation in `_include` that did not process references by canonical URLs.
|
||||||
|
The `_include` search operation now includes canonical references without special configuration."
|
|
@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.searchparam.extractor;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.i18n.Msg;
|
|
||||||
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
||||||
|
@ -28,6 +27,7 @@ import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||||
import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
|
import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
|
||||||
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
|
||||||
|
@ -1415,11 +1415,6 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOrCanBeTreatedAsLocal(IIdType theId) {
|
|
||||||
boolean acceptableAsLocalReference = !theId.isAbsolute() || myModelConfig.getTreatBaseUrlsAsLocal().contains(theId.getBaseUrl());
|
|
||||||
return acceptableAsLocalReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PathAndRef get(IBase theValue, String thePath) {
|
public PathAndRef get(IBase theValue, String thePath) {
|
||||||
extract(new SearchParamSet<>(),
|
extract(new SearchParamSet<>(),
|
||||||
new RuntimeSearchParam(null, null, "Reference", null, null, null, null, null, null, null),
|
new RuntimeSearchParam(null, null, "Reference", null, null, null, null, null, null, null),
|
||||||
|
|
|
@ -20,7 +20,6 @@ package ca.uhn.fhir.jpa.dao;
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||||
import ca.uhn.fhir.i18n.Msg;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
@ -70,7 +69,6 @@ import org.hl7.fhir.instance.model.api.IBaseOperationOutcome;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseReference;
|
import org.hl7.fhir.instance.model.api.IBaseReference;
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
|
||||||
import org.hl7.fhir.r4.model.InstantType;
|
import org.hl7.fhir.r4.model.InstantType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
@ -174,9 +172,7 @@ public abstract class BaseStorageDao {
|
||||||
verifyBundleTypeIsAppropriateForStorage(theResource);
|
verifyBundleTypeIsAppropriateForStorage(theResource);
|
||||||
|
|
||||||
if(!getConfig().getTreatBaseUrlsAsLocal().isEmpty()) {
|
if(!getConfig().getTreatBaseUrlsAsLocal().isEmpty()) {
|
||||||
FhirTerser terser = myFhirContext.newTerser();
|
replaceAbsoluteReferencesWithRelative(theResource, myFhirContext.newTerser());
|
||||||
replaceAbsoluteReferencesWithRelative(theResource, terser);
|
|
||||||
replaceAbsoluteUrisWithRelative(theResource, terser);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
performAutoVersioning(theResource, thePerformIndexing);
|
performAutoVersioning(theResource, thePerformIndexing);
|
||||||
|
@ -235,27 +231,6 @@ public abstract class BaseStorageDao {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace Canonical URI's with local references, if we find that the canonical should be treated as local.
|
|
||||||
*/
|
|
||||||
private void replaceAbsoluteUrisWithRelative(IBaseResource theResource, FhirTerser theTerser) {
|
|
||||||
|
|
||||||
BaseRuntimeElementDefinition<?> canonicalElementDefinition = myFhirContext.getElementDefinition("canonical");
|
|
||||||
if (canonicalElementDefinition != null) {
|
|
||||||
Class<? extends IPrimitiveType<String>> canonicalType = (Class<? extends IPrimitiveType<String>>) canonicalElementDefinition.getImplementingClass();
|
|
||||||
List<? extends IPrimitiveType<String>> canonicals = theTerser.getAllPopulatedChildElementsOfType(theResource, canonicalType);
|
|
||||||
|
|
||||||
//TODO GGG this is pretty inefficient if there are many baseUrls, and many canonicals. Consider improving.
|
|
||||||
for (String baseUrl : myModelConfig.getTreatBaseUrlsAsLocal()) {
|
|
||||||
for (IPrimitiveType<String> canonical : canonicals) {
|
|
||||||
if (canonical.getValue().startsWith(baseUrl)) {
|
|
||||||
canonical.setValue(canonical.getValue().substring(baseUrl.length() + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle {@link ModelConfig#getAutoVersionReferenceAtPaths() auto-populate-versions}
|
* Handle {@link ModelConfig#getAutoVersionReferenceAtPaths() auto-populate-versions}
|
||||||
* <p>
|
* <p>
|
||||||
|
|
Loading…
Reference in New Issue