001
014
015 package com.liferay.portal.upgrade.v6_1_0;
016
017 import com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.Validator;
020 import com.liferay.portlet.PortletPreferencesFactoryUtil;
021
022 import javax.portlet.PortletPreferences;
023
024
027 public class UpgradeIFrame extends BaseUpgradePortletPreferences {
028
029 @Override
030 protected String[] getPortletIds() {
031 return new String[] {"48_INSTANCE_%"};
032 }
033
034 protected void upgradePassword(PortletPreferences portletPreferences)
035 throws Exception {
036
037 String password = GetterUtil.getString(
038 portletPreferences.getValue("password", null));
039
040 if (Validator.isNotNull(password)) {
041 portletPreferences.setValue("formPassword", password);
042 }
043
044 portletPreferences.reset("password");
045 }
046
047 @Override
048 protected String upgradePreferences(
049 long companyId, long ownerId, int ownerType, long plid,
050 String portletId, String xml)
051 throws Exception {
052
053 PortletPreferences portletPreferences =
054 PortletPreferencesFactoryUtil.fromXML(
055 companyId, ownerId, ownerType, plid, portletId, xml);
056
057 upgradePassword(portletPreferences);
058 upgradeUserName(portletPreferences);
059
060 return PortletPreferencesFactoryUtil.toXML(portletPreferences);
061 }
062
063 protected void upgradeUserName(PortletPreferences portletPreferences)
064 throws Exception {
065
066 String userName = GetterUtil.getString(
067 portletPreferences.getValue("userName", null));
068
069 if (Validator.isNull(userName)) {
070 userName = GetterUtil.getString(
071 portletPreferences.getValue("user-name", null));
072 }
073
074 if (Validator.isNotNull(userName)) {
075 portletPreferences.setValue("formUserName", userName);
076 }
077
078 portletPreferences.reset("user-name");
079 portletPreferences.reset("userName");
080 }
081
082 }