001    /**
002     * Copyright (c) 2000-present 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.v7_0_0;
016    
017    import com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.util.PortletKeys;
020    import com.liferay.portlet.PortletPreferencesFactoryUtil;
021    
022    import javax.portlet.PortletPreferences;
023    
024    /**
025     * @author Iv??n Zaera
026     */
027    public class UpgradeDLPreferences extends BaseUpgradePortletPreferences {
028    
029            @Override
030            protected String[] getPortletIds() {
031                    return new String[] {
032                            PortletKeys.DOCUMENT_LIBRARY,
033                            PortletKeys.DOCUMENT_LIBRARY_DISPLAY + StringPool.PERCENT,
034                            PortletKeys.MEDIA_GALLERY_DISPLAY + StringPool.PERCENT
035                    };
036            }
037    
038            @Override
039            protected String upgradePreferences(
040                            long companyId, long ownerId, int ownerType, long plid,
041                            String portletId, String xml)
042                    throws Exception {
043    
044                    PortletPreferences portletPreferences =
045                            PortletPreferencesFactoryUtil.fromXML(
046                                    companyId, ownerId, ownerType, plid, portletId, xml);
047    
048                    upgradeMultiValuePreference(portletPreferences, "displayViews");
049                    upgradeMultiValuePreference(portletPreferences, "entryColumns");
050                    upgradeMultiValuePreference(portletPreferences, "folderColumns");
051                    upgradeMultiValuePreference(portletPreferences, "fileEntryColumns");
052                    upgradeMultiValuePreference(portletPreferences, "mimeTypes");
053    
054                    return PortletPreferencesFactoryUtil.toXML(portletPreferences);
055            }
056    
057    }