public class MockHstRequestContext extends Object implements HstMutableRequestContext
Constructor and Description |
---|
MockHstRequestContext() |
Modifier and Type | Method and Description |
---|---|
void |
addComponentWindowFilter(HstComponentWindowFilter filter)
Adds the
HstComponentWindowFilter to the HstRequestContext |
void |
addMount(String alias,
Mount mount) |
void |
addMount(String type,
String alias,
Mount mount) |
void |
clearObjectAndQueryManagers() |
void |
dispose()
Dispose all the internal objects maintained for the current request processing state.
|
Object |
getAttribute(String name)
Retrieve the attribute value by the attribute name.
|
Enumeration<String> |
getAttributeNames()
Enumerates the attribute names
|
Map<String,Object> |
getAttributes()
Returns attribute map which is unmodifiable.
|
HstContainerURL |
getBaseURL()
Returns the base container URL (
HstContainerURL ) of the current request lifecycle. |
Set<String> |
getComponentFilterTags()
Expert: The tags that will be used to render container items.
|
List<HstComponentWindowFilter> |
getComponentWindowFilters()
Expert: Option to add filters to the
HstRequestContext . |
ContainerConfiguration |
getContainerConfiguration() |
HstContainerURLProvider |
getContainerURLProvider()
Returns the
HstContainerURLProvider to create HstContainerURLs |
HippoBean |
getContentBean()
Returns the content
HippoBean for this request. |
<T extends HippoBean> |
getContentBean(Class<T> beanMappingClass)
Returns same as
HstRequestContext.getContentBean() but if the found HippoBean is not of type
beanMappingClass , then null is returned. |
ContentBeansTool |
getContentBeansTool() |
ContextCredentialsProvider |
getContextCredentialsProvider()
Returns the context credentials provider
|
javax.jcr.Credentials |
getDefaultCredentials() |
HstLinkCreator |
getHstLinkCreator()
Returns the
HstLinkCreator to create navigational links |
HstQueryManagerFactory |
getHstQueryManagerFactory()
Returns a
HstQueryManagerFactory instance responsible for creating a query manager |
HstSiteMenus |
getHstSiteMenus() |
Enumeration<Locale> |
getLocales()
Returns an Enumeration of Locale objects
|
Mount |
getMount(String alias)
a mount with
Mount.getAlias() equal to alias and at least one common type with the mount from the current request. |
Mount |
getMount(String type,
String alias)
|
ObjectBeanManager |
getObjectBeanManager() |
ObjectBeanManager |
getObjectBeanManager(javax.jcr.Session session) |
ObjectConverter |
getObjectConverter()
Returns the
ObjectConverter for the current HstRequestContext . |
HstParameterInfoProxyFactory |
getParameterInfoProxyFactory()
Expert: Returns
HstParameterInfoProxyFactory to create a proxy for an interface that is referred to by a ParametersInfo annotation
on a HstComponent
annotated interface getters |
String |
getPathSuffix()
Returns the path suffix from the resolved site map item.
|
Locale |
getPreferredLocale()
Gets the preferred locale associated with this request.
|
HstQueryManager |
getQueryManager() |
HstQueryManager |
getQueryManager(javax.jcr.Session session) |
String |
getRenderHost() |
ResolvedMount |
getResolvedMount()
Returns the
ResolvedMount for this request |
ResolvedSiteMapItem |
getResolvedSiteMapItem()
Returns the
ResolvedSiteMapItem for this request |
javax.servlet.ServletContext |
getServletContext()
Returns the ServletContext for this request
|
javax.servlet.http.HttpServletRequest |
getServletRequest()
Returns the current HttpServletRequest
|
javax.servlet.http.HttpServletResponse |
getServletResponse()
Returns the current HttpServletResponse
|
javax.jcr.Session |
getSession()
Returns a session which is normally retrieved from a session pooling repository.
|
javax.jcr.Session |
getSession(boolean create)
Returns a session which can be retrieved from a session pooling repository.
|
HippoBean |
getSiteContentBaseBean()
Returns the siteContentBaseBean
HippoBean for this request. |
String |
getSiteContentBasePath() |
HstSiteMapMatcher |
getSiteMapMatcher()
Returns the
HstSiteMapMatcher to be able to match a path to a sitemap item |
Subject |
getSubject()
Gets the subject associated with the authorized entity.
|
HstURLFactory |
getURLFactory()
Returns the
HstURLFactory to create HstURLs |
VirtualHost |
getVirtualHost()
Returns the matched virtual host object
|
boolean |
isCmsRequest() |
boolean |
isFullyQualifiedURLs() |
boolean |
isPreview() |
void |
matchingFinished()
Marks the
HstRequestContext that its matching phase has been finished |
void |
removeAttribute(String name)
Removes the attribute by the attribute name.
|
void |
removeMount(String alias) |
void |
removeMount(String type,
String alias) |
void |
setAttribute(String name,
Object value)
Set an attribute to be shared among each HstComponent windows.
|
void |
setBaseURL(HstContainerURL baseURL) |
void |
setCachingObjectConverter(boolean enabled) |
void |
setCmsRequest(boolean cmsRequest) |
void |
setComponentFilterTags(Set<String> componentFilterTags)
set the conditions that will trigger a component to be added to the component window hierarchy.
|
void |
setComponentWindowFilters(List<HstComponentWindowFilter> filters)
Sets the
HstComponentWindowFilter s on the HstRequestContext |
void |
setContainerConfiguration(ContainerConfiguration containerConfiguration) |
void |
setContentBean(HippoBean contentBean) |
void |
setContentBeansTool(ContentBeansTool contentBeansTool)
Sets ContentBeansTool instance for this request context
|
void |
setContextCredentialsProvider(ContextCredentialsProvider contextCredentialsProvider) |
void |
setDefaultCredentials(javax.jcr.Credentials defaultCredentials) |
void |
setDefaultHstQueryManager(HstQueryManager defaultHstQueryManager) |
void |
setDefaultObjectBeanManager(ObjectBeanManager defaultObjectBeanManager) |
void |
setFullyQualifiedURLs(boolean fullyQualifiedURLs) |
void |
setHstLinkCreator(HstLinkCreator linkCreator) |
void |
setHstQueryManagerFactory(HstQueryManagerFactory hstQueryManagerFactory) |
void |
setHstSiteMenus(HstSiteMenus siteMenus) |
void |
setHstSiteMenusManager(HstSiteMenusManager siteMenusManager) |
void |
setLinkCreator(HstLinkCreator linkCreator) |
void |
setLocales(List<Locale> locales)
Sets the locales assocaited with this request.
|
void |
setNonDefaultHstQueryManagers(Map<javax.jcr.Session,HstQueryManager> nonDefaultHstQueryManagers) |
void |
setNonDefaultObjectBeanManagers(Map<javax.jcr.Session,ObjectBeanManager> nonDefaultObjectBeanManagers) |
void |
setParameterInfoProxyFactory(HstParameterInfoProxyFactory parameterInfoProxyFactory) |
void |
setPathSuffix(String pathSuffix)
Sets the path suffix
|
void |
setPreferredLocale(Locale preferredLocale)
Sets the preferred locale associated with this request.
|
void |
setRenderHost(String renderHost)
Sets a specific render host.
|
void |
setResolvedMount(ResolvedMount resolvedMount) |
void |
setResolvedSiteMapItem(ResolvedSiteMapItem resolvedSiteMapItem) |
void |
setServletContext(javax.servlet.ServletContext servletContext) |
void |
setServletRequest(javax.servlet.http.HttpServletRequest servletRequest) |
void |
setServletResponse(javax.servlet.http.HttpServletResponse servletResponse) |
void |
setSession(javax.jcr.Session session) |
void |
setSiteContentBaseBean(HippoBean siteContentBean) |
void |
setSiteContentBasePath(String siteContentBasePath) |
void |
setSiteMapMatcher(HstSiteMapMatcher siteMapMatcher) |
void |
setSubject(Subject subject) |
void |
setURLFactory(HstURLFactory urlFactory) |
void |
setVirtualHost(VirtualHost virtualHost) |
public boolean isPreview()
isPreview
in interface HstRequestContext
true
when this request is matched to a preview siteMount.isPreview()
public javax.servlet.ServletContext getServletContext()
HstRequestContext
getServletContext
in interface HstRequestContext
public void setServletContext(javax.servlet.ServletContext servletContext)
setServletContext
in interface HstMutableRequestContext
public javax.servlet.http.HttpServletRequest getServletRequest()
HstRequestContext
getServletRequest
in interface HstRequestContext
public void setServletRequest(javax.servlet.http.HttpServletRequest servletRequest)
setServletRequest
in interface HstMutableRequestContext
public javax.servlet.http.HttpServletResponse getServletResponse()
HstRequestContext
getServletResponse
in interface HstRequestContext
public void setServletResponse(javax.servlet.http.HttpServletResponse servletResponse)
setServletResponse
in interface HstMutableRequestContext
public Object getAttribute(String name)
HstRequestContext
getAttribute
in interface HstRequestContext
public Enumeration<String> getAttributeNames()
HstRequestContext
getAttributeNames
in interface HstRequestContext
public Map<String,Object> getAttributes()
HstRequestContext
getAttributes
in interface HstRequestContext
public HstContainerURL getBaseURL()
HstRequestContext
HstContainerURL
) of the current request lifecycle.getBaseURL
in interface HstRequestContext
public void setBaseURL(HstContainerURL baseURL)
setBaseURL
in interface HstMutableRequestContext
public javax.jcr.Credentials getDefaultCredentials()
public void setDefaultCredentials(javax.jcr.Credentials defaultCredentials)
public HstSiteMapMatcher getSiteMapMatcher()
HstRequestContext
HstSiteMapMatcher
to be able to match a path to a sitemap itemgetSiteMapMatcher
in interface HstRequestContext
public void setSiteMapMatcher(HstSiteMapMatcher siteMapMatcher)
setSiteMapMatcher
in interface HstMutableRequestContext
public HstLinkCreator getHstLinkCreator()
HstRequestContext
HstLinkCreator
to create navigational linksgetHstLinkCreator
in interface HstRequestContext
public void setHstLinkCreator(HstLinkCreator linkCreator)
public HstQueryManagerFactory getHstQueryManagerFactory()
HstRequestContext
HstQueryManagerFactory
instance responsible for creating a query managergetHstQueryManagerFactory
in interface HstRequestContext
public void setHstQueryManagerFactory(HstQueryManagerFactory hstQueryManagerFactory)
setHstQueryManagerFactory
in interface HstMutableRequestContext
public void setHstSiteMenus(HstSiteMenus siteMenus)
setHstSiteMenus
in interface HstMutableRequestContext
public HstSiteMenus getHstSiteMenus()
getHstSiteMenus
in interface HstRequestContext
public ResolvedMount getResolvedMount()
HstRequestContext
ResolvedMount
for this requestgetResolvedMount
in interface HstRequestContext
ResolvedMount
for this requestpublic void setResolvedMount(ResolvedMount resolvedMount)
setResolvedMount
in interface HstMutableRequestContext
public ResolvedSiteMapItem getResolvedSiteMapItem()
HstRequestContext
ResolvedSiteMapItem
for this requestgetResolvedSiteMapItem
in interface HstRequestContext
public void setResolvedSiteMapItem(ResolvedSiteMapItem resolvedSiteMapItem)
setResolvedSiteMapItem
in interface HstMutableRequestContext
public void setSession(javax.jcr.Session session)
setSession
in interface HstMutableRequestContext
public javax.jcr.Session getSession() throws javax.jcr.LoginException, javax.jcr.RepositoryException
HstRequestContext
Returns the current javax.jcr.Session
associated with this requestContext or, if if there is no
current JCR session, creates and returns a new JCR session.
getSession
in interface HstRequestContext
javax.jcr.LoginException
javax.jcr.RepositoryException
public javax.jcr.Session getSession(boolean create) throws javax.jcr.LoginException, javax.jcr.RepositoryException
HstRequestContext
Returns the current javax.jcr.Session
associated with this requestContext or, if if there is no
current JCR session and create
is true, returns
a new JCR session.
If create
is false
and the requestContext has no javax.jcr.Session
,
this method returns null
.
getSession
in interface HstRequestContext
javax.jcr.LoginException
javax.jcr.RepositoryException
public HstURLFactory getURLFactory()
HstRequestContext
HstURLFactory
to create HstURLsgetURLFactory
in interface HstRequestContext
public void setURLFactory(HstURLFactory urlFactory)
setURLFactory
in interface HstMutableRequestContext
public HstParameterInfoProxyFactory getParameterInfoProxyFactory()
HstRequestContext
HstParameterInfoProxyFactory
to create a proxy for an interface that is referred to by a ParametersInfo
annotation
on a HstComponent
annotated interface gettersgetParameterInfoProxyFactory
in interface HstRequestContext
HstParameterInfoProxyFactory
public HstContainerURLProvider getContainerURLProvider()
HstRequestContext
HstContainerURLProvider
to create HstContainerURLsgetContainerURLProvider
in interface HstRequestContext
public void removeAttribute(String name)
HstRequestContext
removeAttribute
in interface HstRequestContext
public void setAttribute(String name, Object value)
HstRequestContext
setAttribute
in interface HstRequestContext
name
- attribute namevalue
- attribute valuepublic ContainerConfiguration getContainerConfiguration()
getContainerConfiguration
in interface HstRequestContext
ContainerConfiguration
public void setContainerConfiguration(ContainerConfiguration containerConfiguration)
setContainerConfiguration
in interface HstMutableRequestContext
public VirtualHost getVirtualHost()
HstRequestContext
getVirtualHost
in interface HstRequestContext
public void setVirtualHost(VirtualHost virtualHost)
public ContextCredentialsProvider getContextCredentialsProvider()
HstRequestContext
getContextCredentialsProvider
in interface HstRequestContext
public void setContextCredentialsProvider(ContextCredentialsProvider contextCredentialsProvider)
public Subject getSubject()
HstRequestContext
getSubject
in interface HstRequestContext
public void setSubject(Subject subject)
setSubject
in interface HstMutableRequestContext
public Locale getPreferredLocale()
HstRequestContext
getPreferredLocale
in interface HstRequestContext
public void setPreferredLocale(Locale preferredLocale)
HstMutableRequestContext
setPreferredLocale
in interface HstMutableRequestContext
preferredLocale
- The preferred locale associated with this request.public Enumeration<Locale> getLocales()
HstRequestContext
getLocales
in interface HstRequestContext
public void setLocales(List<Locale> locales)
HstMutableRequestContext
setLocales
in interface HstMutableRequestContext
public void setPathSuffix(String pathSuffix)
HstMutableRequestContext
setPathSuffix
in interface HstMutableRequestContext
public String getPathSuffix()
HstRequestContext
getPathSuffix
in interface HstRequestContext
null
if there is no path suffixpublic Mount getMount(String alias)
HstRequestContext
a mount with Mount.getAlias()
equal to alias
and at least one common type with the mount from the current request. Thus, at least
one of the types of the found Mount.getTypes()
must be equal to one of the types of the mount of the current request.
If there can be found a Mount
with the same primary type ( Mount.getType()
) as the one for the mount of the current request, this
Mount
has precedence. If there is no primary type match, we'll return the mount that has most types in common
There will be looked if the Mount
of the current HstRequestContext
has a property that is called hst:mountXXX
where XXX
is equal to alias
. If so, there will be tried
to return a Mount
that has an alias equal to the value of this mappedAlias property hst:mountXXX
.
If there cannot be found a Mount
for via a mapped hst:mountXXX
property, there will be looked for a Mount
with
which has Mount.getAlias()
equal to alias
.
Thus a mapped alias has precedence!
getMount
in interface HstRequestContext
alias
- the alias the found Mount
or XXX in hst:mountXXX propertyMount.getAlias()
equal to alias
or mappedAlias and at least one common type with the mount from the current request. null
if there is no suitable mount.public void removeMount(String alias)
public Mount getMount(String type, String alias)
HstRequestContext
a mount with Mount.getAlias()
equal to alias
and one of its Mount.getTypes()
equal to type
.
There will be looked if the Mount
of the current HstRequestContext
has a property that is called hst:mountXXX
where XXX
is equal to alias
.
If so, there will be tried to return a Mount
that has an alias equal to the value of this mappedAlias property hst:mountXXX
. If there cannot be found a Mount
for via a mapped hst:mountXXX
property,
there will be looked for a Mount
with which has Mount.getAlias()
equal to alias
.
getMount
in interface HstRequestContext
type
- the alias the found Mount
or or XXX in hst:mountXXX propertyalias
- the type the found Mount
should haveMount.getAlias()
equal to alias
or mappedAlias and one of its Mount.getTypes()
equal to type
. null
if there is no suitable mount.public void setComponentFilterTags(Set<String> componentFilterTags)
HstMutableRequestContext
setComponentFilterTags
in interface HstMutableRequestContext
componentFilterTags
- the Set
of String
conditionspublic Set<String> getComponentFilterTags()
HstRequestContext
Expert: The tags that will be used to render container items. These tags can be used by a HstComponentFactory
implementation to decide to load some specific HstComponentWindow
s only.
This method is in general not useful for frontend developers and is more targetted for the HST Core
HST Core HstComponentFactory
implementations behave as follows:
When tags are available, and there is a container item in a container that matches the tag,
those container items will be rendered at the exclusion of the other items.
If no tags are provided, or none matches any of the tags on the container items,
only those container items that do not have a tag will be rendered.
getComponentFilterTags
in interface HstRequestContext
public List<HstComponentWindowFilter> getComponentWindowFilters()
HstRequestContext
Expert: Option to add filters to the HstRequestContext
. Note that this only affects outcome if it is done
before the actual doBeforeRender / doAction etc or rendering is invoked by the HST
getComponentWindowFilters
in interface HstRequestContext
List
of HstComponentWindowFilter
s and if none present, return a empty Listpublic void addComponentWindowFilter(HstComponentWindowFilter filter)
HstComponentWindowFilter
to the HstRequestContext
addComponentWindowFilter
in interface HstMutableRequestContext
filter
- the HstComponentWindowFilter
to be added to the HstRequestContext.getComponentWindowFilters()
public void setComponentWindowFilters(List<HstComponentWindowFilter> filters)
HstMutableRequestContext
HstComponentWindowFilter
s on the HstRequestContext
setComponentWindowFilters
in interface HstMutableRequestContext
filters
- the HstComponentWindowFilter
s to be set for the HstRequestContext.getComponentWindowFilters()
public boolean isFullyQualifiedURLs()
isFullyQualifiedURLs
in interface HstRequestContext
true
when all URLs must be fully qualified, ie, including scheme, domain and portnumber (if present)public String getRenderHost()
getRenderHost
in interface HstRequestContext
null
when no specific render host is defined. Typically,
there is only a render host when the request originated from the CMSpublic boolean isCmsRequest()
isCmsRequest
in interface HstRequestContext
true
when the request is from a cms context: This can be some REST call from the cms, or
a channel preview request inside the cms or over the HOST of the cmspublic void setLinkCreator(HstLinkCreator linkCreator)
setLinkCreator
in interface HstMutableRequestContext
public void setParameterInfoProxyFactory(HstParameterInfoProxyFactory parameterInfoProxyFactory)
setParameterInfoProxyFactory
in interface HstMutableRequestContext
public void setFullyQualifiedURLs(boolean fullyQualifiedURLs)
setFullyQualifiedURLs
in interface HstMutableRequestContext
fullyQualifiedURLs
- sets whether created URLs will be fully qualifiedpublic void setRenderHost(String renderHost)
HstMutableRequestContext
renderHost
was the
actual
used host in the request.setRenderHost
in interface HstMutableRequestContext
renderHost
- the host to be used for renderingpublic void setCmsRequest(boolean cmsRequest)
setCmsRequest
in interface HstMutableRequestContext
cmsRequest
- when the request is a cmsRequest have this parameter equal to true
HstRequestContext.isCmsRequest()
public HippoBean getContentBean()
HstRequestContext
HippoBean
for this request. After first retrieval, the content bean is cached and
the same instance will be returned when calling HstRequestContext.getContentBean()
multiple times. The backing jcr
Node
is fetched through jcr Session HstRequestContext.getSession()
getContentBean
in interface HstRequestContext
HippoBean
belonging to the ResolvedSiteMapItem
or
null
HstSiteMapItem.getRelativeContentPath()
is null
or when there is no content (jcr node) to be found at HstSiteMapItem.getRelativeContentPath()
.public <T extends HippoBean> T getContentBean(Class<T> beanMappingClass)
HstRequestContext
HstRequestContext.getContentBean()
but if the found HippoBean
is not of type
beanMappingClass
, then null
is returned.getContentBean
in interface HstRequestContext
HippoBean
of type beanMappingClass
or null
getContentBean()
public void setContentBean(HippoBean contentBean)
public HippoBean getSiteContentBaseBean()
HstRequestContext
HippoBean
for this request. After first retrieval, the bean is cached and
the same instance will be returned when calling HstRequestContext.getSiteContentBaseBean()
multiple times. The backing jcr
Node
is fetched through jcr Session HstRequestContext.getSession()
getSiteContentBaseBean
in interface HstRequestContext
HippoBean
belonging to for HstRequestContext.getSiteContentBasePath()
public void setSiteContentBaseBean(HippoBean siteContentBean)
public ContentBeansTool getContentBeansTool()
getContentBeansTool
in interface HstRequestContext
ContentBeansTool
instance. Note that the ContentBeansTool
instance is an object shared by
multiple threads. Invoking this method before the ContentBeansTool
is set on the HstRequestContext
results in null
being returned. As of 2.26.xx, this is for example the case when invoking
HstRequestContext.getContentBeansTool()
during execution of a HstSiteMapItemHandler
public void setContentBeansTool(ContentBeansTool contentBeansTool)
HstMutableRequestContext
setContentBeansTool
in interface HstMutableRequestContext
public ObjectConverter getObjectConverter()
HstRequestContext
ObjectConverter
for the current HstRequestContext
. Note the returned ObjectConverter
is likely to be a different one than returned vua getContentBeansTool().getObjectConverter()
because the latter is a non-caching object converter while this HstRequestContext.getObjectConverter()
returns possibly
a caching object convertergetObjectConverter
in interface HstRequestContext
ObjectConverter
for the current HstRequestContext
public void setCachingObjectConverter(boolean enabled)
setCachingObjectConverter
in interface HstMutableRequestContext
public void setHstSiteMenusManager(HstSiteMenusManager siteMenusManager)
setHstSiteMenusManager
in interface HstMutableRequestContext
public String getSiteContentBasePath()
getSiteContentBasePath
in interface HstRequestContext
ResolvedMount
belonging to the current
HttpServletRequest
. The path never starts with a "/" as it is relative to the root node.public void setSiteContentBasePath(String siteContentBasePath)
public void setDefaultObjectBeanManager(ObjectBeanManager defaultObjectBeanManager)
public void setNonDefaultObjectBeanManagers(Map<javax.jcr.Session,ObjectBeanManager> nonDefaultObjectBeanManagers)
public void setDefaultHstQueryManager(HstQueryManager defaultHstQueryManager)
public void setNonDefaultHstQueryManagers(Map<javax.jcr.Session,HstQueryManager> nonDefaultHstQueryManagers)
public ObjectBeanManager getObjectBeanManager() throws IllegalStateException
getObjectBeanManager
in interface HstRequestContext
ObjectBeanManager
instance for the current HstRequestContext
backed by the
HstRequestContext.getSession()
IllegalStateException
- if the application is unable to provide a ObjectBeanManagerpublic ObjectBeanManager getObjectBeanManager(javax.jcr.Session session) throws IllegalStateException
getObjectBeanManager
in interface HstRequestContext
session
- the Session
to create this ObjectBeanManager
withObjectBeanManager
instance for the current HstRequestContext
backed by the
session
IllegalStateException
- if the application is unable to provide a ObjectBeanManagerpublic HstQueryManager getQueryManager() throws IllegalStateException
getQueryManager
in interface HstRequestContext
HstQueryManager
backed by the
HstRequestContext.getSession()
IllegalStateException
- if the application is unable to provide a HstQueryManagerpublic HstQueryManager getQueryManager(javax.jcr.Session session) throws IllegalStateException
getQueryManager
in interface HstRequestContext
session
- the Session
to create this ObjectBeanManager
withHstQueryManager
backed by the
session
IllegalStateException
- if the application is unable to provide a HstQueryManagerpublic void clearObjectAndQueryManagers()
clearObjectAndQueryManagers
in interface HstMutableRequestContext
public void dispose()
HstMutableRequestContext
dispose
in interface HstMutableRequestContext
public void matchingFinished()
HstMutableRequestContext
HstRequestContext
that its matching phase has been finishedmatchingFinished
in interface HstMutableRequestContext
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.