001
014
015 package com.liferay.portal.kernel.portlet;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.settings.PortletPreferencesSettings;
020 import com.liferay.portal.kernel.settings.Settings;
021 import com.liferay.portal.kernel.util.StringUtil;
022
023 import javax.portlet.ActionRequest;
024 import javax.portlet.PortletPreferences;
025 import javax.portlet.PortletRequest;
026 import javax.portlet.ReadOnlyException;
027
028
031 public class DefaultConfigurationAction
032 extends BaseJSPSettingsConfigurationAction
033 implements ConfigurationAction, ResourceServingConfigurationAction {
034
035 public DefaultConfigurationAction() {
036 setParameterNamePrefix("preferences--");
037 }
038
039 @Override
040 protected Settings getSettings(ActionRequest actionRequest) {
041 return new PortletPreferencesSettings(actionRequest.getPreferences());
042 }
043
044 @SuppressWarnings("unused")
045 protected void postProcess(
046 long companyId, PortletRequest portletRequest,
047 PortletPreferences portletPreferences)
048 throws PortalException {
049 }
050
051 @Override
052 protected void postProcess(
053 long companyId, PortletRequest portletRequest, Settings settings)
054 throws PortalException {
055
056 PortletPreferencesSettings portletPreferencesSettings =
057 (PortletPreferencesSettings)settings;
058
059 postProcess(
060 companyId, portletRequest,
061 portletPreferencesSettings.getPortletPreferences());
062 }
063
064 protected void removeDefaultValue(
065 PortletRequest portletRequest, PortletPreferences portletPreferences,
066 String key, String defaultValue) {
067
068 String value = getParameter(portletRequest, key);
069
070 if (defaultValue.equals(value) ||
071 StringUtil.equalsIgnoreBreakLine(defaultValue, value)) {
072
073 try {
074 portletPreferences.reset(key);
075 }
076 catch (ReadOnlyException roe) {
077 throw new SystemException(roe);
078 }
079 }
080 }
081
082 @Override
083 protected void updateMultiValuedKeys(ActionRequest actionRequest) {
084
085
086
087
088
089 }
090
091 }