Package com.atlassian.jira.util.velocity
Interface VelocityRequestContextFactory
- All Known Implementing Classes:
DefaultVelocityRequestContextFactory
,MockVelocityRequestContextFactory
Provides a request context that can be used to get the 'correct' baseurl.
It will use information from the HttpRequest if one was made or applicationProperties otherwise to determine the baseurl.
- Since:
- v4.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cacheVelocityRequestContext
(VelocityRequestContext velocityRequestContext) Deprecated.void
Resets the thread local storage as if no request has occurred, effectively nulling out the current thread local velocity request context.getDefaultVelocityParams
(Map<String, Object> startingParams, JiraAuthenticationContext authenticationContext) Constructs a map with a number of common parameters used by velocity templates.Get the request context.<I,
O> O runWithStaticBaseUrl
(I input, com.google.common.base.Function<I, O> runnable) Run the passed function in an environment where JIRA's configuredbaseURL
is always used.void
setVelocityRequestContext
(VelocityRequestContext velocityRequestContext) Update the thread-local storage with the given velocityRequestContext.void
setVelocityRequestContext
(String baseUrl, javax.servlet.http.HttpServletRequest request) Update the thread-local storage with the given request information.void
setVelocityRequestContext
(javax.servlet.http.HttpServletRequest request) Update the thread-local storage with the given request information.
-
Method Details
-
getJiraVelocityRequestContext
VelocityRequestContext getJiraVelocityRequestContext()Get the request context.- Returns:
- The request context.
-
getDefaultVelocityParams
Map<String,Object> getDefaultVelocityParams(Map<String, Object> startingParams, JiraAuthenticationContext authenticationContext) Constructs a map with a number of common parameters used by velocity templates.- Parameters:
startingParams
- Map of parameters that may be used to override any of the parameters set here.authenticationContext
- JiraAuthenticationContext- Returns:
- a Map with common velocity parameters
-
cacheVelocityRequestContext
Deprecated.UsesetVelocityRequestContext(VelocityRequestContext)
instead. Since v5.0.Update the thread-local storage with the given velocityRequestContext.- Parameters:
velocityRequestContext
- The velocity request context to store.- Since:
- 4.3
-
clearVelocityRequestContext
void clearVelocityRequestContext()Resets the thread local storage as if no request has occurred, effectively nulling out the current thread local velocity request context.- Since:
- 4.3
-
setVelocityRequestContext
void setVelocityRequestContext(javax.servlet.http.HttpServletRequest request) Update the thread-local storage with the given request information.- Parameters:
request
- The http request context to store.- Since:
- 5.0
-
setVelocityRequestContext
Update the thread-local storage with the given request information.- Parameters:
baseUrl
- of the request.request
- The http request context to store.- Since:
- 5.0
-
setVelocityRequestContext
Update the thread-local storage with the given velocityRequestContext.- Parameters:
velocityRequestContext
- The velocity request context to store.- Since:
- 5.0
-
runWithStaticBaseUrl
@Nullable <I,O> O runWithStaticBaseUrl(@Nullable I input, @Nonnull com.google.common.base.Function<I, O> runnable) Run the passed function in an environment where JIRA's configuredbaseURL
is always used. This basically makes the passed function ignore any smartbaseURL
that can be generated from the request associated with the calling thread.- Parameters:
input
- input to pass to the function.runnable
- the function to execute.- Returns:
- the result of the function.
- Since:
- 6.3.1
-
setVelocityRequestContext(VelocityRequestContext)
instead.