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 voidaddParameterListValues(String name, List<?> values)Add values in the context with a given name.voidaddParameterValues(String name, Object... values)voidconfigureThread(RenderingContext delegates)Configure thisRenderingContextto use the givenRenderingContextin the current thread.Map<String,List<Object>>getAllParameters()Get all parameter in this context except wrapped parameters.StringgetBaseUrl()Gets the current base url.booleangetBooleanParameter(String name)RenderingContextgetDelegate()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.LocalegetLocale()Gets the requestedLocale.<T> TgetParameter(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.SessionWrappergetSession(DocumentModel document)Gets the currentCoreSessionor try to create one.Set<String>getTranslated(String entity)Get all properties to translate for a given entity type.voidsetExistingSession(CoreSession session)Provides aCoreSessionto marshallers.voidsetParameterListValues(String name, List<Object> values)Push values in the context with a given name.voidsetParameterValues(String name, Object... values)WrappedContextwrap()seeWrappedContext
-
-
-
Method Detail
-
configureThread
public void configureThread(RenderingContext delegates)
Configure thisRenderingContextto use the givenRenderingContextin 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:RenderingContextGets the requestedLocale.- Specified by:
getLocalein interfaceRenderingContext
-
getBaseUrl
public String getBaseUrl()
Description copied from interface:RenderingContextGets the current base url.- Specified by:
getBaseUrlin interfaceRenderingContext
-
getSession
public RenderingContext.SessionWrapper getSession(DocumentModel document)
Description copied from interface:RenderingContextGets the currentCoreSessionor try to create one.- Specified by:
getSessionin interfaceRenderingContext- Parameters:
document- may be null, if present, this method search for a session in the document.- Returns:
- The current
CoreSessionif it exists. null otherwise.
-
setExistingSession
public void setExistingSession(CoreSession session)
Description copied from interface:RenderingContextProvides aCoreSessionto marshallers.For example: a
CoreSessionfrom the request context.- Specified by:
setExistingSessionin interfaceRenderingContext- Parameters:
session- The existingCoreSessionwhich lifecycle is managed outside the marshalling context.
-
getProperties
public Set<String> getProperties()
Description copied from interface:RenderingContextGet all document properties. This will aggregate all values from parameters "properties", "X-NXproperties" and "X-NXDocumentProperties". This supports value separated by comma.- Specified by:
getPropertiesin interfaceRenderingContext- Returns:
- All document properties.
-
getFetched
public Set<String> getFetched(String entity)
Description copied from interface:RenderingContextGet 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:
getFetchedin 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:RenderingContextGet 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:
getTranslatedin 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:RenderingContextGet 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:
getEnrichersin 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:RenderingContextseeWrappedContext- Specified by:
wrapin interfaceRenderingContext- Returns:
- A new
WrappedContext
-
getParameter
public <T> T getParameter(String name)
Description copied from interface:RenderingContextGet the casted parameter value for a given name. If multiple are available, the first found is returned.- Specified by:
getParameterin 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:
getBooleanParameterin 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:RenderingContextGet the casted parameter values for a given name.- Specified by:
getParametersin interfaceRenderingContext- Parameters:
name- The parameter name.- Returns:
- The parameter values.
-
getAllParameters
public Map<String,List<Object>> getAllParameters()
Description copied from interface:RenderingContextGet all parameter in this context except wrapped parameters.- Specified by:
getAllParametersin interfaceRenderingContext- Returns:
- All parameter's names and their values.
-
setParameterValues
public void setParameterValues(String name, Object... values)
- Specified by:
setParameterValuesin interfaceRenderingContext- See Also:
RenderingContext.setParameterListValues(String, List)
-
setParameterListValues
public void setParameterListValues(String name, List<Object> values)
Description copied from interface:RenderingContextPush values in the context with a given name. Please note that this method remove any value for the given name.- Specified by:
setParameterListValuesin interfaceRenderingContext- Parameters:
name- The parameter name.values- The parameter values.
-
addParameterValues
public void addParameterValues(String name, Object... values)
- Specified by:
addParameterValuesin interfaceRenderingContext- See Also:
RenderingContext.addParameterListValues(String, List)
-
addParameterListValues
public void addParameterListValues(String name, List<?> values)
Description copied from interface:RenderingContextAdd values in the context with a given name. Please note that this method keep current values for the given name.- Specified by:
addParameterListValuesin interfaceRenderingContext- Parameters:
name- The parameter name.values- The parameter values.
-
-