001    /**
002     * Copyright (c) 2000-2013 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.dao.jdbc.DataAccess;
018    import com.liferay.portal.kernel.upgrade.UpgradeProcess;
019    import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
020    
021    import java.sql.Connection;
022    import java.sql.PreparedStatement;
023    import java.sql.ResultSet;
024    
025    /**
026     * @author Jang Kim
027     */
028    public class UpgradeLayout extends UpgradeProcess {
029    
030            @Override
031            protected void doUpgrade() throws Exception {
032                    Connection con = null;
033                    PreparedStatement ps = null;
034                    ResultSet rs = null;
035    
036                    try {
037                            con = DataAccess.getUpgradeOptimizedConnection();
038    
039                            ps = con.prepareStatement(
040                                    "select plid from Layout where uuid_ is null");
041    
042                            rs = ps.executeQuery();
043    
044                            while (rs.next()) {
045                                    long plid = rs.getLong("plid");
046    
047                                    runSQL(
048                                            "update Layout set uuid_ = '" + PortalUUIDUtil.generate() +
049                                                    "' where plid = " + plid);
050                            }
051                    }
052                    finally {
053                            DataAccess.cleanUp(con, ps, rs);
054                    }
055            }
056    
057    }