Package com.sap.cds.services.runtime
Interface RequestContextRunner
public interface RequestContextRunner
RequestContextRunner is the main entry to spawn a new RequestContext with adapted UserInfo or ParameterInfo.
The current parameters of the calling RequestContext are not affected.-
Method Summary
Modifier and TypeMethodDescriptionSets theUserInfofor theRequestContextto the anonymous user.Resets theMessagesfor theRequestContextbeing opened.Resets theParameterInfofor theRequestContextbeing opened.default RequestContextRunnerResets theUserInfofor theRequestContextbeing opened.featureToggles(FeatureTogglesInfo featureTogglesInfo) Sets a dedicatedFeatureTogglesInfofor theRequestContextbeing opened.modifyParameters(Consumer<ModifiableParameterInfo> contextParameters) Opens aRequestContextwith an adaptedParameterInfo.modifyUser(Consumer<ModifiableUserInfo> contextUser) Opens aRequestContextwith an adaptedUserInfo.parameters(ParameterInfo parameterInfo) Sets a dedicatedParameterInfofor theRequestContextbeing opened.Sets theUserInfofor theRequestContextto the internal privileged user who passes all authorization checks.voidrun(Consumer<RequestContext> requestHandler) Opens aRequestContextand runs the given handler within its scope.<T> Trun(Function<RequestContext, T> requestHandler) Opens aRequestContextand runs the given handler within its scope.Sets theUserInfofor theRequestContextto the system user.systemUser(String tenantId) Sets theUserInfofor theRequestContextto the system user of the specified subscriber account.Sets theUserInfofor theRequestContextto the system user of the provider account.Sets a dedicatedUserInfofor theRequestContextbeing opened.
-
Method Details
-
user
Sets a dedicatedUserInfofor theRequestContextbeing opened.- Parameters:
userInfo- TheUserInfo.- Returns:
- this instance
-
clearUser
Resets theUserInfofor theRequestContextbeing opened. The empty user is anonymous.- Returns:
- this instance
-
anonymousUser
RequestContextRunner anonymousUser()Sets theUserInfofor theRequestContextto the anonymous user. This user is the base-line also used byclearUser().- Returns:
- this instance
-
providedUser
RequestContextRunner providedUser()Sets theUserInfofor theRequestContextas provided by theUserInfoProvider. By default this means theUserInfois resolved from the HTTP request. You may override the default provider during runtime configuration phase by means ofCdsRuntimeConfigurer.provider(UserInfoProvider).- Returns:
- this instance
-
systemUserProvider
RequestContextRunner systemUserProvider()Sets theUserInfofor theRequestContextto the system user of the provider account. This is equivalent to callingsystemUser(null)- Returns:
- this instance
-
systemUser
RequestContextRunner systemUser()Sets theUserInfofor theRequestContextto the system user. The tenant will be automatically propagated from the currentUserInfo. This is equivalent to callingsystemUser(userInfo.getTenant()).- Returns:
- this instance
-
systemUser
Sets theUserInfofor theRequestContextto the system user of the specified subscriber account.- Parameters:
tenantId- Tenant in which theRequestContextwill be executed- Returns:
- this instance
-
privilegedUser
RequestContextRunner privilegedUser()Sets theUserInfofor theRequestContextto the internal privileged user who passes all authorization checks.- Returns:
- this instance
-
modifyUser
Opens aRequestContextwith an adaptedUserInfo. The passedModifiableUserInfoAPI can be used to define modifications which are valid within the scope of the newRequestContext.The modifications are done on the
UserInfoof the outerRequestContextif existing. Otherwise they are done on the providedUserInfofromUserInfoProvider.- Parameters:
contextUser- theModifiableUserInfoas modification layer on top of currentUserInfo- Returns:
- this instance
-
parameters
Sets a dedicatedParameterInfofor theRequestContextbeing opened.- Parameters:
parameterInfo- theParameterInfo.- Returns:
- this instance
-
featureToggles
Sets a dedicatedFeatureTogglesInfofor theRequestContextbeing opened. Throws an exception in case theRequestContextbeing opened has a parent (i.e. is nested).- Parameters:
featureTogglesInfo- theFeatureTogglesInfo.- Returns:
- this instance
-
clearParameters
RequestContextRunner clearParameters()Resets theParameterInfofor theRequestContextbeing opened.- Returns:
- this instance
-
providedParameters
RequestContextRunner providedParameters()Sets theParameterInfofor theRequestContextas provided by theParameterInfoProvider. By default this means theParameterInfois resolved from the HTTP request. You may override the default provider during runtime configuration phase by means ofCdsRuntimeConfigurer.provider(ParameterInfoProvider).- Returns:
- this instance
-
modifyParameters
Opens aRequestContextwith an adaptedParameterInfo. The passedModifiableParameterInfoAPI can be used to define modifications which are valid within the scope of the newRequestContext.The modifications are done on the
ParameterInfoof the outerRequestContextif existing. Otherwise they are done on the providedParameterInfofromParameterInfoProvider.- Parameters:
contextParameters- theModifiableParameterInfoas modification layer on top of currentParameterInfo- Returns:
- this instance
-
clearMessages
RequestContextRunner clearMessages()Resets theMessagesfor theRequestContextbeing opened.- Returns:
- this instance
-
run
Opens aRequestContextand runs the given handler within its scope. TheRequestContextwill be propagated to allEventContextinstances in the service call hierarchy.- Type Parameters:
T- The type of the response- Parameters:
requestHandler- The handler for processing the request within the context- Returns:
- A generic response object of the handler
-
run
Opens aRequestContextand runs the given handler within its scope. TheRequestContextwill be propagated to allEventContextinstances in the service call hierarchy.If
UserInfohas not been specified explicitly, it is taken from the outerRequestContextor, if there is no outer context, fromUserInfoProvider. The same holds forParameterInfo.- Parameters:
requestHandler- The handler for processing the request within the context
-