001    /**
002     * Copyright (c) 2000-2013 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.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    }