public class DefaultVelocityRequestContextFactory extends Object implements VelocityRequestContextFactory
VelocityRequestContext, depending on whether we are called from a web or non-web context.
The original intention of this class is to get around bugs such as JRA-11038, where velocity fragments are called from both
web and non-web contexts. Originally we tried to proxy HttpServletRequest, but it makes more sense to have a specific interface
VelocityRequestContext.
| Constructor and Description |
|---|
DefaultVelocityRequestContextFactory()
Deprecated.
|
DefaultVelocityRequestContextFactory(ApplicationProperties applicationProperties) |
| Modifier and Type | Method and Description |
|---|---|
static void |
cacheVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
Deprecated.
Use
VelocityRequestContextFactory.setVelocityRequestContext(javax.servlet.http.HttpServletRequest) instead. Since v5.0. |
static void |
cacheVelocityRequestContext(String baseUrl,
javax.servlet.http.HttpServletRequest request)
Deprecated.
|
void |
cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
Deprecated.
Use
VelocityRequestContextFactory.setVelocityRequestContext(VelocityRequestContext) instead. Since v5.0. |
void |
clearVelocityRequestContext()
Resets the thread local storage as if no request has occurred, effectively nulling out the current
thread local velocity request context.
|
Map<String,Object> |
getDefaultVelocityParams(Map<String,Object> startingParams,
JiraAuthenticationContext authenticationContext)
Constructs a map with a number of common parameters used by velocity templates.
|
VelocityRequestContext |
getJiraVelocityRequestContext()
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 configured
baseURL is always used. |
void |
setVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
Update the thread-local storage with the given request information.
|
void |
setVelocityRequestContext(String baseUrl,
javax.servlet.http.HttpServletRequest request)
Update the thread-local storage with the given request information.
|
void |
setVelocityRequestContext(VelocityRequestContext velocityRequestContext)
Update the thread-local storage with the given velocityRequestContext.
|
public DefaultVelocityRequestContextFactory(ApplicationProperties applicationProperties)
public DefaultVelocityRequestContextFactory()
DefaultVelocityRequestContextFactory(com.atlassian.jira.config.properties.ApplicationProperties) insteadpublic VelocityRequestContext getJiraVelocityRequestContext()
VelocityRequestContextFactorygetJiraVelocityRequestContext in interface VelocityRequestContextFactorypublic Map<String,Object> getDefaultVelocityParams(Map<String,Object> startingParams, JiraAuthenticationContext authenticationContext)
VelocityRequestContextFactorygetDefaultVelocityParams in interface VelocityRequestContextFactorystartingParams - Map of parameters that may be used to override any of the parameters set here.authenticationContext - JiraAuthenticationContextpublic static void cacheVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
VelocityRequestContextFactory.setVelocityRequestContext(javax.servlet.http.HttpServletRequest) instead. Since v5.0.HttpServletRequest.getContextPath() along as the baseUrl.request - The HttpServletRequest used to construct the RequestContextParameterHolderpublic void setVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
VelocityRequestContextFactorysetVelocityRequestContext in interface VelocityRequestContextFactoryrequest - The http request context to store.public static void cacheVelocityRequestContext(String baseUrl, javax.servlet.http.HttpServletRequest request)
VelocityRequestContextFactory.setVelocityRequestContext(String, javax.servlet.http.HttpServletRequest) instead. Since v5.0.baseUrl - Should pass in HttpServletRequest.getContextPath()request - The HttpServletRequest used to construct the RequestContextParameterHolderpublic void setVelocityRequestContext(String baseUrl, javax.servlet.http.HttpServletRequest request)
VelocityRequestContextFactorysetVelocityRequestContext in interface VelocityRequestContextFactorybaseUrl - of the request.request - The http request context to store.public void cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
VelocityRequestContextFactory.setVelocityRequestContext(VelocityRequestContext) instead. Since v5.0.VelocityRequestContextFactorycacheVelocityRequestContext in interface VelocityRequestContextFactoryvelocityRequestContext - The velocity request context to store.public void setVelocityRequestContext(VelocityRequestContext velocityRequestContext)
VelocityRequestContextFactorysetVelocityRequestContext in interface VelocityRequestContextFactoryvelocityRequestContext - The velocity request context to store.public <I,O> O runWithStaticBaseUrl(I input,
@Nonnull
com.google.common.base.Function<I,O> runnable)
VelocityRequestContextFactorybaseURL is always used. This basically
makes the passed function ignore any smart baseURL that can be generated from the request associated
with the calling thread.runWithStaticBaseUrl in interface VelocityRequestContextFactoryinput - input to pass to the function.runnable - the function to execute.public void clearVelocityRequestContext()
VelocityRequestContextFactoryclearVelocityRequestContext in interface VelocityRequestContextFactoryCopyright © 2002-2019 Atlassian. All Rights Reserved.