Skip to content

Commit

Permalink
Merge pull request #3586 from IBM/issue-3576
Browse files Browse the repository at this point in the history
issue #3576 - remove Resource.id passed via POST
  • Loading branch information
lmsurpre committed Apr 21, 2022
2 parents fd0f8c5 + ab01a9c commit f6d8962
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,19 @@ public FHIRRestOperationResponse doCreateMeta(FHIRPersistenceEvent event, List<I
}
}

// For R4, resources may contain an id. For create, this should be ignored and
// we no longer reject the request.
// Resources may contain an id. For create, this value should be ignored (we no longer reject the request).
if (resource.getId() != null) {
String msg = "The create request resource included id: '" + resource.getId() + "'; this id has been replaced";
warnings.add(FHIRUtil.buildOperationOutcomeIssue(IssueSeverity.INFORMATION, IssueType.INFORMATIONAL, msg));
if (log.isLoggable(Level.FINE)) {
log.fine(msg);
}

// Null out the id so that interceptors don't get confused by the bogus value passed in
Resource.Builder builder = resource.toBuilder();
builder.id(null);
builder.setValidating(false);
event.setFhirResource(builder.build());
}

// Now we know we are going forward with the create, so fire the 'beforeCreate' event. This may modify the resource
Expand All @@ -343,7 +348,7 @@ public FHIRRestOperationResponse doCreateMeta(FHIRPersistenceEvent event, List<I
}

@Override
public FHIRRestOperationResponse doCreatePersist(FHIRPersistenceEvent event, List<Issue> warnings, Resource resource,
public FHIRRestOperationResponse doCreatePersist(FHIRPersistenceEvent event, List<Issue> warnings, Resource resource,
PayloadPersistenceResponse offloadResponse) throws Exception {
log.entering(this.getClass().getName(), "doCreatePersist");

Expand Down

0 comments on commit f6d8962

Please sign in to comment.