001
014
015 package com.liferay.portal.upgrade.v6_2_0;
016
017 import com.liferay.portal.kernel.dao.jdbc.DataAccess;
018 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
019 import com.liferay.portal.kernel.util.LocaleUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.uuid.PortalUUIDUtil;
022
023 import java.sql.Connection;
024 import java.sql.PreparedStatement;
025 import java.sql.ResultSet;
026 import java.sql.Timestamp;
027
028
031 public class UpgradeLayoutFriendlyURL extends UpgradeProcess {
032
033 protected void addLayoutFriendlyURL(
034 long groupId, long companyId, long userId, String userName,
035 Timestamp createDate, Timestamp modifiedDate, long plid,
036 boolean privateLayout, String friendlyURL)
037 throws Exception {
038
039 Connection con = null;
040 PreparedStatement ps = null;
041
042 try {
043 con = DataAccess.getUpgradeOptimizedConnection();
044
045 StringBundler sb = new StringBundler(4);
046
047 sb.append("insert into LayoutFriendlyURL (uuid_, ");
048 sb.append("layoutFriendlyURLId, groupId, companyId, userId, ");
049 sb.append("userName, createDate, modifiedDate, plid, ");
050 sb.append("privateLayout, friendlyURL, languageId) values (?, ?, ");
051 sb.append("?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
052
053 ps = con.prepareStatement(sb.toString());
054
055 ps.setString(1, PortalUUIDUtil.generate());
056 ps.setLong(2, increment());
057 ps.setLong(3, groupId);
058 ps.setLong(4, companyId);
059 ps.setLong(5, userId);
060 ps.setString(6, userName);
061 ps.setTimestamp(7, createDate);
062 ps.setTimestamp(8, modifiedDate);
063 ps.setLong(9, plid);
064 ps.setBoolean(10, privateLayout);
065 ps.setString(11, friendlyURL);
066 ps.setString(12, LocaleUtil.toLanguageId(LocaleUtil.getDefault()));
067
068 ps.executeUpdate();
069 }
070 finally {
071 DataAccess.cleanUp(con, ps);
072 }
073 }
074
075 @Override
076 protected void doUpgrade() throws Exception {
077 Connection con = null;
078 PreparedStatement ps = null;
079 ResultSet rs = null;
080
081 try {
082 con = DataAccess.getUpgradeOptimizedConnection();
083
084 ps = con.prepareStatement(
085 "select plid, groupId, companyId, userId, userName, " +
086 "createDate, modifiedDate, privateLayout, friendlyURL " +
087 "from Layout");
088
089 rs = ps.executeQuery();
090
091 while (rs.next()) {
092 long plid = rs.getLong("plid");
093 long groupId = rs.getLong("groupId");
094 long companyId = rs.getLong("companyId");
095 long userId = rs.getLong("userId");
096 String userName = rs.getString("userName");
097 Timestamp createDate = rs.getTimestamp("createDate");
098 Timestamp modifiedDate = rs.getTimestamp("modifiedDate");
099 boolean privateLayout = rs.getBoolean("privateLayout");
100 String friendlyURL = rs.getString("friendlyURL");
101
102 addLayoutFriendlyURL(
103 groupId, companyId, userId, userName, createDate,
104 modifiedDate, plid, privateLayout, friendlyURL);
105 }
106 }
107 finally {
108 DataAccess.cleanUp(con, ps, rs);
109 }
110 }
111
112 }