|
11 | 11 | import org.hl7.fhir.r4.model.Organization; |
12 | 12 | import org.hl7.fhir.r4.model.OrganizationAffiliation; |
13 | 13 | import org.hl7.fhir.r4.model.Resource; |
| 14 | +import org.hl7.fhir.r4.model.ResourceType; |
14 | 15 | import org.hl7.fhir.r4.model.StringType; |
15 | 16 | import org.hl7.fhir.r4.model.Task; |
16 | 17 | import org.slf4j.Logger; |
@@ -76,10 +77,17 @@ private Predicate<BundleEntryComponent> entryNotAllowedWithError(Task task, Stri |
76 | 77 | private boolean resourceNotAllowedWithError(BundleEntryComponent entry, Task task, String bundleUrl) |
77 | 78 | { |
78 | 79 | Resource resource = entry.getResource(); |
79 | | - boolean resourceAllowed = (resource instanceof Organization || resource instanceof OrganizationAffiliation |
80 | | - || resource instanceof Endpoint); |
81 | | - |
82 | | - if (!resourceAllowed) |
| 80 | + boolean resourceAllowed = (HTTPVerb.DELETE.equals(entry.getRequest().getMethod()) |
| 81 | + && (entry.getRequest().getUrl().startsWith(ResourceType.Organization.name()) |
| 82 | + || entry.getRequest().getUrl().startsWith(ResourceType.OrganizationAffiliation.name()) |
| 83 | + || entry.getRequest().getUrl().startsWith(ResourceType.Endpoint.name()))) |
| 84 | + || (resource instanceof Organization || resource instanceof OrganizationAffiliation |
| 85 | + || resource instanceof Endpoint); |
| 86 | + |
| 87 | + if (HTTPVerb.DELETE.equals(entry.getRequest().getMethod()) && !resourceAllowed) |
| 88 | + addError(task, "Resource delete of '" + entry.getRequest().getUrl() + "' not allowed in Bundle with id '" |
| 89 | + + bundleUrl + "'"); |
| 90 | + else if (!HTTPVerb.DELETE.equals(entry.getRequest().getMethod()) && !resourceAllowed) |
83 | 91 | addError(task, "Resource of type '" + resource.getResourceType().name() |
84 | 92 | + "' not allowed in Bundle with id '" + bundleUrl + "'"); |
85 | 93 |
|
|
0 commit comments