Package com.cognifide.cq.includefilter

Examples of com.cognifide.cq.includefilter.MutableUrl


  }

  @Override
  public void process(SlingHttpServletRequest request, SlingHttpServletResponse response, FilterChain chain)
      throws ServletException, IOException {
    MutableUrl url = new MutableUrl(request, false);
    String resourceType = getResourceTypeFromSuffix(request);
    boolean synthetic = ResourceUtil.isSyntheticResource(request.getResource());

    if (synthetic && config.isSupportedResourceType(resourceType, request)) {
      RequestDispatcherOptions options = new RequestDispatcherOptions();
      options.setForceResourceType(resourceType);

      Resource res = request.getResource();
      String existingResource = getParentExistingResource(res.getPath(), res.getResourceResolver());

      String path = url.getPath();
      // add component name to the most related parent existing resource
      if (!existingResource.isEmpty()) {
        path = existingResource + path.substring(path.lastIndexOf('/'));
      }
View Full Code Here


  }

  @Override
  public void process(SlingHttpServletRequest request, SlingHttpServletResponse response, FilterChain chain)
      throws ServletException, IOException {
    MutableUrl url = new MutableUrl(request, false);
    Resource resource = request.getResource();
    String resourceType = resource.getResourceType();

    if (config.isSupportedResourceType(resourceType, request)) {
      url.removeSelector(config.getIncludeSelector());

      RequestDispatcherOptions options = new RequestDispatcherOptions();
      RequestDispatcher dispatcher = request.getRequestDispatcher(url.toString(), options);
      request.setAttribute(INCLUDED_ATTRIBUTE, Boolean.TRUE);
      dispatcher.include(request, response);
    } else {
      LOG.error("User tries to include " + resourceType
          + " but it is not in the dynamic resource type list.");
View Full Code Here

  }

  private String getUrl(SlingHttpServletRequest request, boolean synthetic) {
    boolean isSynthetic = synthetic;
    Resource resource = request.getResource();
    MutableUrl url = new MutableUrl(request, true);

    url.setDefaultExtension("html");
    url.addSelector(config.getIncludeSelector());
    if (isSynthetic) {
      url.replaceSuffix(resource.getResourceType());
    }
    return url.toString();
  }
View Full Code Here

TOP

Related Classes of com.cognifide.cq.includefilter.MutableUrl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.