Class ThreadSafeRenderingContext
- java.lang.Object
-
- org.nuxeo.ecm.core.io.registry.context.ThreadSafeRenderingContext
-
- All Implemented Interfaces:
RenderingContext
public final class ThreadSafeRenderingContext extends Object implements RenderingContext
- Since:
- 7.2
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.io.registry.context.RenderingContext
RenderingContext.CtxBuilder, RenderingContext.SessionWrapper
-
-
Field Summary
-
Fields inherited from interface org.nuxeo.ecm.core.io.registry.context.RenderingContext
DEFAULT_LOCALE, DEFAULT_URL, REPOSITORY_NAME_REQUEST_HEADER, REPOSITORY_NAME_REQUEST_PARAMETER, RESPONSE_HEADER_ENTITY_TYPE_KEY
-
-
Constructor Summary
Constructors Constructor Description ThreadSafeRenderingContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addParameterListValues(String name, List<?> values)
Add values in the context with a given name.void
addParameterValues(String name, Object... values)
void
configureThread(RenderingContext delegates)
Configure thisRenderingContext
to use the givenRenderingContext
in the current thread.Map<String,List<Object>>
getAllParameters()
Get all parameter in this context except wrapped parameters.String
getBaseUrl()
Gets the current base url.boolean
getBooleanParameter(String name)
RenderingContext
getDelegate()
Get the underlyingRenderingContext
.Set<String>
getEnrichers(String entity)
Get all enrichers to activate on the given entity type.Set<String>
getFetched(String entity)
Get all properties to fetch for a given entity type.Locale
getLocale()
Gets the requestedLocale
.<T> T
getParameter(String name)
Get the casted parameter value for a given name.<T> List<T>
getParameters(String name)
Get the casted parameter values for a given name.Set<String>
getProperties()
Get all document properties.RenderingContext.SessionWrapper
getSession(DocumentModel document)
Gets the currentCoreSession
or try to create one.Set<String>
getTranslated(String entity)
Get all properties to translate for a given entity type.void
setExistingSession(CoreSession session)
Provides aCoreSession
to marshallers.void
setParameterListValues(String name, List<Object> values)
Push values in the context with a given name.void
setParameterValues(String name, Object... values)
WrappedContext
wrap()
seeWrappedContext
-
-
-
Method Detail
-
configureThread
public void configureThread(RenderingContext delegates)
Configure thisRenderingContext
to use the givenRenderingContext
in the current thread.- Parameters:
delegates
- The underlyingRenderingContext
.- Since:
- 7.2
-
getDelegate
public RenderingContext getDelegate()
Get the underlyingRenderingContext
.- Returns:
- The underlying
RenderingContext
. - Since:
- 7.2
-
getLocale
public Locale getLocale()
Description copied from interface:RenderingContext
Gets the requestedLocale
.- Specified by:
getLocale
in interfaceRenderingContext
-
getBaseUrl
public String getBaseUrl()
Description copied from interface:RenderingContext
Gets the current base url.- Specified by:
getBaseUrl
in interfaceRenderingContext
-
getSession
public RenderingContext.SessionWrapper getSession(DocumentModel document)
Description copied from interface:RenderingContext
Gets the currentCoreSession
or try to create one.- Specified by:
getSession
in interfaceRenderingContext
- Parameters:
document
- may be null, if present, this method search for a session in the document.- Returns:
- The current
CoreSession
if it exists. null otherwise.
-
setExistingSession
public void setExistingSession(CoreSession session)
Description copied from interface:RenderingContext
Provides aCoreSession
to marshallers.For example: a
CoreSession
from the request context.- Specified by:
setExistingSession
in interfaceRenderingContext
- Parameters:
session
- The existingCoreSession
which lifecycle is managed outside the marshalling context.
-
getProperties
public Set<String> getProperties()
Description copied from interface:RenderingContext
Get all document properties. This will aggregate all values from parameters "properties", "X-NXproperties" and "X-NXDocumentProperties". This supports value separated by comma.- Specified by:
getProperties
in interfaceRenderingContext
- Returns:
- All document properties.
-
getFetched
public Set<String> getFetched(String entity)
Description copied from interface:RenderingContext
Get all properties to fetch for a given entity type. This will aggregate all values from parameters "fetch.entity" and "X-NXfetch.entity". This supports value separated by comma.- Specified by:
getFetched
in interfaceRenderingContext
- Parameters:
entity
- The type of the entity on which you want to fetch properties.- Returns:
- All properties to fetch.
-
getTranslated
public Set<String> getTranslated(String entity)
Description copied from interface:RenderingContext
Get all properties to translate for a given entity type. This will aggregate all values from parameters "translate.entity" and "X-NXtranslate.entity". This supports value separated by comma.- Specified by:
getTranslated
in interfaceRenderingContext
- Parameters:
entity
- The type of the entity on which you want to fetch properties.- Returns:
- All properties to fetch.
-
getEnrichers
public Set<String> getEnrichers(String entity)
Description copied from interface:RenderingContext
Get all enrichers to activate on the given entity type. This will aggregate all values from parameters "enrichers.entity", "X-NXenrichers.entity" and "X-NXContext-Category". This supports value separated by comma.- Specified by:
getEnrichers
in interfaceRenderingContext
- Parameters:
entity
- The type of the entity on which you want to activate enrichers.- Returns:
- All enrichers to activate.
-
wrap
public WrappedContext wrap()
Description copied from interface:RenderingContext
seeWrappedContext
- Specified by:
wrap
in interfaceRenderingContext
- Returns:
- A new
WrappedContext
-
getParameter
public <T> T getParameter(String name)
Description copied from interface:RenderingContext
Get the casted parameter value for a given name. If multiple are available, the first found is returned.- Specified by:
getParameter
in interfaceRenderingContext
- Parameters:
name
- The parameter name.- Returns:
- The first parameter value, null if no parameter are availble.
-
getBooleanParameter
public boolean getBooleanParameter(String name)
Description copied from interface:RenderingContext
- Specified by:
getBooleanParameter
in interfaceRenderingContext
- Returns:
- true is the parameter exists and if it's Boolean.TRUE or "true", false otherwise.
-
getParameters
public <T> List<T> getParameters(String name)
Description copied from interface:RenderingContext
Get the casted parameter values for a given name.- Specified by:
getParameters
in interfaceRenderingContext
- Parameters:
name
- The parameter name.- Returns:
- The parameter values.
-
getAllParameters
public Map<String,List<Object>> getAllParameters()
Description copied from interface:RenderingContext
Get all parameter in this context except wrapped parameters.- Specified by:
getAllParameters
in interfaceRenderingContext
- Returns:
- All parameter's names and their values.
-
setParameterValues
public void setParameterValues(String name, Object... values)
- Specified by:
setParameterValues
in interfaceRenderingContext
- See Also:
RenderingContext.setParameterListValues(String, List)
-
setParameterListValues
public void setParameterListValues(String name, List<Object> values)
Description copied from interface:RenderingContext
Push values in the context with a given name. Please note that this method remove any value for the given name.- Specified by:
setParameterListValues
in interfaceRenderingContext
- Parameters:
name
- The parameter name.values
- The parameter values.
-
addParameterValues
public void addParameterValues(String name, Object... values)
- Specified by:
addParameterValues
in interfaceRenderingContext
- See Also:
RenderingContext.addParameterListValues(String, List)
-
addParameterListValues
public void addParameterListValues(String name, List<?> values)
Description copied from interface:RenderingContext
Add values in the context with a given name. Please note that this method keep current values for the given name.- Specified by:
addParameterListValues
in interfaceRenderingContext
- Parameters:
name
- The parameter name.values
- The parameter values.
-
-