public class ContentBeanUtils extends Object
HstRequestContext
is available via a thread local via
RequestContextProvider.get()
. This is the case when this utility is used in the context
of HST request processing. If you only include the hst-content-beans dependency to a project, the utility method in this
class do not functionModifier and Type | Method and Description |
---|---|
static HstQuery |
createIncomingBeansQuery(HippoDocumentBean bean,
HippoBean scope,
int depth,
Class<? extends HippoBean> beanMappingClass,
boolean includeSubTypes)
Returns a HstQuery for incoming beans (incoming beans within scope
scope ). |
static HstQuery |
createIncomingBeansQuery(HippoDocumentBean bean,
HippoBean scope,
int depth,
ObjectConverter converter,
Class<? extends HippoBean> beanMappingClass,
boolean includeSubTypes)
Deprecated.
since 7.9.0 : objectConverter not used any more.
use
createIncomingBeansQuery(HippoDocumentBean, HippoBean, int, Class, boolean) instead |
static HstQuery |
createIncomingBeansQuery(HippoDocumentBean bean,
HippoBean scope,
List<String> linkPaths,
Class<? extends HippoBean> beanMappingClass,
boolean includeSubTypes)
Returns a HstQuery for incoming beans (incoming beans within scope
scope ). |
static HstQuery |
createIncomingBeansQuery(HippoDocumentBean bean,
HippoBean scope,
List<String> linkPaths,
ObjectConverter converter,
Class<? extends HippoBean> beanMappingClass,
boolean includeSubTypes)
Deprecated.
since 7.9.0 : objectConverter not used any more.
use
createIncomingBeansQuery(HippoDocumentBean, HippoBean, List, Class, boolean) instead |
static HstQuery |
createIncomingBeansQuery(HippoDocumentBean bean,
HippoBean scope,
String linkPath,
Class<? extends HippoBean> beanMappingClass,
boolean includeSubTypes)
Returns a HstQuery for incoming beans (incoming beans within scope
scope ). |
static HstQuery |
createIncomingBeansQuery(HippoDocumentBean bean,
HippoBean scope,
String linkPath,
ObjectConverter converter,
Class<? extends HippoBean> beanMappingClass,
boolean includeSubTypes)
Deprecated.
since 7.9.0 : objectConverter not used any more.
use
createIncomingBeansQuery(HippoDocumentBean, HippoBean, String, Class, boolean) instead |
static javax.jcr.Session |
getDisposableSession(HstRequestContext requestContext,
String sessionIdentifier)
This method tries to get a
Session from a disposable pool which is identified by
disposablePoolIdentifier or a Session from a security delegate
If sessionIdentifier is empty or null an HstComponentException will be thrown. |
static <T extends HippoBean> |
getFacetedNavigationResultDocument(HstQuery query,
Class<T> beanMappingClass)
Tries to return a bean that is located in a faceted navigation tree below a result set.
|
static <T extends HippoBean> |
getFacetedNavigationResultDocument(HstQuery query,
String relPath,
Class<T> beanMappingClass)
Tries to return a bean that is located in a faceted navigation tree below a result set.
|
static <T extends HippoBean> |
getFacetedNavigationResultDocument(HstQuery query,
String absBasePath,
String relPath,
Class<T> beanMappingClass)
Tries to return a bean that is located in a faceted navigation tree below a result set.
|
static <T extends HippoBean> |
getFacetedNavigationResultDocument(String query,
Class<T> beanMappingClass)
Tries to return a bean that is located in a faceted navigation tree below a result set.
|
static <T extends HippoBean> |
getFacetedNavigationResultDocument(String query,
String relPath,
Class<T> beanMappingClass)
Tries to return a bean that is located in a faceted navigation tree below a result set.
|
static <T extends HippoBean> |
getFacetedNavigationResultDocument(String query,
String absBasePath,
String relPath,
Class<T> beanMappingClass)
Tries to return a bean that is located in a faceted navigation tree below a result set.
|
static HippoFacetNavigationBean |
getFacetNavigationBean(HstQuery query)
|
static HippoFacetNavigationBean |
getFacetNavigationBean(HstQuery query,
String relPath)
Same as
getFacetNavigationBean(HstQuery) only now instead of having the faceted navigation
node from the ResolvedSiteMapItem we add a relPath where it should be found |
static HippoFacetNavigationBean |
getFacetNavigationBean(HstQuery query,
String absBasePath,
String relPath)
Same as
getFacetNavigationBean(HstQuery) only now instead of having the faceted navigation
node from the ResolvedSiteMapItem we add absBasePath and relPath where it should be found |
static HippoFacetNavigationBean |
getFacetNavigationBean(String query) |
static HippoFacetNavigationBean |
getFacetNavigationBean(String relPath,
String query) |
static HippoFacetNavigationBean |
getFacetNavigationBean(String absBasePath,
String relPath,
String query)
Returns the
HippoFacetNavigationBean for absBasePath , relPath and
accounted for the free text query . |
static <T extends HippoBean> |
getIncomingBeans(HstQuery query,
Class<? extends HippoBean> beanMappingClass)
Returns a list of beans of type T (the same type as
beanMappingClass ) that have a (facet)link to the HippoDocumentBean bean . |
static javax.jcr.Session |
getPreviewCmsQuerySession(HstRequestContext requestContext,
String sessionIdentifier) |
static boolean |
isBeanType(Object bean,
String typeName)
Determines if the class or interface represented by this content bean object is either the same as, or is a
subclass of, the class or interface represented by the specified fully qualified class name parameter.
|
public static boolean isBeanType(Object bean, String typeName)
bean
- content bean objecttypeName
- fully qualified class name or simple class name@Deprecated public static HstQuery createIncomingBeansQuery(HippoDocumentBean bean, HippoBean scope, String linkPath, ObjectConverter converter, Class<? extends HippoBean> beanMappingClass, boolean includeSubTypes) throws QueryException
createIncomingBeansQuery(HippoDocumentBean, HippoBean, String, Class, boolean)
insteadQueryException
public static HstQuery createIncomingBeansQuery(HippoDocumentBean bean, HippoBean scope, String linkPath, Class<? extends HippoBean> beanMappingClass, boolean includeSubTypes) throws QueryException
scope
). You can add filters and ordering to the query before executing it
You need to add a linkPath
: this is that path, that the incoming beans use to link to the HippoDocumentBean bean
. For example, with 'myproject:link/@hippo:docbase' or even 'wildcard/@hippo:docbase' or
'wildcard/wildcard/@hippo:docbase' where wildcard = *bean
- The HippoDocumentBean that you have, and for which you want to find the other beans that have a link to it (incoming beans)scope
- the scope (hierarchical location) to search below for 'incoming beans'linkPath
- the path where the 'incoming beans' have there link (mirror) stored, for example at myns:links/@hippo:docbasebeanMappingClass
- the type the 'incoming beans' should be ofincludeSubTypes
- true
when subtypes of beanMappingClass should be included in the resultbean
QueryException
@Deprecated public static HstQuery createIncomingBeansQuery(HippoDocumentBean bean, HippoBean scope, int depth, ObjectConverter converter, Class<? extends HippoBean> beanMappingClass, boolean includeSubTypes) throws QueryException
createIncomingBeansQuery(HippoDocumentBean, HippoBean, int, Class, boolean)
insteadQueryException
public static HstQuery createIncomingBeansQuery(HippoDocumentBean bean, HippoBean scope, int depth, Class<? extends HippoBean> beanMappingClass, boolean includeSubTypes) throws QueryException
scope
). You can add filters and ordering to the query before executing it
You need to add a depth
: this is the maximum depth, that the incoming beans use to link to the HippoDocumentBean bean
. For example, with 'myproject:link/@hippo:docbase' is depth 1,
'myproject:somecompound/myproject:link/@hippo:docbase' is depth 2bean
- The HippoDocumentBean that you have, and for which you want to find the other beans that have a link to it (incoming beans)scope
- the scope (hierarchical location) to search below for 'incoming beans'depth
- the depth
until which the links below the HippoDocuments you want to find can be. Maximum depth is 4, when larger, a QueryException is thrownbeanMappingClass
- the type the 'incoming beans' should be ofincludeSubTypes
- true
when subtypes of beanMappingClass should be included in the resultbean
QueryException
- when depth
is larger than 4@Deprecated public static HstQuery createIncomingBeansQuery(HippoDocumentBean bean, HippoBean scope, List<String> linkPaths, ObjectConverter converter, Class<? extends HippoBean> beanMappingClass, boolean includeSubTypes) throws QueryException
createIncomingBeansQuery(HippoDocumentBean, HippoBean, List, Class, boolean)
insteadQueryException
public static HstQuery createIncomingBeansQuery(HippoDocumentBean bean, HippoBean scope, List<String> linkPaths, Class<? extends HippoBean> beanMappingClass, boolean includeSubTypes) throws QueryException
scope
). You can add filters and ordering to the query before executing it
You need to add linkPaths
: these are the paths, that the incoming beans use to link to the HippoDocumentBean bean
. For example, with 'myproject:link/@hippo:docbase' or even 'wildcard/@hippo:docbase' or
'wildcard/wildcard/@hippo:docbase' where wildcard = *bean
- The HippoDocumentBean that you have, and for which you want to find the other beans that have a link to it (incoming beans)scope
- the scope (hierarchical location) to search below for 'incoming beans'linkPaths
- the paths where the 'incoming beans' have there link (mirror) stored, for example at {myns:links/@hippo:docbase, myns:alsolinks/@hippo:docbase }beanMappingClass
- the type the 'incoming beans' should be ofincludeSubTypes
- true
when subtypes of beanMappingClass should be included in the resultbean
QueryException
public static <T extends HippoBean> List<T> getIncomingBeans(HstQuery query, Class<? extends HippoBean> beanMappingClass) throws QueryException
beanMappingClass
) that have a (facet)link to the HippoDocumentBean bean
. If no incoming beans are found,
an empty
list will be returned.QueryException
public static HippoFacetNavigationBean getFacetNavigationBean(String absBasePath, String relPath, String query) throws HstComponentException
Returns the HippoFacetNavigationBean
for absBasePath
, relPath
and
accounted for the free text query
. When query
is null
or
empty, the HippoFacetNavigationBean without free text search is returned. Else, a HippoFacetNavigationBean with free text search is returned. If the
HippoFacetNavigationBean does not exist in the faceted navigation tree in combination with the free text search, null
is returned.
The relPath
is relative to absBasePath
and must not start with a /
HstComponentException
is thrownabsBasePath
- the absolute path (starting with /) from where to get the faceted navigation bean for relPath
and
query
. The absBasePath
is NOT allowed to point to or to a descendant of a faceted navigation
noderelPath
- the relative path to the faceted navigation node (thus not start with a '/') and is relative to the site content base pathquery
- the free text query that should be accounted for for this facNavBean
, can be null
in case of no queryHstComponentException
public static HippoFacetNavigationBean getFacetNavigationBean(String relPath, String query) throws HstComponentException
HstComponentException
#getFacetNavigationBean(String, String, String)} with absBasePath
as "/"+ requestContext.getSiteContentBasePath();
public static HippoFacetNavigationBean getFacetNavigationBean(String query) throws HstComponentException
HstComponentException
#getFacetNavigationBean(String, String, String)} with absBasePath
as "/"+ requestContext.getSiteContentBasePath() and
relPath
as requestContext.getResolvedSiteMapItem().getRelativeContentPath()
public static HippoFacetNavigationBean getFacetNavigationBean(HstQuery query) throws HstComponentException
HstComponentException
#getFacetNavigationBean(String)}
public static HippoFacetNavigationBean getFacetNavigationBean(HstQuery query, String relPath) throws HstComponentException
getFacetNavigationBean(HstQuery)
only now instead of having the faceted navigation
node from the ResolvedSiteMapItem
we add a relPath
where it should be foundquery
- a HstQuery
objectrelPath
- the relative path from site base content to the faceted navigation node, which must not start with a / and is relative to the site content base pathHippoFacetNavigationBean
accounted for this query
and relPath
and null
if we could not find the HippoFacetNavigationBean when the query
is appliedHstComponentException
#getFacetNavigationBean(String)}
public static HippoFacetNavigationBean getFacetNavigationBean(HstQuery query, String absBasePath, String relPath) throws HstComponentException
getFacetNavigationBean(HstQuery)
only now instead of having the faceted navigation
node from the ResolvedSiteMapItem
we add absBasePath
and relPath
where it should be foundquery
- a HstQuery
objectabsBasePath
- the absolute path (starting with /) from where to get the faceted navigation bean for relPath
and
query
. The absBasePath
is NOT allowed to point to or to a descendant of a faceted navigation
noderelPath
- the relative path from absBasePath to the faceted navigation node, which must not start with a / and is relative to the site content base pathHippoFacetNavigationBean
accounted for this query
and relPath
and null
if we could not find the HippoFacetNavigationBean when the query
is appliedHstComponentException
#getFacetNavigationBean(String)}
public static <T extends HippoBean> T getFacetedNavigationResultDocument(String query, String absBasePath, String relPath, Class<T> beanMappingClass)
beanMappingClass
, null
will be returned.T
- query
- the free text search as String that is used for this faceted navigation. The query should already
have been processed by SearchInputParsingUtils.parse(String, boolean)
if necessary.absBasePath
- the absolute path (starting with /) from where to get the faceted navigation bean for relPath
and
query
. The absBasePath
is NOT allowed to point to or to a descendant of a faceted navigation
noderelPath
- the relative path from absBasePath
to the faceted navigation node, which must not start with a / and is relative to the site content base pathbeanMappingClass
- the class T must be ofnull
if it cannot be found or is not of type T
public static <T extends HippoBean> T getFacetedNavigationResultDocument(String query, String relPath, Class<T> beanMappingClass)
beanMappingClass
, null
will be returned.T
- query
- the free text search as String that is used for this faceted navigation. The query should already
have been processed by SearchInputParsingUtils.parse(String, boolean)
if necessary.relPath
- the relative path from site base content to the faceted navigation node, which must not start with a / and is relative to the site content base pathbeanMappingClass
- the class T must be ofnull
if it cannot be found or is not of type T
public static <T extends HippoBean> T getFacetedNavigationResultDocument(String query, Class<T> beanMappingClass)
beanMappingClass
, null
will be returned.T
- query
- the free text search as String that is used for this faceted navigationbeanMappingClass
- the class T must be ofnull
if it cannot be found or is not of type T
public static <T extends HippoBean> T getFacetedNavigationResultDocument(HstQuery query, String absBasePath, String relPath, Class<T> beanMappingClass)
beanMappingClass
, null
will be returned.T
- query
- the free text search as HstQuery
that is used for this faceted navigationabsBasePath
- the absolute path (starting with /) from where to get the faceted navigation bean for relPath
and
query
. The absBasePath
is NOT allowed to point to or to a descendant of a faceted navigation
noderelPath
- the relative path from absBasePath
to the faceted navigation node, which must not start with a / and is relative to the site content base pathbeanMappingClass
- the class T must be ofnull
if it cannot be found or is not of type T
public static <T extends HippoBean> T getFacetedNavigationResultDocument(HstQuery query, String relPath, Class<T> beanMappingClass)
beanMappingClass
, null
will be returned.T
- query
- the free text search as HstQuery
that is used for this faceted navigationrelPath
- the relative path from site base content to the faceted navigation node, which must not start with a / and is relative to the site content base pathbeanMappingClass
- the class T must be ofnull
if it cannot be found or is not of type T
public static <T extends HippoBean> T getFacetedNavigationResultDocument(HstQuery query, Class<T> beanMappingClass)
beanMappingClass
, null
will be returned.T
- query
- the free text search as HstQuery
that is used for this faceted navigationbeanMappingClass
- the class T must be ofnull
if it cannot be found or is not of type T
public static javax.jcr.Session getDisposableSession(HstRequestContext requestContext, String sessionIdentifier) throws HstComponentException
Session
from a disposable pool which is identified by
disposablePoolIdentifier
or a Session
from a security delegate
If sessionIdentifier
is empty or null
an HstComponentException will be thrown.
If it is not possible to return a Session
for the sessionIdentifier
, for example
because there is configured a MultipleRepositoryImpl instead of LazyMultipleRepositoryImpl, also a HstComponentException
will be thrown.requestContext
- the hstRequest for this HstComponentsessionIdentifier
- the identifier for this disposable pool / session. It is not allowed to be empty or
null
Session
from a disposable poolHstComponentException
public static javax.jcr.Session getPreviewCmsQuerySession(HstRequestContext requestContext, String sessionIdentifier) throws HstComponentException
HstComponentException
Copyright © 2008–2016 Hippo B.V. (http://www.onehippo.com). All rights reserved.