001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.upgrade.v5_2_0;
016    
017    import com.liferay.portal.kernel.util.StringPool;
018    import com.liferay.portal.kernel.util.StringUtil;
019    import com.liferay.portal.kernel.util.Validator;
020    import com.liferay.portal.upgrade.BaseUpgradePortletPreferences;
021    import com.liferay.portlet.PortletPreferencesImpl;
022    import com.liferay.portlet.PortletPreferencesSerializer;
023    
024    /**
025     * @author Samuel Kong
026     * @author Brian Wing Shun Chan
027     * @author Edward Shin
028     */
029    public class UpgradeDocumentLibrary extends BaseUpgradePortletPreferences {
030    
031            protected String getUpdatePortletPreferencesWhereClause() {
032                    return "portletId = '20'";
033            }
034    
035            protected String upgradePreferences(
036                            long companyId, long ownerId, int ownerType, long plid,
037                            String portletId, String xml)
038                    throws Exception {
039    
040                    PortletPreferencesImpl preferences =
041                            PortletPreferencesSerializer.fromXML(
042                                    companyId, ownerId, ownerType, plid, portletId, xml);
043    
044                    String fileEntryColumns = preferences.getValue(
045                            "fileEntryColumns", StringPool.BLANK);
046    
047                    if (Validator.isNotNull(fileEntryColumns)) {
048                            fileEntryColumns = StringUtil.replace(
049                                    fileEntryColumns, "document", "name");
050    
051                            preferences.setValue("fileEntryColumns", fileEntryColumns);
052                    }
053    
054                    return PortletPreferencesSerializer.toXML(preferences);
055            }
056    
057    }