com.atlassian.jira.util.velocity
Class MockVelocityRequestContextFactory

java.lang.Object
  extended by com.atlassian.jira.util.velocity.MockVelocityRequestContextFactory
All Implemented Interfaces:
VelocityRequestContextFactory

public class MockVelocityRequestContextFactory
extends Object
implements VelocityRequestContextFactory


Constructor Summary
MockVelocityRequestContextFactory(String baseUrl)
           
MockVelocityRequestContextFactory(String baseUrl, String staticBaseUrl)
           
 
Method Summary
 void cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
          Update the thread-local storage with the given velocityRequestContext.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockVelocityRequestContextFactory

public MockVelocityRequestContextFactory(String baseUrl)

MockVelocityRequestContextFactory

public MockVelocityRequestContextFactory(String baseUrl,
                                         String staticBaseUrl)
Method Detail

getJiraVelocityRequestContext

public VelocityRequestContext getJiraVelocityRequestContext()
Description copied from interface: VelocityRequestContextFactory
Get the request context.

Specified by:
getJiraVelocityRequestContext in interface VelocityRequestContextFactory
Returns:
The request context.

getDefaultVelocityParams

public Map<String,Object> getDefaultVelocityParams(Map<String,Object> startingParams,
                                                   JiraAuthenticationContext authenticationContext)
Description copied from interface: VelocityRequestContextFactory
Constructs a map with a number of common parameters used by velocity templates.

Specified by:
getDefaultVelocityParams in interface VelocityRequestContextFactory
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

public void cacheVelocityRequestContext(VelocityRequestContext velocityRequestContext)
Description copied from interface: VelocityRequestContextFactory
Update the thread-local storage with the given velocityRequestContext.

Specified by:
cacheVelocityRequestContext in interface VelocityRequestContextFactory
Parameters:
velocityRequestContext - The velocity request context to store.

clearVelocityRequestContext

public void clearVelocityRequestContext()
Description copied from interface: VelocityRequestContextFactory
Resets the thread local storage as if no request has occurred, effectively nulling out the current thread local velocity request context.

Specified by:
clearVelocityRequestContext in interface VelocityRequestContextFactory

setVelocityRequestContext

public void setVelocityRequestContext(javax.servlet.http.HttpServletRequest request)
Description copied from interface: VelocityRequestContextFactory
Update the thread-local storage with the given request information.

Specified by:
setVelocityRequestContext in interface VelocityRequestContextFactory
Parameters:
request - The http request context to store.

setVelocityRequestContext

public void setVelocityRequestContext(String baseUrl,
                                      javax.servlet.http.HttpServletRequest request)
Description copied from interface: VelocityRequestContextFactory
Update the thread-local storage with the given request information.

Specified by:
setVelocityRequestContext in interface VelocityRequestContextFactory
Parameters:
baseUrl - of the request.
request - The http request context to store.

setVelocityRequestContext

public void setVelocityRequestContext(VelocityRequestContext velocityRequestContext)
Description copied from interface: VelocityRequestContextFactory
Update the thread-local storage with the given velocityRequestContext.

Specified by:
setVelocityRequestContext in interface VelocityRequestContextFactory
Parameters:
velocityRequestContext - The velocity request context to store.

runWithStaticBaseUrl

@Nullable
public <I,O> O runWithStaticBaseUrl(@Nullable
                                             I input,
                                             @Nonnull
                                             com.google.common.base.Function<I,O> runnable)
Description copied from interface: VelocityRequestContextFactory
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.

Specified by:
runWithStaticBaseUrl in interface VelocityRequestContextFactory
Parameters:
input - input to pass to the function.
runnable - the function to execute.
Returns:
the result of the function.


Copyright © 2002-2014 Atlassian. All Rights Reserved.