public Resource decorate()

in src/main/java/org/apache/sling/servlets/resolver/internal/ScriptResourceDecorator.java [45:67]


    public Resource decorate(final Resource resource) {
        String path = ResourceUtil.normalize(resource.getPath());
        if (this.provider.isRootOf(path)) {
            String resolutionPath = resource.getResourceMetadata().getResolutionPath();
            Resource script = getResource(resource, path);
            if (script == resource && Resource.RESOURCE_TYPE_NON_EXISTING.equals(resource.getResourceType())) {
                int idx = path.indexOf('.');
                if (idx != -1) {
                    path = path.substring(0, idx);
                    script = getResource(resource, path);
                    resolutionPath = path;
                }
            }
            if (script != resource) {
                script.getResourceMetadata().putAll(resource.getResourceMetadata());
                script.getResourceMetadata().setResolutionPath(resolutionPath);
            }

            return script;
        } else {
            return resource;
        }
    }