[MGNLETK-29] LinkUtil fails to generate links in the multi site environment Created: 25/May/10  Updated: 03/Jul/14  Resolved: 07/Jun/10

Status: Closed
Project: Extended Templating Kit (closed)
Component/s: None
Affects Version/s: 1.3.1
Fix Version/s: 1.3.1

Type: Bug Priority: Major
Reporter: Ernst Bunders Assignee: Jan Haderka
Resolution: Fixed Votes: 0
Labels: multisite, vpro
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Zip Archive RssGenerator.zip     XML File config.modules.rssaggregator.config.feedGenerators.tegenlicht-nieuws.xml     Text File stacktrace.txt    
Issue Links:
causality
caused by MAGNOLIA-3213 MagnoliaTemplatingUtilities do not su... Closed
Template:
Acceptance criteria:
Empty
Date of First Response:

 Description   

Inside my AbstractSyndFeedGenerator implementation I run a query on some content nodes, and then for each node create a SyndEntry where I use info.magnolia.link.LinkUtil.createAbsoluteLink(content) to create the rss item link. This causes a stack trace, which I include.

I traced the problem to info.magnolia.module.extendedtemplatingkit.CrossSiteAbsolutePathTransformer.prefixLink(String linkStr).
This method is quite complicated, but I can guess what goes wrong:
Because the request is on http://tegenlicht.localhost:8080/rss/?generatorName=tegelicht-nieuws it is not a request on the website workspace and the site is not resolved in the course of the request handling, so the configuration is not part of the request context.

I had some communication about this with Jan, who suggested I should use LinkUtil.createExternalLink(). But this method does not know how to resolve the hostname (based on multi site configuration), and it also does not know how the links to pages in the site should be created.

I hope this information is sufficient. If not, i will supply what is required.



 Comments   
Comment by Ernst Bunders [ 26/May/10 ]

Some files that demonstrate what code causes our problem with the rss.

Comment by Ernst Bunders [ 26/May/10 ]

for completeness: the configuration xml

Comment by Jan Haderka [ 26/May/10 ]

This issue is fixed by changes made for MAGNOLIA-3213 and MGNLETK-28
I will try to deploy a snapshot in the morning with the fixes for testing.

Comment by Jan Haderka [ 27/May/10 ]

All the issues are still undergoing testing, but if you want to test as well (and I would really appreciate that):
magnolia-core
magnolia-module-templating
STK
ETK

Thanks Jan

Comment by Ernst Bunders [ 28/May/10 ]

Yes, the rss seems to be working again, calling:
> http://localhost:8080/rss/?generatorName=tegenlicht-nieuws

and using:
String link = LinkUtil.createAbsoluteLink(content);
StringBuilder sb = new StringBuilder("http://");
HttpServletRequest req = MgnlContext.getWebContext().getRequest();
sb.append(req.getServerName());
if(req.getServerPort() != 80)

{ sb.append(String.format(":%s", "" + req.getServerPort())); }

sb.append(link);
return sb.toString();

this creates a link like:
>http://localhost:8080/pip/nieuws/2010/februari/metropolis-correspondenten-gingen-op-zoek-naar-de-woede.html

When I use LinkUtil.createExternalLink(content), I see that the link is created with the hostname linked to the site, like:
>http://tegenlicht.localhost/nieuws/2010/februari/metropolis-correspondenten-gingen-op-zoek-naar-de-woede.html
I just wonder what happens when you add more than one hostname to a site.... So I guess your idea of creating a version of this method that accepts a host name as well is perhaps not so bad.

One remark: port numbers are ignored, so if you run the app on a non-standard (80) port, the links won't work. Not a big deal, but worth mentioning.

I also tried both variations from:
>http://tegenlicht.localhost:8080/rss/?generatorName=tegenlicht-nieuws
and it all works.

But.....
Link creation int the site is broken again.... If i try to open my site from the admin central that is not bound to a host name:
>http://localhost:8080/tegenlicht.html
The link to a section (news) looks like:
>http://localhost:8080/nieuws.html
That had been fixed, and should be
>http://localhost:8080/pip/nieuws.html
where pip is the site definition name.....

When i open the site like
>http://tegenlicht.localhost:8080/
it works ok.

Comment by Jan Haderka [ 28/May/10 ]

Actually you should use the LinkUtil.createExternalLink(Content) since it is now site aware and will generate the complete URL for you. As for the port, in the domain configuration in your site you can now (apart from the name of the domain) specify port, protocol and context.

If you have more then one domain, the one matching the current domain will be used. If none matches the current, the first one will be used.

Comment by Ernst Bunders [ 01/Jun/10 ]

I just checked the links again, and can report that both in the rss feeds and in the site (when opened from admin central) work ok.
Snapshots i'm on right now:

magnolia-core-4.3.2-20100528.163321-7.jar
magnolia-module-standard-templating-kit-1.3.1-20100528.163613-8.jar
magnolia-module-extended-templating-kit-1.3.1-20100528.164214-13.jar

Let's hope we can switch back to stable versions again soon...

Generated at Mon Feb 12 01:47:48 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.