@Override public final void forwardAsGet(final Form form, final String path, final SlingHttpServletRequest request, final SlingHttpServletResponse response, final RequestDispatcherOptions options) throws ServletException, IOException { this.setRequestAttrForm(request, form); final SlingHttpServletRequest syntheticRequest = new SyntheticSlingHttpServletGetRequest(request); if (log.isDebugEnabled()) { log.debug("Forwarding as GET to path: {} ", path); log.debug("Forwarding as GET w/ replace selectors: {} ", options.getReplaceSelectors()); log.debug("Forwarding as GET w/ add selectors: {} ", options.getAddSelectors()); log.debug("Forwarding as GET w/ suffix: {} ", options.getReplaceSuffix()); log.debug("Forwarding as GET w/ forced resourceType: {} ", options.getForceResourceType()); } request.getRequestDispatcher(path, options).forward(syntheticRequest, response); }
@Override public final void forwardAsGet(final Form form, final String path, final SlingHttpServletRequest request, final SlingHttpServletResponse response, final RequestDispatcherOptions options) throws ServletException, IOException { this.setRequestAttrForm(request, form); final SlingHttpServletRequest syntheticRequest = new SyntheticSlingHttpServletGetRequest(request); if (log.isDebugEnabled()) { log.debug("Forwarding as GET to path: {} ", path); log.debug("Forwarding as GET w/ replace selectors: {} ", options.getReplaceSelectors()); log.debug("Forwarding as GET w/ add selectors: {} ", options.getAddSelectors()); log.debug("Forwarding as GET w/ suffix: {} ", options.getReplaceSuffix()); log.debug("Forwarding as GET w/ forced resourceType: {} ", options.getForceResourceType()); } request.getRequestDispatcher(path, options).forward(syntheticRequest, response); }
private void includeResource(SlingHttpServletRequest request, final Bindings bindings, PrintWriter out, Resource includeRes, RequestDispatcherOptions requestDispatcherOptions) { if (includeRes == null) { throw new SightlyException("Resource cannot be null"); } else { if (request.getResource().getPath().equals(includeRes.getPath())) { String requestSelectorString = request.getRequestPathInfo().getSelectorString(); String requestDispatcherAddSelectors = requestDispatcherOptions.getAddSelectors(); if ( (requestSelectorString == null ? requestDispatcherAddSelectors == null : requestSelectorString.equals(requestDispatcherAddSelectors)) && StringUtils.EMPTY.equals(requestDispatcherOptions.getReplaceSelectors()) && (requestDispatcherOptions.getForceResourceType() == null || requestDispatcherOptions.getForceResourceType().equals(request.getResource().getResourceType())) ) { LOGGER.warn("Will not include resource {} since this will lead to a {} exception.", includeRes.getPath(), "org.apache.sling.api.request.RecursionTooDeepException"); return; } } SlingHttpServletResponse customResponse = new PrintWriterResponseWrapper(out, BindingsUtils.getResponse(bindings)); RequestDispatcher dispatcher = request.getRequestDispatcher(includeRes, requestDispatcherOptions); try { if (dispatcher != null) { dispatcher.include(request, customResponse); } else { throw new SightlyException("Failed to include resource " + includeRes.getPath()); } } catch (Exception e) { throw new SightlyException("Failed to include resource " + includeRes.getPath(), e); } } }
private void includeResource(SlingHttpServletRequest request, final Bindings bindings, PrintWriter out, String path, RequestDispatcherOptions requestDispatcherOptions) { if (StringUtils.isEmpty(path)) { throw new SightlyException("Resource path cannot be empty"); } else { Resource includeRes = request.getResourceResolver().resolve(path); if (ResourceUtil.isNonExistingResource(includeRes)) { String resourceType = request.getResource().getResourceType(); if (requestDispatcherOptions.containsKey(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE)) { resourceType = requestDispatcherOptions.getForceResourceType(); } includeRes = new SyntheticResource(request.getResourceResolver(), path, resourceType); } includeResource(request, bindings, out, includeRes, requestDispatcherOptions); } }