Java Code Examples for org.apache.sling.api.resource.ResourceUtil#isSyntheticResource()

The following examples show how to use org.apache.sling.api.resource.ResourceUtil#isSyntheticResource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SyntheticResourceFilter.java    From sling-org-apache-sling-dynamic-include with Apache License 2.0 6 votes vote down vote up
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
        ServletException {
    final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
    final String resourceType = getResourceTypeFromSuffix(slingRequest);
    final Configuration config = configurationWhiteboard.getConfiguration(slingRequest, resourceType);

    if (config == null || !config.hasIncludeSelector(slingRequest)
            || !ResourceUtil.isSyntheticResource(slingRequest.getResource())
            || (config.hasExtensionSet() && !config.hasExtension(slingRequest))) {
        chain.doFilter(request, response);
        return;
    }

    final RequestDispatcherOptions options = new RequestDispatcherOptions();
    options.setForceResourceType(resourceType);
    String resourcePath = StringUtils.substringBefore(slingRequest.getRequestPathInfo().getResourcePath(), ".");
    Resource resource = slingRequest.getResourceResolver().resolve(resourcePath);
    final RequestDispatcher dispatcher = slingRequest.getRequestDispatcher(resource, options);
    dispatcher.forward(request, response);
}
 
Example 2
Source File: IncludeTagFilter.java    From sling-org-apache-sling-dynamic-include with Apache License 2.0 4 votes vote down vote up
private String buildUrl(Configuration config, SlingHttpServletRequest request) {
    final Resource resource = request.getResource();

    final boolean synthetic = ResourceUtil.isSyntheticResource(request.getResource());
    return UrlBuilder.buildUrl(config.getIncludeSelector(), resource.getResourceType(), synthetic, config, request.getRequestPathInfo());
}