public class WCMUtils
extends java.lang.Object
CMUtils
class provides utility methods for various
aspects of the Core WCM system.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEBUG_PARAM
debug parameter name
|
Modifier and Type | Method and Description |
---|---|
static Component |
getComponent(Resource resource)
Returns the component according to the type of the resource or
null if no such component exists. |
static ComponentContext |
getComponentContext(ServletRequest request)
Returns the component context for the given request or
null
if not defined. |
static java.lang.String |
getInheritedProperty(Page page,
ResourceResolver resolver,
java.lang.String name)
Returns the content property of the given page.
|
static java.lang.String |
getKeywords(Page page)
Returns a comma-separated list of keywords for the given page, based on
the titles of the tags set on the page.
|
static java.lang.String |
getKeywords(Page page,
boolean onlyLocalized)
Returns a comma-separated list of keywords for the given page, based on
the titles of the tags set on the page.
|
static Node |
getNode(Resource resource)
Returns a node for the given resource.
|
static Style |
getStyle(SlingHttpServletRequest request)
Returns the style for the given request.
|
public static final java.lang.String DEBUG_PARAM
public static Component getComponent(Resource resource)
null
if no such component exists. This is a pure convenience
method retrieving the component manager and invoking
ComponentManager.getComponentOfResource(Resource)
.resource
- to resolvenull
public static java.lang.String getInheritedProperty(Page page, ResourceResolver resolver, java.lang.String name)
null
if the page has no parent.
Note that the standard "pageProperties" variable defined by the
<cq:defineObjects/>
tag is now (since CQ 5.4) an
InheritanceValueMap
that provides
getInherited(String, Class)
and
getInherited(String, Object)
to search for those properties in parent
pages if not found locally.
page
- the page to retrieve the property fromresolver
- for resolving parent pagesname
- the property namenull
public static Style getStyle(SlingHttpServletRequest request)
request
- the requestnull
public static ComponentContext getComponentContext(ServletRequest request)
null
if not defined.request
- servlet requestnull
public static Node getNode(Resource resource)
resource
- resource to adapt to nodenull
public static java.lang.String getKeywords(Page page)
Since CQ 5.4, this returns localized tag titles based on the page
language or the default title if no localized title exists for that
language. This is essentially the same as
getKeywords(page, false)
.
page
- wcm pagepublic static java.lang.String getKeywords(Page page, boolean onlyLocalized)
Returns localized tag titles based on the page language. A boolean flag allows to choose if only localized titles shall be returned or if it is ok to fallback to the default title in case no localized title exists for a given tag.
page
- wcm pageonlyLocalized
- if only keywords should be returned that have a localized
variant for the given page locale"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"