@PublicApi @InjectableComponent public interface

VelocityRequestContextFactory

com.atlassian.jira.util.velocity.VelocityRequestContextFactory
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

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.

Summary

Public Methods
void cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
This method is deprecated. Use 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<StringObject> getDefaultVelocityParams(Map<StringObject> startingParams, JiraAuthenticationContext authenticationContext)
Constructs a map with a number of common parameters used by velocity templates.
VelocityRequestContext getJiraVelocityRequestContext()
Get the request context.
@Nullable <I, O> O runWithStaticBaseUrl(I input, Function<I, O> runnable)
Run the passed function in an environment where JIRA's configured baseURL is always used.
void setVelocityRequestContext(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.
void setVelocityRequestContext(String baseUrl, HttpServletRequest request)
Update the thread-local storage with the given request information.

Public Methods

public void cacheVelocityRequestContext (VelocityRequestContext velocityRequestContext)

This method is deprecated.
Use setVelocityRequestContext(VelocityRequestContext) instead. Since v5.0.

Update the thread-local storage with the given velocityRequestContext.

Parameters
velocityRequestContext The velocity request context to store.

public void clearVelocityRequestContext ()

Resets the thread local storage as if no request has occurred, effectively nulling out the current thread local velocity request context.

public Map<StringObject> getDefaultVelocityParams (Map<StringObject> 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

public VelocityRequestContext getJiraVelocityRequestContext ()

Get the request context.

Returns
  • The request context.

@Nullable public O runWithStaticBaseUrl (I input, Function<I, O> runnable)

Run the passed function in an environment where JIRA's configured baseURL 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.

Parameters
input input to pass to the function.
runnable the function to execute.
Returns
  • the result of the function.

public void setVelocityRequestContext (HttpServletRequest request)

Update the thread-local storage with the given request information.

Parameters
request The http request context to store.

public void setVelocityRequestContext (VelocityRequestContext velocityRequestContext)

Update the thread-local storage with the given velocityRequestContext.

Parameters
velocityRequestContext The velocity request context to store.

public void setVelocityRequestContext (String baseUrl, HttpServletRequest request)

Update the thread-local storage with the given request information.

Parameters
baseUrl of the request.
request The http request context to store.