@Test void testGetContentResource_NoContentPath_FallbackToReferer() { when(request.getRequestURI()).thenReturn(GraniteUi.CREATEPAGEWITZARD_PROPERTIES_URI + "/apps/app1/templates/template1"); when(request.getHeader(GraniteUi.HEADER_REFERER)).thenReturn(GraniteUi.CREATEPAGEWITZARD_URI + CONTENT_PATH); when(request.getAttribute(Value.CONTENTPATH_ATTRIBUTE)).thenReturn(null); assertSame(resource, GraniteUi.getContentResource(request)); }
public static @Nullable Resource getContentResource(@NotNull HttpServletRequest request) { String contentPath = getContentPath(request); if (contentPath != null) { SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request; return slingRequest.getResourceResolver().getResource(contentPath); } return null; }
GraniteUi { public static @Nullable Resource getContentResource(@NotNull HttpServletRequest request) { String contentPath = getContentPath(request); if (contentPath != null) { SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request; return slingRequest.getResourceResolver().getResource(contentPath); } return null; } }
GraniteUi { public static @Nullable Resource getContentResource(@NotNull HttpServletRequest request) { String contentPath = getContentPath(request); if (contentPath != null) { SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request; return slingRequest.getResourceResolver().getResource(contentPath); } return null; } private  GraniteUi(); }
GraniteUi { public static @Nullable Resource getContentResource(@NotNull HttpServletRequest request) { String contentPath = getContentPath(request); if (contentPath != null) { SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request; return slingRequest.getResourceResolver().getResource(contentPath); } return null; } private  GraniteUi(); static @Nullable Resource getContentResource(@NotNull HttpServletRequest request); static @Nullable Resource getContentResourceOrParent(@NotNull HttpServletRequest request); static @Nullable Page getContentPage(@NotNull HttpServletRequest request); static @Nullable String getExistingResourceType(@NotNull ResourceResolver resourceResolver, @NotNull String @NotNull... resourceTypes); }
GraniteUi { public static @Nullable Resource getContentResource(@NotNull HttpServletRequest request) { String contentPath = getContentPath(request); if (contentPath != null) { SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request; return slingRequest.getResourceResolver().getResource(contentPath); } return null; } private  GraniteUi(); static @Nullable Resource getContentResource(@NotNull HttpServletRequest request); static @Nullable Resource getContentResourceOrParent(@NotNull HttpServletRequest request); static @Nullable Page getContentPage(@NotNull HttpServletRequest request); static @Nullable String getExistingResourceType(@NotNull ResourceResolver resourceResolver, @NotNull String @NotNull... resourceTypes);  }