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, PropsKeys.SITES_EMAIL_FROM_NAME,
063 PropsKeys.SITES_EMAIL_MEMBERSHIP_REPLY_BODY,
064 PropsKeys.SITES_EMAIL_MEMBERSHIP_REPLY_SUBJECT,
065 PropsKeys.SITES_EMAIL_MEMBERSHIP_REQUEST_BODY,
066 PropsKeys.SITES_EMAIL_MEMBERSHIP_REQUEST_SUBJECT
067 };
068
069 private static final String[] _NEW_PORTLET_PREFERENCES = {
070 "site-role", "[$SITE_NAME$]"
071 };
072
073 private static final String[] _OLD_PORTAL_PREFERENCES = {
074 "company.security.community.logo", "communities.email.from.address",
075 "communities.email.from.name",
076 "communities.email.membership.reply.body",
077 "communities.email.membership.reply.subject",
078 "communities.email.membership.request.body",
079 "communities.email.membership.request.subject",
080 };
081
082 private static final String[] _OLD_PORTLET_PREFERENCES = {
083 "community-role", "[$COMMUNITY_NAME$]"
084 };
085
086 }