/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.knowledge.base.internal.upgrade.v1_3_0;
import com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil;
import com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.rss.util.RSSUtil;
import javax.portlet.PortletPreferences;
/**
* @author Eduardo Garcia
*/
public class UpgradePortletPreferences extends BaseUpgradePortletPreferences {
@Override
protected String[] getPortletIds() {
return _PORTLET_IDS;
}
@Override
protected String upgradePreferences(
long companyId, long ownerId, int ownerType, long plid,
String portletId, String xml)
throws Exception {
PortletPreferences portletPreferences =
PortletPreferencesFactoryUtil.fromXML(
companyId, ownerId, ownerType, plid, portletId, xml);
String rssFormat = GetterUtil.getString(
portletPreferences.getValue("rssFormat", null));
if (Validator.isNotNull(rssFormat)) {
String rssFeedType = RSSUtil.getFeedType(
RSSUtil.getFormatType(rssFormat),
RSSUtil.getFormatVersion(rssFormat));
portletPreferences.setValue("rssFeedType", rssFeedType);
}
portletPreferences.reset("rssFormat");
return PortletPreferencesFactoryUtil.toXML(portletPreferences);
}
private static final String[] _PORTLET_IDS = new String[] {
"2_WAR_knowledgebaseportlet", "3_WAR_knowledgebaseportlet_INSTANCE_%",
"4_WAR_knowledgebaseportlet_INSTANCE_%", "5_WAR_knowledgebaseportlet"
};
}