private void resolveAliases()

in src/main/java/org/apache/sling/resourceresolver/impl/mapping/ResourceMapperImpl.java [236:272]


    private void resolveAliases(Resource res, PathGenerator pathBuilder) {
        Resource current = res;
        String path = res.getPath();
        if (this.mapEntries.isOptimizeAliasResolutionEnabled()) {
            // this code path avoids any creation of Sling Resource objects
            while (path != null) {
                Collection<String> aliases = Collections.emptyList();
                // read alias only if we can read the resources and it's not a jcr:content leaf
                if (!path.endsWith(ResourceResolverImpl.JCR_CONTENT_LEAF)) {
                    aliases = readAliasesOptimized(path);
                }
                // build the path from the name segments or aliases
                pathBuilder.insertSegment(aliases, ResourceUtil.getName(path));
                path = ResourceUtil.getParent(path);
                if ("/".equals(path)) {
                    path = null;
                }
            }
        } else {
            // while here there Resources are resolved
            while (path != null) {
                List<String> aliases = Collections.emptyList();
                // read alias only if we can read the resources and it's not a jcr:content leaf
                if (current != null && !path.endsWith(ResourceResolverImpl.JCR_CONTENT_LEAF)) {
                    aliases = readAliases(path, current);
                }
                // build the path from the name segments or aliases
                pathBuilder.insertSegment(aliases, ResourceUtil.getName(path));
                path = ResourceUtil.getParent(path);
                if ("/".equals(path)) {
                    path = null;
                } else if (path != null) {
                    current = resolver.resolve(path);
                }
            }
        }
    }