001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.upgrade.v6_2_0;
016    
017    import com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.Validator;
020    import com.liferay.portlet.PortletPreferencesFactoryUtil;
021    import com.liferay.util.RSSUtil;
022    
023    import javax.portlet.PortletPreferences;
024    
025    /**
026     * @author Eduardo Garcia
027     * @author Daniel Kocsis
028     */
029    public class UpgradeMessageBoards extends BaseUpgradePortletPreferences {
030    
031            @Override
032            protected void doUpgrade() throws Exception {
033                    super.doUpgrade();
034            }
035    
036            @Override
037            protected String[] getPortletIds() {
038                    return new String[] {"19"};
039            }
040    
041            @Override
042            protected String upgradePreferences(
043                            long companyId, long ownerId, int ownerType, long plid,
044                            String portletId, String xml)
045                    throws Exception {
046    
047                    PortletPreferences portletPreferences =
048                            PortletPreferencesFactoryUtil.fromXML(
049                                    companyId, ownerId, ownerType, plid, portletId, xml);
050    
051                    String rssFormat = GetterUtil.getString(
052                            portletPreferences.getValue("rssFormat", null));
053    
054                    if (Validator.isNotNull(rssFormat)) {
055                            String rssFeedType = RSSUtil.getFeedType(
056                                    RSSUtil.getFormatType(rssFormat),
057                                    RSSUtil.getFormatVersion(rssFormat));
058    
059                            portletPreferences.setValue("rssFeedType", rssFeedType);
060                    }
061    
062                    portletPreferences.reset("rssFormat");
063    
064                    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
065            }
066    
067    }