sergiogonzalez/liferay-portal — pull request #447 by matethurzo (2012-11-14 11:03:57+00:00)
Title: LPS-30648 Language portlet fix

Hey Sergio,

This is the fix what we have talked about earlier.

The real issue happens with a specific setup. Basically this is in correlation with the Asset Publiher/Web Content feature that a web content can be viewed on a different specific page.

So the basic situation is this:
- you have two pages - A and B
- you have an Asset Publisher portlet on both pages.
- the Asset Publisher on page A is configured for this preference: Asset Link Behavior: View in Specific portlet
- the Asset Publisher on page B is configured to be the default asset publisher on that page.
- If a web content is created and we set the page B as a display page for that web content, if you are on page A and click on the view link for that web content it will redirect you to the page B and display the content there.

The URL for this feature is something like this: /web/guest/-/articletitle
During the request the FriendlyURLServlet will map this friendly URL to an actual one, this servlet will call the getActualURL method in the PortalImpl. This method gets the /-/articletitle portion of the URL and it will check for the /-/ url separator. Then this method will call to the getJournalArticleActualURL method to determine the actual URL for this journal content. There is a quite huge logic there, but I think in that case the bottomline is, that this framework is set to process the logic based on a group entity. Basically the logic how the URL is being determined is tied to a group not a layout.

- Now the problem comes with the translations. If on page A we click on the View link we will be redirected properly to the page B.
- If we click on a different language flag in the Language portlet, it will redirect us to a new URL.

And this is when the portal displays that the portlet is undeployed. I've figured out that this is happening because the portal tries to get a portlet with an id "articletitle". Something is messed up with the URLs around here. As I was debugging it turned out that when the language portlet assembles a redirect it will create a layout based URL like this: /web/guest/b/-/articletitle

When processing this URL the FriendlyURLServlet and the underlying framework could not determine an article for this URL since as I wrote previously it's explicitly waiting for a group friendly url, but we are passing /b/-/articletitle instead. This will case the main issue, that the language portlet assembles a layout based friendly url instead of a group one.

I think to change the API is not an option here, this journal article feature to display them on a different page is really a group level feature. As I was looking through the code it seemed that this feature is on group level - even the code requires a groupId passed on not a layout id.

So after all I think the best solution to fix the language portlet to pass the correct URL in these special cases.

Thanks,

Máté

cc-ing @giros