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.v6_0_3;
016    
017    import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018    import com.liferay.portal.kernel.util.LoggingTimer;
019    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
020    
021    import java.sql.PreparedStatement;
022    import java.sql.ResultSet;
023    
024    /**
025     * @author Jang Kim
026     */
027    public class UpgradeLayout extends UpgradeProcess {
028    
029            @Override
030            protected void doUpgrade() throws Exception {
031                    updateLayouts();
032            }
033    
034            protected void updateLayouts() throws Exception {
035                    try (LoggingTimer loggingTimer = new LoggingTimer();
036                            PreparedStatement ps = connection.prepareStatement(
037                                    "select plid from Layout where uuid_ is null");
038                            ResultSet rs = ps.executeQuery()) {
039    
040                            while (rs.next()) {
041                                    long plid = rs.getLong("plid");
042    
043                                    runSQL(
044                                            "update Layout set uuid_ = '" + PortalUUIDUtil.generate() +
045                                                    "' where plid = " + plid);
046                            }
047                    }
048            }
049    
050    }