001
014
015 package com.liferay.portal.upgrade.v6_2_0;
016
017 import com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil;
018 import com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.LoggingTimer;
021 import com.liferay.portal.kernel.util.RSSUtil;
022 import com.liferay.portal.kernel.util.Validator;
023 import com.liferay.portal.upgrade.v6_2_0.util.BlogsEntryTable;
024
025 import javax.portlet.PortletPreferences;
026
027
031 public class UpgradeBlogs extends BaseUpgradePortletPreferences {
032
033 @Override
034 protected void doUpgrade() throws Exception {
035 super.doUpgrade();
036
037 updateEntries();
038 }
039
040 @Override
041 protected String[] getPortletIds() {
042 return new String[] {"33"};
043 }
044
045 protected void updateEntries() throws Exception {
046 try (LoggingTimer loggingTimer = new LoggingTimer()) {
047 alter(
048 BlogsEntryTable.class,
049 new AlterColumnType("description", "STRING null"));
050 }
051 }
052
053 protected void upgradeDisplayStyle(PortletPreferences portletPreferences)
054 throws Exception {
055
056 String pageDisplayStyle = GetterUtil.getString(
057 portletPreferences.getValue("pageDisplayStyle", null));
058
059 if (Validator.isNotNull(pageDisplayStyle)) {
060 portletPreferences.setValue("displayStyle", pageDisplayStyle);
061 }
062
063 portletPreferences.reset("pageDisplayStyle");
064 }
065
066 @Override
067 protected String upgradePreferences(
068 long companyId, long ownerId, int ownerType, long plid,
069 String portletId, String xml)
070 throws Exception {
071
072 PortletPreferences portletPreferences =
073 PortletPreferencesFactoryUtil.fromXML(
074 companyId, ownerId, ownerType, plid, portletId, xml);
075
076 upgradeDisplayStyle(portletPreferences);
077 upgradeRss(portletPreferences);
078
079 return PortletPreferencesFactoryUtil.toXML(portletPreferences);
080 }
081
082 protected void upgradeRss(PortletPreferences portletPreferences)
083 throws Exception {
084
085 String rssFormat = GetterUtil.getString(
086 portletPreferences.getValue("rssFormat", null));
087
088 if (Validator.isNotNull(rssFormat)) {
089 String rssFormatType = RSSUtil.getFormatType(rssFormat);
090 double rssFormatVersion = RSSUtil.getFormatVersion(rssFormat);
091
092 String rssFeedType = RSSUtil.getFeedType(
093 rssFormatType, rssFormatVersion);
094
095 portletPreferences.setValue("rssFeedType", rssFeedType);
096 }
097
098 portletPreferences.reset("rssFormat");
099 }
100
101 }