Package io.wcm.wcm.ui.granite.util
Class GraniteUi
java.lang.Object
io.wcm.wcm.ui.granite.util.GraniteUi
Helper methods for GraniteUI components.
It uses some heuristics to get the current content path in context of a GraniteUI component:
- Inside create page wizard, try to get content path from referrer header
- Try to get content path from request suffix
- Try to get content path from "item" request parameter (inside multifield component)
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable com.day.cq.wcm.api.PagegetContentPage(@NotNull javax.servlet.http.HttpServletRequest request) Current content page.static @Nullable org.apache.sling.api.resource.ResourcegetContentResource(@NotNull javax.servlet.http.HttpServletRequest request) Current content resourcestatic @Nullable org.apache.sling.api.resource.ResourcegetContentResourceOrParent(@NotNull javax.servlet.http.HttpServletRequest request) Get current content resource If it does not exist, go up the content path and return the first resource that exists.static @Nullable StringgetExistingResourceType(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull String @NotNull ... resourceTypes) From the list of resource types get the first one that exists.
-
Method Details
-
getContentResource
@Nullable public static @Nullable org.apache.sling.api.resource.Resource getContentResource(@NotNull @NotNull javax.servlet.http.HttpServletRequest request) Current content resource- Parameters:
request- Request- Returns:
- Current content resource or null
-
getContentResourceOrParent
@Nullable public static @Nullable org.apache.sling.api.resource.Resource getContentResourceOrParent(@NotNull @NotNull javax.servlet.http.HttpServletRequest request) Get current content resource If it does not exist, go up the content path and return the first resource that exists.- Parameters:
request- Request- Returns:
- Current content resource or the first existing parent/ancestor.
-
getContentPage
@Nullable public static @Nullable com.day.cq.wcm.api.Page getContentPage(@NotNull @NotNull javax.servlet.http.HttpServletRequest request) Current content page. If the current resource does not exist the content page of the next-existing parent resource is returned.- Parameters:
request- Request- Returns:
- Current content page or null
-
getExistingResourceType
@Nullable public static @Nullable String getExistingResourceType(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull @NotNull String @NotNull ... resourceTypes) From the list of resource types get the first one that exists.- Parameters:
resourceResolver- Resource resolverresourceTypes- ResourceTypes- Returns:
- Existing resource type
-