001
014
015 package com.liferay.portal.upgrade.v5_1_0;
016
017 import com.liferay.portal.kernel.util.GetterUtil;
018 import com.liferay.portal.kernel.util.StringPool;
019 import com.liferay.portal.upgrade.BaseUpgradePortletPreferences;
020 import com.liferay.portlet.PortletPreferencesImpl;
021 import com.liferay.portlet.PortletPreferencesSerializer;
022
023
027 public class UpgradeSitemap extends BaseUpgradePortletPreferences {
028
029 protected String getUpdatePortletPreferencesWhereClause() {
030 return "portletId like '85_%'";
031 }
032
033 protected String upgradePreferences(
034 long companyId, long ownerId, int ownerType, long plid,
035 String portletId, String xml)
036 throws Exception {
037
038 PortletPreferencesImpl preferences =
039 PortletPreferencesSerializer.fromXML(
040 companyId, ownerId, ownerType, plid, portletId, xml);
041
042 long rootPlid = GetterUtil.getLong(
043 preferences.getValue("root-plid", StringPool.BLANK));
044
045 if (rootPlid > 0) {
046 Object[] layout = getLayout(rootPlid);
047
048 if (layout != null) {
049 long layoutId = (Long)layout[3];
050
051 preferences.setValue(
052 "root-layout-id", String.valueOf(layoutId));
053 }
054 }
055
056 preferences.setValue("root-plid", null);
057
058 return PortletPreferencesSerializer.toXML(preferences);
059 }
060
061 }