Package io.wcm.wcm.ui.granite.util
Class GraniteUi
- java.lang.Object
-
- io.wcm.wcm.ui.granite.util.GraniteUi
-
@ProviderType public final class GraniteUi extends java.lang.Object
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
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @Nullable com.day.cq.wcm.api.Page
getContentPage(@NotNull javax.servlet.http.HttpServletRequest request)
Current content page.static @Nullable org.apache.sling.api.resource.Resource
getContentResource(@NotNull javax.servlet.http.HttpServletRequest request)
Current content resourcestatic @Nullable org.apache.sling.api.resource.Resource
getContentResourceOrParent(@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 java.lang.String
getExistingResourceType(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull java.lang.String @NotNull ... resourceTypes)
From the list of resource types get the first one that exists.
-
-
-
Method Detail
-
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 java.lang.String getExistingResourceType(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull @NotNull java.lang.String @NotNull ... resourceTypes)
From the list of resource types get the first one that exists.- Parameters:
resourceResolver
- Resource resolverresourceTypes
- ResourceTypes- Returns:
- Existing resource type
-
-