Package org.apache.sling.api.resource

Examples of org.apache.sling.api.resource.SyntheticResource


            }
        }
        final int firstDot = fullPath.indexOf(".");
       
        final ResourceMetadata metadata = new ResourceMetadata();
        final Resource r = new SyntheticResource(null, metadata, null);
        metadata.setResolutionPath(firstDot < 0 ? fullPath : fullPath.substring(0, firstDot));
        metadata.setResolutionPathInfo(firstDot < 0 ? null : fullPath.substring(firstDot));
        requestPathInfo = new SlingRequestPathInfo(r);
    }
View Full Code Here


        if (res == null) {
            if (!path.startsWith("/")) {
                path = "/".concat(path);
            }

            res = new SyntheticResource(resolver, path, "$synthetic$");
        }

        return res;
    }
View Full Code Here

     * @param request The request whose resource is to be returned.
     */
    private Resource getErrorResource(final SlingHttpServletRequest request) {
        Resource res = request.getResource();
        if (res == null) {
            res = new SyntheticResource(request.getResourceResolver(), request.getPathInfo(),
                    ServletResolverConstants.ERROR_HANDLER_PATH);
        }
        return res;
    }
View Full Code Here

    @Test
    public void test_isRedirectValid_resource_resolver_root_context() {
        context.checking(new Expectations() {
            {
                allowing(resolver).resolve(with(any(HttpServletRequest.class)), with(equal("/absolute/path")));
                will(returnValue(new SyntheticResource(resolver, "/absolute/path", "test")));

                allowing(resolver).resolve(with(any(HttpServletRequest.class)), with(equal("relative/path")));
                will(returnValue(new NonExistingResource(resolver, "relative/path")));

                allowing(resolver).resolve(with(any(HttpServletRequest.class)), with(any(String.class)));
View Full Code Here

     */
    public Resource getResource(ResourceResolver resourceResolver, String path) {

        // handle resources for the virtual container resources
        if (path.equals(SYSTEM_USER_MANAGER_PATH)) {
            return new SyntheticResource(resourceResolver, path,
                "sling/userManager");
        } else if (path.equals(SYSTEM_USER_MANAGER_USER_PATH)) {
            return new SyntheticResource(resourceResolver, path, "sling/users");
        } else if (path.equals(SYSTEM_USER_MANAGER_GROUP_PATH)) {
            return new SyntheticResource(resourceResolver, path, "sling/groups");
        }

        // the principalId should be the first segment after the prefix
        String pid = null;
        if (path.startsWith(SYSTEM_USER_MANAGER_USER_PREFIX)) {
View Full Code Here

    @Test
    public void test_isRedirectValid_resource_resolver_non_root_context() {
        context.checking(new Expectations() {
            {
                allowing(resolver).resolve(with(any(HttpServletRequest.class)), with(equal("/absolute/path")));
                will(returnValue(new SyntheticResource(resolver, "/absolute/path", "test")));

                allowing(resolver).resolve(with(any(HttpServletRequest.class)), with(equal("relative/path")));
                will(returnValue(new NonExistingResource(resolver, "relative/path")));

                allowing(request).getAttribute(with(AuthenticationSupport.REQUEST_ATTRIBUTE_RESOLVER));
View Full Code Here

    public Resource getResource(ResourceResolver resourceResolver, String path) {
        if (path.contains("/nonexisting/")) {
            return null;
        }
        return new SyntheticResource(resourceResolver, path, "test/resource"){
            @SuppressWarnings("unchecked")
            public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
                AdapterType result = super.adaptTo(type);
               
                if ( result == null && type == InputStream.class )
View Full Code Here

            // detecte resource
            final Resource resource;
            if ( this.resource != null ) {
                resource = this.resource;
            } else if ( this.resourceType != null ) {
                resource = new SyntheticResource(bindings.getRequest().getResourceResolver(),
                        bindings.getResource().getPath(), this.resourceType);
            } else {
                resource = bindings.getResource();
            }
            servlet = servletResolver.resolveServlet(resource, this.script);
View Full Code Here

                    }

                },
                new ResourceResolverContext(false, null, new ResourceAccessSecurityTracker()));
        resolvers.add(resolver);
        final Resource r = new SyntheticResource(resolver, "/a", "a:b") {
            @Override
            public String getResourceSuperType() {
                return "d:e";
            }
        };
View Full Code Here

                                resPath);
                        if (res == null) {
                            if (!delayed.containsKey(resPath)) {
                                delayed.put(
                                        resPath,
                                        new SyntheticResource(
                                                rr,
                                                resPath,
                                                ResourceProvider.RESOURCE_TYPE_SYNTHETIC));
                            }
                        } else {
View Full Code Here

TOP

Related Classes of org.apache.sling.api.resource.SyntheticResource

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.