[
https://issues.apache.org/jira/browse/SLING-6587?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15892369#comment-15892369
]
Georg Henzler edited comment on SLING-6587 at 3/2/17 3:42 PM:
--------------------------------------------------------------
Added in [r1785149|http://svn.apache.org/viewvc?view=revision&revision=1785149]
- [~cziegeler] as you created the interface initially please double check if it
actually makes sense.
was (Author: henzlerg):
Added in [r1785149|http://svn.apache.org/viewvc?view=revision&revision=1785149]
> Resource Merger does not work correctly with content
> ----------------------------------------------------
>
> Key: SLING-6587
> URL: https://issues.apache.org/jira/browse/SLING-6587
> Project: Sling
> Issue Type: Bug
> Components: Extensions
> Affects Versions: Resource Merger 1.3.0
> Reporter: Georg Henzler
>
> I tried to create the following resource picker in the hope I could merge
> content resources and render them as html:
> {code}
> @Component(label = "Content Resource Picker", description = "", metatype =
> true)
> @Service(value = { MergedResourcePicker2.class })
> @Properties({
> @Property(name = MergedResourcePicker2.MERGE_ROOT, value =
> WwwMergingResourcePicker.DEFAULT_ROOT, label = "Root", description = "The
> mount point of merged resources"),
> @Property(name = MergedResourcePicker2.READ_ONLY, boolValue = false,
> label = "Read Only", description = "Specifies if the resources are read-only
> or can be modified.")
> })
> public class WwwMergingResourcePicker implements MergedResourcePicker2 {
> private static final Logger LOG =
> LoggerFactory.getLogger(WwwMergingResourcePicker.class);
> public static final String DEFAULT_ROOT = "/mnt/contentwww";
> @Override
> public List<Resource> pickResources(final ResourceResolver resolver,
> final String relativePath,
> final Resource relatedResource) {
> String resourcePath = StringUtils.substringBefore(relativePath, ".");
> // for some reason path/to/page.html including ".html" is passed in here
> List<Resource> resources = new ArrayList<Resource>();
> String overrideContentBasePath = "/content/www/override";
> String masterBasePath = "/content/www/master";
> String overrideContentPath = overrideContentBasePath + "/" +
> resourcePath;
> Resource overrideContentResource =
> resolver.getResource(overrideContentPath);
> resources.add(overrideContentResource);
> String masterPath = masterBasePath + "/" + resourcePath;
> Resource masterResource = resolver.getResource(masterPath);
> resources.add(masterResource);
> return resources;
> }
> }
> {code}
> The request to `/mnt/contentwww/path/to/my/page.html` answers with a redirect
> to /mnt/contentwww/path/to/my/page.html/, trailing slash instead of returning
> an html rendering, the root cause seems to be that for some reason the
> request path is completely taken as resource path instead of splitting it in
> the sling way (extension should be html, .html should be cut off the resource
> path:
> {code}
> 0 TIMER_END{0,ResourceResolution} URI=/mnt/contentwww/path/to/my/page.html
> resolves to Resource=MergedResource
> [path=/mnt/contentwww/path/to/my/page.html,
> resources=[Ljava.lang.String;@31d6983a]
> 0 LOG Resource Path Info: SlingRequestPathInfo:
> path='/mnt/contentwww/path/to/my/page.html', selectorString='null',
> extension='null', suffix='null'
> ...
> 4 TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0}
> 4 LOG Using
> org.apache.sling.servlets.get.impl.helpers.StreamRendererServlet to render
> for extension=null
> {code}
> Looking at the code of the resource merger module, it is just registering a
> resource provider and hence, conceptually it should work (the resource
> provider should never get to see a path with extension ".html" IMHO, to me it
> looks like the problem might be in some other module).
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)