juliocamarero/liferay-portal — pull request #2582 by KocsisDaniel (2013-11-22 14:24:21+00:00)
Title: LPS-42288

Hey Julio,

here is the fix for the issue I mentioned on my email. So the problem is when the customer adds a portlet to a page and publishes this page, but in the configuration unchecks the portlet setup under the "Applications" section he could expect the portlet won't be added to the page if it wasn't there before and the configuration also won't be imported. However what happens is the configuration gets ignored but the portlet appears on the page with its default setup. It happens because we just simply override the target layout type settings (it contains the portletIds for the layout) with the source layout type settings at the end of the import process. The method contains some logic to detect if a portlet was removed from the source since the last publish, but doesn't have any logic to detect when it shouldn't add a portlet to the target layout.

I defined the following logic:

- remove the portlets from target layout what was removed from the source layout (this logic already exist)
- remove the portlets from the source layout what was not selected to import and haven't been added to the target before. (do not remove if it is already on the layout, but do not add if it is not there)
- after these preparations override the target layout typesettings with the source layout typesettings

I also consolidated the export/import controls logic since we duplicated the code for Layout/Portlet exporters and importers, it has a slight difference how we handled the export/import data but I also fixed that.

thanks,
Daniel