private Resource getFromBaseResource()

in src/main/java/org/apache/sling/resourcemerger/impl/picker/SearchPathBasedResourcePicker.java [100:118]


    private Resource getFromBaseResource(final ResourceResolver resolver, final Resource baseResource,
                                         final String path) {
        final Resource resource;
        final String baseResourcePath = baseResource.getPath();
        // Check if the path is a child of the base resource
        if (path.startsWith(baseResourcePath + '/')) {
            String relPath = path.substring(baseResourcePath.length() + 1);
            resource = baseResource.getChild(relPath);
        }
        // Check if the path is a direct parent of the base resource
        else if (baseResourcePath.startsWith(path) && baseResourcePath.lastIndexOf('/') == path.length()) {
            resource = baseResource.getParent();
        }
        // The two resources are not related enough, retrieval cannot be optimised
        else {
            return null;
        }
        return (resource != null) ? resource : new NonExistingResource(resolver, path);
    }