001    /**
002     * Copyright (c) 2000-2012 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     */
028    public class UpgradeMessageBoards extends BaseUpgradePortletPreferences {
029    
030            @Override
031            protected String[] getPortletIds() {
032                    return new String[] {"19"};
033            }
034    
035            @Override
036            protected String upgradePreferences(
037                            long companyId, long ownerId, int ownerType, long plid,
038                            String portletId, String xml)
039                    throws Exception {
040    
041                    PortletPreferences portletPreferences =
042                            PortletPreferencesFactoryUtil.fromXML(
043                                    companyId, ownerId, ownerType, plid, portletId, xml);
044    
045                    String rssFormat = GetterUtil.getString(
046                            portletPreferences.getValue("rssFormat", null));
047    
048                    if (Validator.isNotNull(rssFormat)) {
049                            String rssFeedType = RSSUtil.getFeedType(
050                                    RSSUtil.getFormatType(rssFormat),
051                                    RSSUtil.getFormatVersion(rssFormat));
052    
053                            portletPreferences.setValue("rssFeedType", rssFeedType);
054                    }
055    
056                    portletPreferences.reset("rssFormat");
057    
058                    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
059            }
060    
061    }