juliocamarero/liferay-portal — pull request #932 by KocsisDaniel (2012-12-13 19:26:05+00:00)
Title: LPS-31002

Hey Julio,

this is a fix for a regression caused by LPS-30420. The original problem is when we call the getPortletSetup method it creates preferences even if the portlet doesn't have one in the current context. As a result all the non-instancable protlets like doclib, calendar, bookmarks... can't be added anymore to the layout because a valid preference exists where the owner is the page. So we need to get strict preferences as Ray fixed it, but unfortunately it still has 2 problems:
- to check only layout type preference is too strict, because the portlet could have group level shared preference, or company level one. --> changed the original method to be able to return strict preference, but keep all the logic to find the right preference
- if the method can't find a valid preference it returns not "null", but an empty object and the store() method of it throws UnsupportedOperationException if and only if the portletId attribute is null, which is the case with all these empty preferences. --> don't want to change the return value, since we use the method in other places, where we might rely on that. changed only the exception handling we have, but it is not a logic change, only the way how we log the exception.

The reason why we even have the portlets checked with the page is we have the always exportable portlets which we always add to the portlet set we try to export with all the layouts in the exported site.

thanks,
Daniel