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 {
|
public enum PreferReturnEnum {
|
||||||
|
|
||||||
REPRESENTATION("representation"), MINIMAL("minimal");
|
REPRESENTATION("representation"), MINIMAL("minimal"), OPERATION_OUTCOME("OperationOutcome");
|
||||||
|
|
||||||
private String myHeaderValue;
|
private String myHeaderValue;
|
||||||
private static HashMap<String, PreferReturnEnum> ourValues;
|
private static HashMap<String, PreferReturnEnum> ourValues;
|
||||||
|
|
|
@ -183,18 +183,23 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding<Metho
|
||||||
private Object returnResponse(IRestfulServer<?> theServer, RequestDetails theRequest, MethodOutcome response, IBaseResource originalOutcome, IBaseResource resource) throws IOException {
|
private Object returnResponse(IRestfulServer<?> theServer, RequestDetails theRequest, MethodOutcome response, IBaseResource originalOutcome, IBaseResource resource) throws IOException {
|
||||||
boolean allowPrefer = false;
|
boolean allowPrefer = false;
|
||||||
int operationStatus = getOperationStatus(response);
|
int operationStatus = getOperationStatus(response);
|
||||||
IBaseResource outcome = originalOutcome;
|
IBaseResource outcome = resource;
|
||||||
|
|
||||||
if (ourOperationsWhichAllowPreferHeader.contains(getRestOperationType())) {
|
if (ourOperationsWhichAllowPreferHeader.contains(getRestOperationType())) {
|
||||||
allowPrefer = true;
|
allowPrefer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resource != null && allowPrefer) {
|
if (allowPrefer) {
|
||||||
String prefer = theRequest.getHeader(Constants.HEADER_PREFER);
|
String prefer = theRequest.getHeader(Constants.HEADER_PREFER);
|
||||||
PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(prefer);
|
PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(prefer);
|
||||||
if (preferReturn != null) {
|
if (preferReturn != null) {
|
||||||
if (preferReturn == PreferReturnEnum.REPRESENTATION) {
|
if (preferReturn == PreferReturnEnum.MINIMAL) {
|
||||||
outcome = resource;
|
outcome = null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (preferReturn == PreferReturnEnum.OPERATION_OUTCOME) {
|
||||||
|
outcome = originalOutcome;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue