Package org.apache.sling.api.request

Examples of org.apache.sling.api.request.RequestPathInfo


            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) {
View Full Code Here


            final PostResponse response, final List<Modification> changes)
            throws RepositoryException {

        // SLING-3203: selectors, extension and suffix make no sense here and
        // might lead to deleting other resources than the one the user means.
        final RequestPathInfo rpi = request.getRequestPathInfo();
        if( (rpi.getSelectors() != null && rpi.getSelectors().length > 0)
                || (rpi.getExtension() != null && rpi.getExtension().length() > 0)
                || (rpi.getSuffix() != null && rpi.getSuffix().length() > 0)) {
            response.setStatus(
                    HttpServletResponse.SC_FORBIDDEN,
                    "DeleteOperation request cannot include any selectors, extension or suffix");
            return;
        }
View Full Code Here

        return resource;
    }

    public void initServlet(final Resource resource) {
        // the resource and the request path info, will never be null
        RequestPathInfo requestPathInfo = new SlingRequestPathInfo(resource,
            getServletRequest().getPathInfo());
        ContentData contentData = pushContent(resource, requestPathInfo);

        // finally resolve the servlet for the resource
        ServletResolver sr = slingMainServlet.getServletResolver();
View Full Code Here

     */
    protected static String toRedirectPath(String targetPath,
            SlingHttpServletRequest request) {

        String postFix;
        RequestPathInfo rpi = request.getRequestPathInfo();
        if (rpi.getExtension() != null) {
            StringBuffer postfixBuf = new StringBuffer();
            if (rpi.getSelectorString() != null) {
                postfixBuf.append('.').append(rpi.getSelectorString());
            }
            postfixBuf.append('.').append(rpi.getExtension());
            if (rpi.getSuffix() != null) {
                postfixBuf.append(rpi.getSuffix());
            }
            postFix = postfixBuf.toString();
        } else {
            postFix = null;
        }
View Full Code Here

     * @param defaultValue the default value
     * @return the selector value or the default
     */
    public static String getSelector(final SlingHttpServletRequest request,
                                     final int index, final String defaultValue) {
        RequestPathInfo pathInfo = request.getRequestPathInfo();
        if (pathInfo == null) {
            return null;
        }

        String[] selectors =  pathInfo.getSelectors();
        if (selectors == null) {
            return null;
        }

        if (index >= 0 && index < selectors.length) {
View Full Code Here

     *
     * @param request
     * @return and array of the suffix segments or empty array
     */
    public static String[] getSuffixSegments(final SlingHttpServletRequest request) {
        RequestPathInfo pathInfo = request.getRequestPathInfo();
        if (pathInfo == null || pathInfo.getSuffix() == null) {
            return new String[] {};
        }

        return StringUtils.split(pathInfo.getSuffix(), '/');
    }
View Full Code Here

     *
     * @param request
     * @return Returns null if Request's pathInfo or Suffix is null
     */
    public static String getSuffix(final SlingHttpServletRequest request) {
        RequestPathInfo pathInfo = request.getRequestPathInfo();
        if (pathInfo == null || pathInfo.getSuffix() == null) {
            return null;
        }

        return pathInfo.getSuffix();
    }
View Full Code Here

            // required for a null resource
        }
    }

    public void testTrailingDot() {
        RequestPathInfo p = new SlingRequestPathInfo(
            new MockResource("/some/path"), "/some/path.");
        assertEquals("/some/path", p.getResourcePath());
        assertNull(p.getSelectorString());
        assertEquals(0, p.getSelectors().length);
        assertNull(p.getExtension());
        assertNull(p.getSuffix());
    }
View Full Code Here

        assertNull(p.getExtension());
        assertNull(p.getSuffix());
    }

    public void testTrailingDotWithSuffix() {
        RequestPathInfo p = new SlingRequestPathInfo(
            new MockResource("/some/path"), "/some/path./suffix");
        assertEquals("/some/path", p.getResourcePath());
        assertNull(p.getSelectorString());
        assertEquals(0, p.getSelectors().length);
        assertNull(p.getExtension());
        assertEquals("/suffix", p.getSuffix());
    }
View Full Code Here

        assertNull(p.getExtension());
        assertEquals("/suffix", p.getSuffix());
    }

    public void testTrailingDotDot() {
        RequestPathInfo p = new SlingRequestPathInfo(
            new MockResource("/some/path"), "/some/path..");
        assertEquals("/some/path", p.getResourcePath());
        assertNull(p.getSelectorString());
        assertEquals(0, p.getSelectors().length);
        assertNull(p.getExtension());
        assertNull(p.getSuffix());
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.api.request.RequestPathInfo

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.