Package com.day.cq.wcm.commons
Class WCMUtils
java.lang.Object
com.day.cq.wcm.commons.WCMUtils
The
CMUtils class provides utility methods for various
aspects of the Core WCM system.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic ComponentgetComponent(Resource resource) Returns the component according to the type of the resource ornullif no such component exists.static ComponentContextgetComponentContext(ServletRequest request) Returns the component context for the given request ornullif not defined.static StringgetInheritedProperty(Page page, ResourceResolver resolver, String name) Returns the content property of the given page.static StringgetKeywords(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 StringgetKeywords(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 NodeReturns a node for the given resource.static StylegetStyle(SlingHttpServletRequest request) Returns the style for the given request.
-
Field Details
-
DEBUG_PARAM
debug parameter name- See Also:
-
-
Method Details
-
getComponent
Returns the component according to the type of the resource ornullif no such component exists. This is a pure convenience method retrieving the component manager and invokingComponentManager.getComponentOfResource(Resource).- Parameters:
resource- to resolve- Returns:
- the respective component or
null
-
getInheritedProperty
Returns the content property of the given page. If the page does not contain this property, the page's parent's property is returned ornullif the page has no parent.Note that the standard "pageProperties" variable defined by the
<cq:defineObjects/>tag is now (since CQ 5.4) anInheritanceValueMapthat providesgetInherited(String, Class)andgetInherited(String, Object)to search for those properties in parent pages if not found locally.- Parameters:
page- the page to retrieve the property fromresolver- for resolving parent pagesname- the property name- Returns:
- the property value or
null
-
getStyle
Returns the style for the given request. It's a convenience method that retrieves the respective page of the request resource, resolves its design, extracts the cell path and retrieves the style. A design and cell path can be specified '/-/' delimited as suffix. the design path only needs to include the part after the /etc/designs. eg: ...img.png/geometrixx/-/par/image- Parameters:
request- the request- Returns:
- the style or
null
-
getComponentContext
Returns the component context for the given request ornullif not defined.- Parameters:
request- servlet request- Returns:
- component context or
null
-
getNode
Returns a node for the given resource. If the node does not exist, returns null- Parameters:
resource- resource to adapt to node- Returns:
- the node or
null
-
getKeywords
Returns a comma-separated list of keywords for the given page, based on the titles of the tags set on the page. Useful for the <meta keywords> element in HTML.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).- Parameters:
page- wcm page- Returns:
- comma-separated list of keywords
-
getKeywords
Returns a comma-separated list of keywords for the given page, based on the titles of the tags set on the page. Useful for the <meta keywords> element in HTML.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.
- Parameters:
page- wcm pageonlyLocalized- if only keywords should be returned that have a localized variant for the given page locale- Returns:
- comma-separated list of keywords
- Since:
- 5.4
-