Skip to content

Commit 59680b9

Browse files
Merge pull request #1826 from hapifhir/2024-11-gg-clean0up
2024 11 gg clean0up
2 parents 845921d + 42065d5 commit 59680b9

File tree

6 files changed

+59
-30
lines changed

6 files changed

+59
-30
lines changed

RELEASE_NOTES.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
## Validator Changes
22

33
* fix pattern discriminator validation rule
4+
* fix issue with FHIRPath engine throwing exception for an invalid path
45

56
## Other code changes
67

7-
* no changes
8+
* fix NPE rendering reference
9+
* fix NPE processing issue from template
10+
* Add FeatureDefinition renderer
11+
* Support for Custom resources in publisher

org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/utils/ToolingExtensions.java

+3
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,9 @@ private static IssueType mapType(org.hl7.fhir.r4.model.OperationOutcome.IssueTyp
874874
}
875875

876876
private static IssueSeverity mapSeverity(org.hl7.fhir.r4.model.OperationOutcome.IssueSeverity severity) {
877+
if (severity == null) {
878+
return null;
879+
}
877880
switch (severity) {
878881
case ERROR:
879882
return IssueSeverity.ERROR;

org.hl7.fhir.r4b/src/main/java/org/hl7/fhir/r4b/utils/ToolingExtensions.java

+3
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,9 @@ private static IssueType mapType(org.hl7.fhir.r4b.model.OperationOutcome.IssueTy
903903
}
904904

905905
private static IssueSeverity mapSeverity(org.hl7.fhir.r4b.model.OperationOutcome.IssueSeverity severity) {
906+
if (severity == null) {
907+
return null;
908+
}
906909
switch (severity) {
907910
case ERROR:
908911
return IssueSeverity.ERROR;

org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ResourceRenderer.java

+16-12
Original file line numberDiff line numberDiff line change
@@ -846,22 +846,26 @@ protected XhtmlNode renderResourceTechDetails(ResourceWrapper r, XhtmlNode x, St
846846
if (!Utilities.noString(r.getId())) {
847847
if (!context.isSecondaryLang()) {
848848
String sid = r.getScopedId();
849-
if (!context.hasAnchor(sid)) {
850-
context.addAnchor(sid);
851-
x.an(context.prefixAnchor(sid));
852-
}
853-
sid = "hc"+sid;
854-
if (!context.hasAnchor(sid)) {
855-
context.addAnchor(sid);
856-
x.an(context.prefixAnchor(sid));
849+
if (sid != null) {
850+
if (!context.hasAnchor(sid)) {
851+
context.addAnchor(sid);
852+
x.an(context.prefixAnchor(sid));
853+
}
854+
sid = "hc"+sid;
855+
if (!context.hasAnchor(sid)) {
856+
context.addAnchor(sid);
857+
x.an(context.prefixAnchor(sid));
858+
}
857859
}
858860
}
859861
if (context.getLocale() != null) {
860862
String langSuffix = "-"+context.getLocale().toLanguageTag();
861-
String sid = r.getScopedId()+langSuffix;
862-
if (!context.hasAnchor(sid)) {
863-
context.addAnchor(sid);
864-
x.an(context.prefixAnchor(sid));
863+
if (r.getScopedId() != null) {
864+
String sid = r.getScopedId()+langSuffix;
865+
if (!context.hasAnchor(sid)) {
866+
context.addAnchor(sid);
867+
x.an(context.prefixAnchor(sid));
868+
}
865869
}
866870
}
867871
}

org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java

+3
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,9 @@ private static IssueType mapType(org.hl7.fhir.r5.model.OperationOutcome.IssueTyp
10711071
}
10721072

10731073
private static IssueSeverity mapSeverity(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity severity) {
1074+
if (severity == null) {
1075+
return null;
1076+
}
10741077
switch (severity) {
10751078
case ERROR: return IssueSeverity.ERROR;
10761079
case FATAL: return IssueSeverity.FATAL;

org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/npm/NpmPackage.java

+29-17
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ public JsonObject oidIndex() throws IOException {
331331

332332
}
333333

334+
334335
private String path;
335336
private JsonObject npm;
336337
private Map<String, NpmPackageFolder> folders = new HashMap<>();
@@ -339,6 +340,7 @@ public JsonObject oidIndex() throws IOException {
339340
private boolean minimalMemory;
340341
private int size;
341342
private boolean warned = false;
343+
private static boolean loadCustomResources;
342344

343345
/**
344346
* Constructor
@@ -406,7 +408,7 @@ public Map<String, Object> getUserData() {
406408
public void loadFiles(String path, File source, String... exemptions) throws FileNotFoundException, IOException {
407409
this.npm = JsonParser.parseObject(TextFile.fileToString(Utilities.path(path, "package", "package.json")));
408410
this.path = path;
409-
411+
410412
File dir = ManagedFileAccess.file(path);
411413
for (File f : dir.listFiles()) {
412414
if (!isInternalExemptFile(f) && !Utilities.existsInList(f.getName(), exemptions)) {
@@ -431,6 +433,7 @@ public void loadFiles(String path, File source, String... exemptions) throws Fil
431433
}
432434
}
433435
loadSubFolders(dir.getAbsolutePath(), f);
436+
434437
} else {
435438
NpmPackageFolder folder = this.new NpmPackageFolder(Utilities.path("package", "$root"));
436439
folder.folder = dir;
@@ -448,24 +451,26 @@ public static boolean isInternalExemptFile(File f) {
448451
private void loadSubFolders(String rootPath, File dir) throws IOException {
449452
for (File f : dir.listFiles()) {
450453
if (f.isDirectory()) {
451-
String d = f.getAbsolutePath().substring(rootPath.length()+1);
452-
if (!d.startsWith("package")) {
453-
d = Utilities.path("package", d);
454-
}
455-
NpmPackageFolder folder = this.new NpmPackageFolder(d);
456-
folder.folder = f;
457-
this.folders.put(d, folder);
458-
File ij = ManagedFileAccess.file(Utilities.path(f.getAbsolutePath(), ".index.json"));
459-
if (ij.exists() || !minimalMemory) {
460-
try {
461-
if (!ij.exists() || !folder.readIndex(JsonParser.parseObject(ij), folder.getTypes())) {
462-
indexFolder(folder.getFolderName(), folder);
454+
if (!"custom".equals(f.getName()) || loadCustomResources) {
455+
String d = f.getAbsolutePath().substring(rootPath.length()+1);
456+
if (!d.startsWith("package")) {
457+
d = Utilities.path("package", d);
458+
}
459+
NpmPackageFolder folder = this.new NpmPackageFolder(d);
460+
folder.folder = f;
461+
this.folders.put(d, folder);
462+
File ij = ManagedFileAccess.file(Utilities.path(f.getAbsolutePath(), ".index.json"));
463+
if (ij.exists() || !minimalMemory) {
464+
try {
465+
if (!ij.exists() || !folder.readIndex(JsonParser.parseObject(ij), folder.getTypes())) {
466+
indexFolder(folder.getFolderName(), folder);
467+
}
468+
} catch (Exception e) {
469+
throw new IOException("Error parsing "+ij.getAbsolutePath()+": "+e.getMessage(), e);
463470
}
464-
} catch (Exception e) {
465-
throw new IOException("Error parsing "+ij.getAbsolutePath()+": "+e.getMessage(), e);
466471
}
472+
loadSubFolders(rootPath, f);
467473
}
468-
loadSubFolders(rootPath, f);
469474
}
470475
}
471476
}
@@ -1510,5 +1515,12 @@ public String vid() {
15101515
return id()+"#"+version();
15111516
}
15121517

1513-
1518+
public static boolean isLoadCustomResources() {
1519+
return loadCustomResources;
1520+
}
1521+
1522+
public static void setLoadCustomResources(boolean loadCustomResources) {
1523+
NpmPackage.loadCustomResources = loadCustomResources;
1524+
}
1525+
15141526
}

0 commit comments

Comments
 (0)