@Override public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException { if (theRequest.getRequestType() == RequestTypeEnum.POST) { IBaseResource requestContents = ResourceParameter.loadResourceFromRequest(theRequest, this, null); theRequest.getUserData().put(OperationParameter.REQUEST_CONTENTS_USERDATA_KEY, requestContents); } return super.invokeServer(theServer, theRequest); }
public static IBaseResource parseResourceFromRequest(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding, Class<? extends IBaseResource> theResourceType) { IBaseResource retVal = null; if (theResourceType != null && IBaseBinary.class.isAssignableFrom(theResourceType)) { String ct = theRequest.getHeader(Constants.HEADER_CONTENT_TYPE); if (EncodingEnum.forContentTypeStrict(ct) == null) { FhirContext ctx = theRequest.getServer().getFhirContext(); IBaseBinary binary = BinaryUtil.newBinary(ctx); binary.setId(theRequest.getId()); binary.setContentType(ct); binary.setContent(theRequest.loadRequestContents()); retVal = binary; /* * Security context header, which is only in * DSTU3+ */ if (ctx.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) { String securityContext = theRequest.getHeader(Constants.HEADER_X_SECURITY_CONTEXT); if (isNotBlank(securityContext)) { BinaryUtil.setSecurityContext(ctx, binary, securityContext); } } } } if (retVal == null) { retVal = loadResourceFromRequest(theRequest, theMethodBinding, theResourceType); } return retVal; }
@Override public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest) throws BaseServerResponseException, IOException { if (theRequest.getRequestType() == RequestTypeEnum.POST) { IBaseResource requestContents = ResourceParameter.loadResourceFromRequest(theRequest, this, null); theRequest.getUserData().put(OperationParameter.REQUEST_CONTENTS_USERDATA_KEY, requestContents); } return super.invokeServer(theServer, theRequest); }
public static IBaseResource parseResourceFromRequest(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding, Class<? extends IBaseResource> theResourceType) { IBaseResource retVal = null; if (theResourceType != null && IBaseBinary.class.isAssignableFrom(theResourceType)) { String ct = theRequest.getHeader(Constants.HEADER_CONTENT_TYPE); if (EncodingEnum.forContentTypeStrict(ct) == null) { FhirContext ctx = theRequest.getServer().getFhirContext(); IBaseBinary binary = BinaryUtil.newBinary(ctx); binary.setId(theRequest.getId()); binary.setContentType(ct); binary.setContent(theRequest.loadRequestContents()); retVal = binary; /* * Security context header, which is only in * DSTU3+ */ if (ctx.getVersion().getVersion().isEqualOrNewerThan(FhirVersionEnum.DSTU3)) { String securityContext = theRequest.getHeader(Constants.HEADER_X_SECURITY_CONTEXT); if (isNotBlank(securityContext)) { BinaryUtil.setSecurityContext(ctx, binary, securityContext); } } } } if (retVal == null) { retVal = loadResourceFromRequest(theRequest, theMethodBinding, theResourceType); } return retVal; }