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.BaseUpgradeLastPublishDate;
018    import com.liferay.portal.util.PortletKeys;
019    
020    /**
021     * @author Levente Hud??k
022     */
023    public class UpgradeLastPublishDate extends BaseUpgradeLastPublishDate {
024    
025            @Override
026            protected void doUpgrade() throws Exception {
027                    upgradeAssetCategoriesAdmin();
028                    upgradeBlogs();
029                    upgradeDocumentLibrary();
030                    upgradeLayoutsAdmin();
031                    upgradeMessageBoards();
032                    upgradeMobileDeviceRules();
033                    upgradeSiteAdmin();
034            }
035    
036            protected void upgradeAssetCategoriesAdmin() throws Exception {
037                    runSQL("alter table AssetCategory add lastPublishDate DATE null");
038    
039                    updateLastPublishDates("147", "AssetCategory");
040    
041                    runSQL("alter table AssetTag add lastPublishDate DATE null");
042    
043                    updateLastPublishDates("147", "AssetTag");
044    
045                    runSQL("alter table AssetVocabulary add lastPublishDate DATE null");
046    
047                    updateLastPublishDates("147", "AssetVocabulary");
048            }
049    
050            protected void upgradeBlogs() throws Exception {
051                    runSQL("alter table BlogsEntry add lastPublishDate DATE null");
052    
053                    updateLastPublishDates(PortletKeys.BLOGS, "BlogsEntry");
054            }
055    
056            protected void upgradeDocumentLibrary() throws Exception {
057                    runSQL("alter table DLFileEntry add lastPublishDate DATE null");
058    
059                    updateLastPublishDates("20", "DLFileEntry");
060    
061                    runSQL("alter table DLFileEntryType add lastPublishDate DATE null");
062    
063                    updateLastPublishDates("20", "DLFileEntryType");
064    
065                    runSQL("alter table DLFileShortcut add lastPublishDate DATE null");
066    
067                    updateLastPublishDates("20", "DLFileShortcut");
068    
069                    runSQL("alter table DLFileVersion add lastPublishDate DATE null");
070    
071                    updateLastPublishDates("20", "DLFileVersion");
072    
073                    runSQL("alter table DLFolder add lastPublishDate DATE null");
074    
075                    updateLastPublishDates("20", "DLFolder");
076    
077                    runSQL("alter table Repository add lastPublishDate DATE null");
078    
079                    updateLastPublishDates("20", "Repository");
080    
081                    runSQL("alter table RepositoryEntry add lastPublishDate DATE null");
082    
083                    updateLastPublishDates("20", "RepositoryEntry");
084            }
085    
086            protected void upgradeLayoutsAdmin() throws Exception {
087                    runSQL("alter table Layout add lastPublishDate DATE null");
088    
089                    updateLastPublishDates(PortletKeys.LAYOUTS_ADMIN, "Layout");
090    
091                    runSQL("alter table LayoutFriendlyURL add lastPublishDate DATE null");
092    
093                    updateLastPublishDates(PortletKeys.LAYOUTS_ADMIN, "LayoutFriendlyURL");
094            }
095    
096            protected void upgradeMessageBoards() throws Exception {
097                    runSQL("alter table MBBan add lastPublishDate DATE null");
098    
099                    updateLastPublishDates("19", "MBBan");
100    
101                    runSQL("alter table MBCategory add lastPublishDate DATE null");
102    
103                    updateLastPublishDates("19", "MBCategory");
104    
105                    runSQL("alter table MBDiscussion add lastPublishDate DATE null");
106    
107                    updateLastPublishDates("19", "MBDiscussion");
108    
109                    runSQL("alter table MBMessage add lastPublishDate DATE null");
110    
111                    updateLastPublishDates("19", "MBMessage");
112    
113                    runSQL("alter table MBThread add lastPublishDate DATE null");
114    
115                    updateLastPublishDates("19", "MBThread");
116    
117                    runSQL("alter table MBThreadFlag add lastPublishDate DATE null");
118    
119                    updateLastPublishDates("19", "MBThreadFlag");
120            }
121    
122            protected void upgradeMobileDeviceRules() throws Exception {
123                    runSQL("alter table MDRAction add lastPublishDate DATE null");
124    
125                    updateLastPublishDates("178", "MDRAction");
126    
127                    runSQL("alter table MDRRule add lastPublishDate DATE null");
128    
129                    updateLastPublishDates("178", "MDRRule");
130    
131                    runSQL("alter table MDRRuleGroup add lastPublishDate DATE null");
132    
133                    updateLastPublishDates("178", "MDRRuleGroup");
134    
135                    runSQL(
136                            "alter table MDRRuleGroupInstance add lastPublishDate DATE null");
137    
138                    updateLastPublishDates("178", "MDRRuleGroupInstance");
139            }
140    
141            protected void upgradeSiteAdmin() throws Exception {
142                    runSQL("alter table Team add lastPublishDate DATE null");
143    
144                    updateLastPublishDates(PortletKeys.SITE_ADMIN, "Team");
145            }
146    
147    }