001
014
015 package com.liferay.portal.upgrade.v6_1_0;
016
017 import com.liferay.portal.kernel.upgrade.UpgradeProcess;
018 import com.liferay.portal.kernel.util.PropsKeys;
019 import com.liferay.portal.kernel.util.StringBundler;
020
021
024 public class UpgradeCommunityProperties extends UpgradeProcess {
025
026 @Override
027 protected void doUpgrade() throws Exception {
028 for (int i = 0; i < _OLD_PORTLET_PREFERENCES.length; i++) {
029 updatePreferences(
030 "PortletPreferences", _OLD_PORTLET_PREFERENCES[i],
031 _NEW_PORTLET_PREFERENCES[i]);
032 }
033
034 for (int i = 0; i < _OLD_PORTAL_PREFERENCES.length; i++) {
035 updatePreferences(
036 "PortalPreferences", _OLD_PORTAL_PREFERENCES[i],
037 _NEW_PORTAL_PREFERENCES[i]);
038 }
039 }
040
041 protected void updatePreferences(
042 String tableName, String oldValue, String newValue)
043 throws Exception {
044
045 StringBundler sb = new StringBundler();
046
047 sb.append("update ");
048 sb.append(tableName);
049 sb.append(" set preferences = replace(CAST_TEXT(preferences), '");
050 sb.append(oldValue);
051 sb.append("', '");
052 sb.append(newValue);
053 sb.append("') where preferences like '%");
054 sb.append(oldValue);
055 sb.append("%'");
056
057 runSQL(sb.toString());
058 }
059
060 private static final String[] _NEW_PORTAL_PREFERENCES = {
061 PropsKeys.COMPANY_SECURITY_SITE_LOGO,
062 PropsKeys.SITES_EMAIL_FROM_ADDRESS,
063 PropsKeys.SITES_EMAIL_FROM_NAME,
064 PropsKeys.SITES_EMAIL_MEMBERSHIP_REPLY_BODY,
065 PropsKeys.SITES_EMAIL_MEMBERSHIP_REPLY_SUBJECT,
066 PropsKeys.SITES_EMAIL_MEMBERSHIP_REQUEST_BODY,
067 PropsKeys.SITES_EMAIL_MEMBERSHIP_REQUEST_SUBJECT
068 };
069
070 private static final String[] _NEW_PORTLET_PREFERENCES = {
071 "site-role", "[$SITE_NAME$]"
072 };
073
074 private static final String[] _OLD_PORTAL_PREFERENCES = {
075 "company.security.community.logo", "communities.email.from.address",
076 "communities.email.from.name",
077 "communities.email.membership.reply.body",
078 "communities.email.membership.reply.subject",
079 "communities.email.membership.request.body",
080 "communities.email.membership.request.subject",
081 };
082
083 private static final String[] _OLD_PORTLET_PREFERENCES = {
084 "community-role", "[$COMMUNITY_NAME$]"
085 };
086
087 }