public class BaseHstComponent extends GenericHstComponent
ObjectBeanManager
, request parameters, query manager, etc.
This implementation enables developers to make use of HST Content Bean's ObjectBeanManager
which provides a simple object-content mapping solution.
To use ObjectBeanManager
, you can invoke getObjectBeanManager(HstRequest)
, which retrieves
a JCR session from HstRequestContext.getSession()
internally.
When you need to persist beans through ecm workflow, you can use getWorkflowPersistenceManager(Session)
. Make
sure that the jcr session you use as parameter is obtained through getPersistableSession(HstRequest)
or
getPersistableSession(HstRequest, Credentials)
.
RESOURCE_PATH_BY_RESOURCE_ID
Constructor and Description |
---|
BaseHstComponent() |
Modifier and Type | Method and Description |
---|---|
HippoFolderBean |
getAssetBaseBean(HstRequest request) |
HippoBean |
getBeanForResolvedSiteMapItem(HstRequest request,
ResolvedSiteMapItem resolvedSiteMapItem)
Return a
HippoBean when it can be found for the relativeContentPath for the . |
String |
getComponentLocalParameter(String name)
See
getComponentParameter(String) , but now, only resolved parameters directly on the HstComponent are taken into
account: in other words, no inheritance of parameters is applied |
Map<String,String> |
getComponentLocalParameters()
See
getComponentParameters() , but now, only resolved parameter map of parameters is returned that is directly on
the HstComponenConfiguration, thus, no inheritance is applied |
String |
getComponentParameter(String name)
Returns resolved parameter from HstComponentConfiguration : resolved means that possible property placeholders like
${1} or ${year}, where the first refers to the first wildcard matcher in a resolved sitemap item, and the latter
to a resolved parameter in the resolved HstSiteMapItem
The parameter map used has inherited parameters from ancestor components, which have precedence over child components)
|
Map<String,String> |
getComponentParameters()
See
getComponentParameter(String) , where we now return all resolved parameters (thus with inheritance of
ancestor components) |
protected <T> T |
getComponentParametersInfo(HstRequest request)
Returns a proxy ParametersInfo object which resolves parameter from HstComponentConfiguration : resolved means that possible property placeholders like
${1} or ${year}, where the first refers to the first wildcard matcher in a resolved sitemap item, and the latter
to a resolved parameter in the resolved HstSiteMapItem
|
HippoBean |
getContentBean(HstRequest request)
Deprecated.
since 7.9.0 : use
HstRequestContext.getContentBean() instead |
<T extends HippoBean> |
getContentBean(HstRequest request,
Class<T> beanMappingClass)
Deprecated.
since 7.9.1 : use
org.hippoecm.hst.core.request.HstRequestContext#getContentBean(Class instead |
HippoFolderBean |
getGalleryBaseBean(HstRequest request) |
HstSite |
getHstSite(HstRequest request) |
String |
getLocalParameter(String name,
HstRequest request)
Deprecated.
since 2.26.01. Use
getComponentLocalParameter(String) instead |
Map<String,String> |
getLocalParameters(HstRequest request)
Deprecated.
since 2.26.01. Use
getComponentLocalParameters() instead |
Mount |
getMount(HstRequest request) |
ObjectBeanManager |
getObjectBeanManager(HstRequest request)
Deprecated.
since 7.9.0 : use
HstRequestContext.getObjectBeanManager() instead |
ObjectConverter |
getObjectConverter()
Deprecated.
since 7.9.0, use
ContentBeansTool.getObjectConverter() instead.
ContentBeansTool can be accessed through HstRequestContext.getContentBeansTool() and
the HstReqeustContext can be fetched from the HstRequest or through RequestContextProvider.get(). |
String |
getParameter(String name,
HstRequest request)
Deprecated.
since 2.26.01. Use
getComponentParameter(String) instead |
Map<String,String> |
getParameters(HstRequest request)
Deprecated.
since 2.26.01. Use #getComponentParameters()} instead
|
protected <T> T |
getParametersInfo(HstRequest request)
Deprecated.
since 2.26.01. Use #getComponentParametersInfo(org.hippoecm.hst.core.component.HstRequest)} instead
|
protected javax.jcr.Session |
getPersistableSession(HstRequest request)
Creates a persistable JCR session with the default credentials
|
protected javax.jcr.Session |
getPersistableSession(HstRequest request,
javax.jcr.Credentials credentials)
Creates a persistable JCR session with provided credentials.
|
String |
getPublicRequestParameter(HstRequest request,
String parameterName)
A public request parameter is a
HttpServletRequest parameter that is not namespaced. |
String[] |
getPublicRequestParameters(HstRequest request,
String parameterName)
|
HstQueryManager |
getQueryManager(HstRequest request)
Deprecated.
since 7.9.0 : use
HstRequestContext.getQueryManager() instead |
HstQueryManager |
getQueryManager(HstRequestContext ctx)
Deprecated.
since 7.9.0 : use
HstRequestContext.getQueryManager() instead |
HstQueryManager |
getQueryManager(javax.jcr.Session session)
Deprecated.
since 7.9.0 : use
HstRequestContext.getQueryManager(Session) instead |
ResolvedMount |
getResolvedMount(HstRequest request) |
HippoBean |
getSiteContentBaseBean(HstRequest request)
Deprecated.
since 7.9.0. Use
HstRequestContext.getSiteContentBaseBean() instead |
String |
getSiteContentBasePath(HstRequest request)
Deprecated.
since 7.9.0 : use
HstRequestContext.getSiteContentBasePath() instead |
protected WorkflowPersistenceManager |
getWorkflowPersistenceManager(javax.jcr.Session session)
Returns a
WorkflowPersistenceManager instance. |
protected WorkflowPersistenceManager |
getWorkflowPersistenceManager(javax.jcr.Session session,
Map<String,ContentNodeBinder> contentNodeBinders)
Returns a
WorkflowPersistenceManager instance with custom binders map. |
void |
init(javax.servlet.ServletContext servletContext,
ComponentConfiguration componentConfig)
Allows the component to initialize itself
|
boolean |
isPreview(HstRequest request) |
void |
sendRedirect(String path,
HstRequest request,
HstResponse response)
Facility method for sending a redirect to a sitemap path.
|
void |
sendRedirect(String path,
HstRequest request,
HstResponse response,
Map<String,String[]> queryParams)
Facility method for sending a redirect to a sitemap path including query params.
|
void |
sendRedirect(String path,
HstRequest request,
HstResponse response,
Map<String,String[]> queryParams,
String characterEncoding)
Facility method for sending a redirect to a sitemap path including query params and characterEncoding.
|
destroy, doAction, doBeforeRender, doBeforeServeResource, getComponentConfiguration
public void init(javax.servlet.ServletContext servletContext, ComponentConfiguration componentConfig) throws HstComponentException
HstComponent
init
in interface HstComponent
init
in class GenericHstComponent
servletContext
- the servletConfig of the HST container servletcomponentConfig
- the componentConfigBean configurationHstComponentException
@Deprecated public String getParameter(String name, HstRequest request)
getComponentParameter(String)
instead#getComponentParameter(String)}
public String getComponentParameter(String name)
name
- null if not present
@Deprecated public Map<String,String> getParameters(HstRequest request)
#getComponentParameters()}
public Map<String,String> getComponentParameters()
getComponentParameter(String)
, where we now return all resolved parameters (thus with inheritance of
ancestor components)@Deprecated public String getLocalParameter(String name, HstRequest request)
getComponentLocalParameter(String)
instead#getComponentLocalParameter(String)}
public String getComponentLocalParameter(String name)
getComponentParameter(String)
, but now, only resolved parameters directly on the HstComponent are taken into
account: in other words, no inheritance of parameters is appliedname
- null if not present
@Deprecated public Map<String,String> getLocalParameters(HstRequest request)
getComponentLocalParameters()
insteadpublic Map<String,String> getComponentLocalParameters()
getComponentParameters()
, but now, only resolved parameter map of parameters is returned that is directly on
the HstComponenConfiguration, thus, no inheritance is appliedpublic String getPublicRequestParameter(HstRequest request, String parameterName)
HttpServletRequest
parameter that is not namespaced. Thus for example ?foo=bar. Typically,
a namespaced request parameter for example looks like ?r1_r4:foo=bar.
Public request parameters are used when some parameter from some hst component needs to be readable by another hst
component. For example when you have a search box in the top of your webpage. The input value there should be
readable by the center content block displaying the search results. In that case, this method can be used
to fetch the public request parameter. Also see getPublicRequestParameters(HstRequest, String)
request
- parameterName
- null
is returnedpublic String[] getPublicRequestParameters(HstRequest request, String parameterName)
request
- parameterName
- new String[0]
is returnedpublic HstSite getHstSite(HstRequest request)
public ResolvedMount getResolvedMount(HstRequest request)
public Mount getMount(HstRequest request)
@Deprecated public String getSiteContentBasePath(HstRequest request)
HstRequestContext.getSiteContentBasePath()
insteadrequest
- public boolean isPreview(HstRequest request)
true
when this request is matched to a preview siteMount.isPreview()
@Deprecated public HippoBean getContentBean(HstRequest request)
HstRequestContext.getContentBean()
insteadResolvedSiteMapItem
belonging to the current requestUri has a relativeContentPath that points to an
existing jcr Node, a HippoBean wrapping this node is returned. When there is no relativeContentPath or the location does not exist,
null
is returnedrequest
- HippoBean
or null
when there cannot be created a content bean for the resolvedSiteMapItem belonging to the current request@Deprecated public <T extends HippoBean> T getContentBean(HstRequest request, Class<T> beanMappingClass)
org.hippoecm.hst.core.request.HstRequestContext#getContentBean(Class)
insteadrequest
- current HstRequestbeanMappingClass
- the class of the bean that you expectbeanMappingClass
or null
if bean cannot be found or is of a different class#getContentBean(HstRequest)} but only returns the bean if the found content bean is of type {@code beanMappingClass}.
When the bean cannot be found, or is not of type {@code beanMappingClass}, null
is returned
@Deprecated public HippoBean getSiteContentBaseBean(HstRequest request)
HstRequestContext.getSiteContentBaseBean()
insteadpublic HippoFolderBean getGalleryBaseBean(HstRequest request)
request
- /content/gallery
and null
if it does not existpublic HippoFolderBean getAssetBaseBean(HstRequest request)
request
- /content/assets
and null if it does not existpublic HippoBean getBeanForResolvedSiteMapItem(HstRequest request, ResolvedSiteMapItem resolvedSiteMapItem)
HippoBean
when it can be found for the relativeContentPath for the ResolvedSiteMapItem
. If there is no
relativeContentPath available in the ResolvedSiteMapItem
, or when the relativeContentPath does not point to an existing jcr node,
null
will be returnedrequest
- resolvedSiteMapItem
- HippoBean
or null
when there cannot be created a content bean for this resolvedSiteMapItem@Deprecated public HstQueryManager getQueryManager(HstRequest request)
HstRequestContext.getQueryManager()
insteadrequest
- the HstRequest
HstQueryManager
#getQueryManager(HstRequestContext)} and {@link #getQueryManager(Session)}
@Deprecated public HstQueryManager getQueryManager(HstRequestContext ctx)
HstRequestContext.getQueryManager()
insteadctx
- the HstRequestContext
HstQueryManager
#getQueryManager(HstRequest)} and {@link #getQueryManager(Session)}
@Deprecated public HstQueryManager getQueryManager(javax.jcr.Session session)
HstRequestContext.getQueryManager(Session)
insteadsession
- the Session
HstQueryManager
#getQueryManager(HstRequestContext)} and {@link #getQueryManager(HstRequest)}
@Deprecated public ObjectBeanManager getObjectBeanManager(HstRequest request)
HstRequestContext.getObjectBeanManager()
insteadpublic void sendRedirect(String path, HstRequest request, HstResponse response)
Facility method for sending a redirect to a sitemap path. You do not have to take into account the context path or Mount
path
path
- the sitemap path you want to redirect torequest
- the HstRequestresponse
- the HstResponseHstResponse.sendRedirect(String)
public void sendRedirect(String path, HstRequest request, HstResponse response, Map<String,String[]> queryParams)
Facility method for sending a redirect to a sitemap path including query params. You do not have to take into account the context path or Mount
path
path
- the sitemap path you want to redirect torequest
- the HstRequestqueryParams
- query parameters to append to the redirection urlresponse
- the HstResponseHstResponse.sendRedirect(String)
public void sendRedirect(String path, HstRequest request, HstResponse response, Map<String,String[]> queryParams, String characterEncoding)
Facility method for sending a redirect to a sitemap path including query params and characterEncoding. You do not have to take into account the context path or Mount
path
path
- the sitemap path you want to redirect torequest
- the HstRequestqueryParams
- query parameters to append to the redirection urlresponse
- the HstResponsecharacterEncoding
- character encoding for query parametersHstResponse.sendRedirect(String)
@Deprecated public ObjectConverter getObjectConverter() throws HstComponentException
ContentBeansTool.getObjectConverter()
instead.
ContentBeansTool can be accessed through HstRequestContext.getContentBeansTool()
and
the HstReqeustContext can be fetched from the HstRequest or through RequestContextProvider.get().HstComponentException
protected javax.jcr.Session getPersistableSession(HstRequest request) throws javax.jcr.RepositoryException
Note: The client should invoke logout()
method on the session after use.
Internally, Session.impersonate(Credentials)
method will be used to create a
persistable JCR session. The method is invoked on the session from the session pooling repository.
request
- javax.jcr.RepositoryException
protected javax.jcr.Session getPersistableSession(HstRequest request, javax.jcr.Credentials credentials) throws javax.jcr.RepositoryException
Note: The client should invoke logout()
method on the session after use.
Internally, Session.impersonate(Credentials)
method will be used to create a
persistable JCR session. The method is invoked on the session from the session pooling repository.
request
- javax.jcr.RepositoryException
protected WorkflowPersistenceManager getWorkflowPersistenceManager(javax.jcr.Session session)
WorkflowPersistenceManager
instance.session
- make sure this is a persistable session, obtained through or {@link #getPersistableSession(HstRequest, Credentials)}
protected WorkflowPersistenceManager getWorkflowPersistenceManager(javax.jcr.Session session, Map<String,ContentNodeBinder> contentNodeBinders)
WorkflowPersistenceManager
instance with custom binders map.session
- make sure this is a persistable session, obtained through or {@link #getPersistableSession(HstRequest, Credentials)}
contentNodeBinders
- protected <T> T getComponentParametersInfo(HstRequest request)
NOTE: Because the returned ParametersInfo proxy instance is bound to the current request, you MUST NOT store the returned object in a member variable or session. You should retrieve that per request.
The parameter map used has inherited parameters from ancestor components, which have precedence over child components)request
- the HST requestnull if not present
@Deprecated protected <T> T getParametersInfo(HstRequest request)
#getComponentParametersInfo(org.hippoecm.hst.core.component.HstRequest)}
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.