|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hippoecm.hst.core.component.GenericHstComponent
org.hippoecm.hst.component.support.bean.BaseHstComponent
public class BaseHstComponent
A base HstComponent implementation to provide some facility methods for accessing content node POJO objects,
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)
.
Field Summary | |
---|---|
static String |
BEANS_ANNOTATED_CLASSES_CONF_PARAM
|
protected boolean |
beansInitialized
|
static String |
DEFAULT_BEANS_ANNOTATED_CLASSES_CONF
|
protected HstQueryManagerFactory |
hstQueryManagerFactory
|
static String |
OBJECT_CONVERTER_CONTEXT_ATTRIBUTE
|
protected ObjectConverter |
objectConverter
|
Fields inherited from class org.hippoecm.hst.core.component.GenericHstComponent |
---|
RESOURCE_PATH_BY_RESOURCE_ID |
Constructor Summary | |
---|---|
BaseHstComponent()
|
Method Summary | ||
---|---|---|
HippoFolderBean |
getAssetBaseBean(HstRequest request)
|
|
HippoBean |
getBeanForResolvedSiteMapItem(HstRequest request,
ResolvedSiteMapItem resolvedSiteMapItem)
Return a HippoBean when it can be found for the relativeContentPath for the . |
|
HippoBean |
getContentBean(HstRequest request)
When the belonging to the current requestUri has a relativeContentPath that points to an
existing jcr Node, a HippoBean wrapping this node is returned. |
|
|
getContentBean(HstRequest request,
Class<T> beanMappingClass)
|
|
ComponentManager |
getDefaultClientComponentManager()
This returns the client ComponentManager if one is configured with its default name. |
|
protected String[] |
getFallBackJcrNodeTypes()
Deprecated. |
|
HippoFolderBean |
getGalleryBaseBean(HstRequest request)
|
|
HstSite |
getHstSite(HstRequest request)
|
|
protected List<Class<? extends HippoBean>> |
getLocalAnnotatedClasses()
when you want to inject specific component only custom annotated classes override this method This method is only called during the init() phase of a component |
|
String |
getLocalParameter(String name,
HstRequest request)
See getParameter(String, HstRequest) , but now, only resolved parameters directly on the HstComponent are taken into
acoount: in other words, no inheritance of parameters is applied |
|
Map<String,String> |
getLocalParameters(HstRequest request)
See getParameters(HstRequest) , but now, only resolved parameter map of parameters is returned that is directly on
the HstComponenConfiguration, thus, no inheritance is applied |
|
Mount |
getMount(HstRequest request)
|
|
ObjectBeanManager |
getObjectBeanManager(HstRequest request)
|
|
ObjectConverter |
getObjectConverter()
|
|
String |
getParameter(String name,
HstRequest request)
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> |
getParameters(HstRequest request)
See getParameter(String, HstRequest) , where we now return all resolved parameters (thus with inheritance of
ancestor components) |
|
protected
|
getParametersInfo(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 |
|
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 request parameter that is not namespaced. |
|
String[] |
getPublicRequestParameters(HstRequest request,
String parameterName)
Also see getPublicRequestParameter(HstRequest, String) . |
|
HstQueryManager |
getQueryManager()
Deprecated. use getQueryManager(HstRequest) , getQueryManager(HstRequestContext) or #getQue instead |
|
HstQueryManager |
getQueryManager(HstRequest request)
|
|
HstQueryManager |
getQueryManager(HstRequestContext ctx)
|
|
HstQueryManager |
getQueryManager(javax.jcr.Session session)
|
|
ResolvedMount |
getResolvedMount(HstRequest request)
|
|
HippoBean |
getSiteContentBaseBean(HstRequest request)
|
|
String |
getSiteContentBasePath(HstRequest request)
|
|
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. |
Methods inherited from class org.hippoecm.hst.core.component.GenericHstComponent |
---|
destroy, doAction, doBeforeRender, doBeforeServeResource, getComponentConfiguration |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String BEANS_ANNOTATED_CLASSES_CONF_PARAM
public static final String DEFAULT_BEANS_ANNOTATED_CLASSES_CONF
public static final String OBJECT_CONVERTER_CONTEXT_ATTRIBUTE
protected boolean beansInitialized
protected ObjectConverter objectConverter
protected HstQueryManagerFactory hstQueryManagerFactory
Constructor Detail |
---|
public BaseHstComponent()
Method Detail |
---|
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 configuration
HstComponentException
public String getParameter(String name, HstRequest request)
name
- request
-
null if not present
public Map<String,String> getParameters(HstRequest request)
getParameter(String, HstRequest)
, where we now return all resolved parameters (thus with inheritance of
ancestor components)
request
-
public String getLocalParameter(String name, HstRequest request)
getParameter(String, HstRequest)
, but now, only resolved parameters directly on the HstComponent are taken into
acoount: in other words, no inheritance of parameters is applied
name
- request
-
null if not present
public Map<String,String> getLocalParameters(HstRequest request)
getParameters(HstRequest)
, but now, only resolved parameter map of parameters is returned that is directly on
the HstComponenConfiguration, thus, no inheritance is applied
request
-
public String getPublicRequestParameter(HstRequest request, String parameterName)
getPublicRequestParameters(HstRequest, String)
request
- parameterName
-
null
is returnedpublic String[] getPublicRequestParameters(HstRequest request, String parameterName)
getPublicRequestParameter(HstRequest, String)
.
request
- parameterName
-
new String[0]
is returnedpublic HstSite getHstSite(HstRequest request)
public ResolvedMount getResolvedMount(HstRequest request)
public Mount getMount(HstRequest request)
public String getSiteContentBasePath(HstRequest request)
request
-
public boolean isPreview(HstRequest request)
true
when this request is matched to a preview siteMount.isPreview()
public HippoBean getContentBean(HstRequest request)
ResolvedSiteMapItem
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 returned
request
-
HippoBean
or null
when there cannot be created a content bean for the resolvedSiteMapItem belonging to the current requestpublic <T extends HippoBean> T getContentBean(HstRequest request, Class<T> beanMappingClass)
request
- beanMappingClass
- the class of the bean that you expect
beanMappingClass
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
public HippoBean getSiteContentBaseBean(HstRequest request)
public 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 returned
request
- resolvedSiteMapItem
-
HippoBean
or null
when there cannot be created a content bean for this resolvedSiteMapItem@Deprecated public HstQueryManager getQueryManager()
getQueryManager(HstRequest)
, getQueryManager(HstRequestContext)
or #getQue instead
public HstQueryManager getQueryManager(HstRequest request)
request
- the HstRequest
HstQueryManager
same as {@link #getQueryManager(HstRequestContext)} and {@link #getQueryManager(Session)} does
public HstQueryManager getQueryManager(HstRequestContext ctx)
ctx
- the HstRequestContext
HstQueryManager
same as {@link #getQueryManager(HstRequest)} and {@link #getQueryManager(Session)} does
public HstQueryManager getQueryManager(javax.jcr.Session session)
session
- the Session
HstQueryManager
same as {@link #getQueryManager(HstRequestContext)} and {@link #getQueryManager(HstRequest)} does
public ObjectBeanManager getObjectBeanManager(HstRequest request)
public ComponentManager getDefaultClientComponentManager()
null
if none configuredpublic 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)
public ObjectConverter getObjectConverter() throws HstComponentException
HstComponentException
@Deprecated protected String[] getFallBackJcrNodeTypes()
getObjectConverter()
method instead.
This method just returns the default fallback primary node types by using ObjectConverterUtils.getDefaultFallbackNodeTypes()
.
protected List<Class<? extends HippoBean>> getLocalAnnotatedClasses()
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 getParametersInfo(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 request
null if not present
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |