In my opinion these changes should be made in order to have the behavior
for the Prefer header values as the one explained in the official documentation from https://www.hl7.org/fhir/http.html
This commit is contained in:
parent
cc0e836680
commit
dc476aeeea
|
@ -27,7 +27,7 @@ import java.util.HashMap;
|
|||
*/
|
||||
public enum PreferReturnEnum {
|
||||
|
||||
REPRESENTATION("representation"), MINIMAL("minimal");
|
||||
REPRESENTATION("representation"), MINIMAL("minimal"), OPERATION_OUTCOME("OperationOutcome");
|
||||
|
||||
private String myHeaderValue;
|
||||
private static HashMap<String, PreferReturnEnum> ourValues;
|
||||
|
|
|
@ -183,19 +183,24 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
|||
private Object returnResponse(IRestfulServer<?> theServer, RequestDetails theRequest, MethodOutcome response, IBaseResource originalOutcome, IBaseResource resource) throws IOException {
|
||||
boolean allowPrefer = false;
|
||||
int operationStatus = getOperationStatus(response);
|
||||
IBaseResource outcome = originalOutcome;
|
||||
IBaseResource outcome = resource;
|
||||
|
||||
if (ourOperationsWhichAllowPreferHeader.contains(getRestOperationType())) {
|
||||
allowPrefer = true;
|
||||
}
|
||||
|
||||
if (resource != null && allowPrefer) {
|
||||
if (allowPrefer) {
|
||||
String prefer = theRequest.getHeader(Constants.HEADER_PREFER);
|
||||
PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(prefer);
|
||||
if (preferReturn != null) {
|
||||
if (preferReturn == PreferReturnEnum.REPRESENTATION) {
|
||||
outcome = resource;
|
||||
if (preferReturn == PreferReturnEnum.MINIMAL) {
|
||||
outcome = null;
|
||||
}
|
||||
else {
|
||||
if (preferReturn == PreferReturnEnum.OPERATION_OUTCOME) {
|
||||
outcome = originalOutcome;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue