Examples of SlingHttpServletResponse


Examples of org.apache.sling.api.SlingHttpServletResponse

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
            ServletException {
        if (request instanceof SlingHttpServletRequest && response instanceof SlingHttpServletResponse) {
            SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
            SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;

            RequestPathInfo pathInfo = slingRequest.getRequestPathInfo();

            Resource definitionResource = findUrlFilterDefinitionResource(slingRequest.getResource(),
                    slingRequest.getResourceResolver());

            if (definitionResource != null) {
                logger.debug("found url filter definition resource at {}", definitionResource.getPath());
                ValueMap properties = definitionResource.adaptTo(ValueMap.class);
                if (properties != null) {
                    if (checkSelector(pathInfo, properties) && checkSuffix(pathInfo, properties)
                            && checkExtension(pathInfo, properties)) {
                        logger.debug("url filter definition resource at {} passed for request {}.",
                                definitionResource.getPath(), slingRequest.getRequestPathInfo());
                    } else {
                        logger.info("url filter definition resource at {} FAILED for request {}.",
                                definitionResource.getPath(), slingRequest.getRequestPathInfo());
                        slingResponse.sendError(403);
                        return;
                    }
                }
            }
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

    throws IOException, ServletException {
        if ( ! (request instanceof SlingHttpServletRequest)) {
            throw new ServletException("Request is not a Apache Sling HTTP request.");
        }
        final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
        final SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;

        final RewriterResponse rewriterResponse =
                new RewriterResponse(slingRequest, slingResponse, this.pipelineManager);
        boolean errorOccured = true;
        try {
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

        if (helper == null) {
            throw new ScriptException("SlingScriptHelper missing from bindings");
        }

        final SlingHttpServletRequest request = helper.getRequest();
        final SlingHttpServletResponse response = helper.getResponse();
        final ServletContext servletContext = null; // only used by Thymeleaf's ServletContextResourceResolver

        final Locale locale = helper.getResponse().getLocale();
        final String scriptName = helper.getScript().getScriptResource().getPath();
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

        mockStatic(ResourceDataUtil.class);

        String data = "";

        SlingHttpServletRequest request = mock(SlingHttpServletRequest.class);
        SlingHttpServletResponse response = mock(SlingHttpServletResponse.class);

        when(ResourceDataUtil.getIncludeAsString("/content/world", request,
                response)).thenReturn("hello world");

        assertEquals(0, errorPageCache.getTotalCacheRequests());
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

            chain.doFilter(request, response);
            return;
        }

        final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest) request;
        final SlingHttpServletResponse slingResponse = (SlingHttpServletResponse) response;

        final ComponentContext componentContext = WCMUtils.getComponentContext(request);

        if (componentContext == null
                || componentContext.isRoot()) {
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

     */
    public static SlingHttpServletResponse toSlingHttpServletResponse(
            ServletResponse response) {

        // unwrap to SlingHttpServletResponse
        SlingHttpServletResponse cResponse = unwrap(response);

        // check type of response, don't care actually for the response itself
        RequestData.unwrap(cResponse);

        // if the servlet response is actually the SlingHttpServletResponse, we
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

        // setting the Sling request and response
        final RequestData requestData = new RequestData(this, servletRequest,
            servletResponse);
        SlingHttpServletRequest request = requestData.getSlingRequest();
        SlingHttpServletResponse response = requestData.getSlingResponse();

        // request entry log
        if (requestLogger != null) {
            requestLogger.logRequestEntry(request, response);
        }
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

        checkRecursionLevel(request, resolvedURL.getResourcePath());

        // we need a SlingHttpServletRequest/SlingHttpServletResponse tupel to continue
        SlingHttpServletRequest cRequest = RequestData.toSlingHttpServletRequest(request);
        SlingHttpServletResponse cResponse = RequestData.toSlingHttpServletResponse(response);

        // get the request data (and btw check the correct type)
        RequestData requestData = RequestData.getRequestData(cRequest);
        ContentData contentData = requestData.pushContent(resource, resolvedURL);
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

            } else {
                dispatcher = request.getRequestDispatcher(path, opts);
            }

            if (dispatcher != null) {
                SlingHttpServletResponse response = new JspSlingHttpServletResponseWrapper(
                    pageContext);
                dispatcher.include(request, response);
            } else {
                TagUtil.log(log, pageContext, "No content to include...", null);
            }
View Full Code Here

Examples of org.apache.sling.api.SlingHttpServletResponse

    public void service(ServletRequest req, ServletResponse res)
            throws ServletException, IOException {

        try {
            SlingHttpServletRequest request = (SlingHttpServletRequest) req;
            SlingHttpServletResponse response = (SlingHttpServletResponse) res;

            service(request, response);

        } catch (ClassCastException cce) {
            throw new ServletException("Not a Sling HTTP request/response");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.