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:
Ana Maria Radu 2018-06-12 14:04:05 +03:00
parent cc0e836680
commit dc476aeeea
2 changed files with 10 additions and 5 deletions

View File

@ -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;

View File

@ -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;
}
}
}
}