Package org.apache.sling.api.resource

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


     * If the user can't be authenticated <code>null</code> is returned.
     * @param ctx The user context.
     * @return A resource provider or <code>null</code>
     */
    public ResourceProvider getResourceProvider(final ResourceResolverContext ctx) {
        ResourceProvider rp = ctx.getFactoryResourceProvider(this.getServiceId());
        if ( rp == null ) {
            try {
                rp = this.login(ctx);
            } catch (final LoginException le ) {
                // for now we log to debug, as a failed login for not required resource provider
View Full Code Here


    /**
     * @see ResourceProvider#getResource(ResourceResolver, String)
     */
    public Resource getResource(final ResourceResolverContext ctx, final ResourceResolver resourceResolver, final String path) {
        final ResourceProvider rp = this.getResourceProvider(ctx);
        if ( rp != null ) {
            return getReadableResource(ctx, rp.getResource(resourceResolver, path) );
        }
        return null;
    }
View Full Code Here

    /**
     * @see ResourceProvider#listChildren(Resource)
     */
    public Iterator<Resource> listChildren(final ResourceResolverContext ctx, final Resource parent) {
        final ResourceProvider rp = this.getResourceProvider(ctx);
        if ( rp != null ) {
            return getReadableChildrenIterator( ctx, rp.listChildren(parent) );
        }
        return null;
    }
View Full Code Here

    /**
     * Login to a resource resolver factory.
     */
    public ResourceProvider login(final ResourceResolverContext ctx) throws LoginException {
        final ResourceProvider rp;
        if (ctx.isAdmin()) {
            rp = this.resourceProviderFactory.getAdministrativeResourceProvider(ctx.getAuthenticationInfo());
        } else {
            rp = this.resourceProviderFactory.getResourceProvider(ctx.getAuthenticationInfo());
        }
View Full Code Here

            "/apps/sling/microsling/html.js"));
    }

    public void testAdd1Provider() {
        String firstPath = "/rootel";
        ResourceProvider first = new TestResourceProvider(firstPath);
        root.addResourceProvider(firstPath, first);

        assertEquals(root, root.getResource(null, "/"));
        assertEquals(first, root.getResource(null, "/rootel"));
        assertEquals(first, root.getResource(null, "/rootel/html.js"));
View Full Code Here

    public void testAdd3Providers() {
        String firstPath = "/rootel";
        String thirdPath = "/apps/sling/sample";
        String secondPath = firstPath + "/child";

        ResourceProvider first = new TestResourceProvider(firstPath);
        ResourceProvider second = new TestResourceProvider(secondPath);
        ResourceProvider third = new TestResourceProvider(thirdPath);

        root.addResourceProvider(firstPath, first);
        root.addResourceProvider(secondPath, second);
        root.addResourceProvider(thirdPath, third);
View Full Code Here

    public void testAdd3ProvidersReverse() {
        String firstPath = "/rootel";
        String thirdPath = "/apps/sling/sample";
        String secondPath = firstPath + "/child";

        ResourceProvider first = new TestResourceProvider(firstPath);
        ResourceProvider second = new TestResourceProvider(secondPath);
        ResourceProvider third = new TestResourceProvider(thirdPath);

        root.addResourceProvider(thirdPath, third);
        root.addResourceProvider(secondPath, second);
        root.addResourceProvider(firstPath, first);
View Full Code Here

    public void testRemoveProviders() {
        String firstPath = "/rootel";
        String thirdPath = "/apps/sling/sample";
        String secondPath = firstPath + "/child";

        ResourceProvider first = new TestResourceProvider(firstPath);
        ResourceProvider second = new TestResourceProvider(secondPath);
        ResourceProvider third = new TestResourceProvider(thirdPath);

        root.addResourceProvider(firstPath, first);
        root.addResourceProvider(secondPath, second);
        root.addResourceProvider(thirdPath, third);
View Full Code Here

            private Resource seek() {
                for (;;) {
                    while ((resources == null || !resources.hasNext())
                        && providers.hasNext()) {
                        ResourceProvider provider = providers.next();
                        resources = provider.listChildren(resource);
                    }

                    if (resources != null && resources.hasNext()) {
                        Resource res = resources.next();
                        if (res instanceof SyntheticResource) {
View Full Code Here

        } else {
            String[] roots = OsgiUtil.toStringArray(reference.getProperty(ResourceProvider.ROOTS));
            if (roots != null && roots.length > 0) {

                ResourceProvider provider = (ResourceProvider) componentContext.locateService(
                    "ResourceProvider", reference);

                for (String root : roots) {
                    try {
                        rootProviderEntry.addResourceProvider(root, provider);
View Full Code Here

TOP

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

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.