001
014
015 package com.liferay.portal.upgrade.v6_0_3;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.upgrade.BaseUpgradePortletPreferences;
019 import com.liferay.portlet.PortletPreferencesImpl;
020 import com.liferay.portlet.PortletPreferencesSerializer;
021
022
025 public class UpgradeLookAndFeel extends BaseUpgradePortletPreferences {
026
027 protected String getUpdatePortletPreferencesWhereClause() {
028 return "preferences like '%portlet-setup-link-to-%'";
029 }
030
031 protected String upgradePreferences(
032 long companyId, long ownerId, int ownerType, long plid,
033 String portletId, String xml)
034 throws Exception {
035
036 PortletPreferencesImpl preferences =
037 PortletPreferencesSerializer.fromXML(
038 companyId, ownerId, ownerType, plid, portletId, xml);
039
040 long linkToLayoutId = GetterUtil.getLong(
041 preferences.getValue("portlet-setup-link-to-layout-id", null));
042
043 if (linkToLayoutId <= 0) {
044 linkToLayoutId = GetterUtil.getLong(
045 preferences.getValue("portlet-setup-link-to-plid", null));
046 }
047
048 if (linkToLayoutId > 0) {
049 String uuid = getLayoutUuid(plid, linkToLayoutId);
050
051 if (uuid != null) {
052 preferences.setValue("portlet-setup-link-to-layout-uuid", uuid);
053 }
054
055 preferences.reset("portlet-setup-link-to-layout-id");
056 preferences.reset("portlet-setup-link-to-plid");
057 }
058
059 return PortletPreferencesSerializer.toXML(preferences);
060 }
061
062 }