001
014
015 package com.liferay.portlet.invitation.action;
016
017 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionErrors;
019 import com.liferay.portal.kernel.servlet.SessionMessages;
020 import com.liferay.portal.kernel.util.Constants;
021 import com.liferay.portal.kernel.util.ParamUtil;
022 import com.liferay.portal.kernel.util.Validator;
023 import com.liferay.portlet.PortletPreferencesFactoryUtil;
024
025 import javax.portlet.ActionRequest;
026 import javax.portlet.ActionResponse;
027 import javax.portlet.PortletConfig;
028 import javax.portlet.PortletPreferences;
029 import javax.portlet.RenderRequest;
030 import javax.portlet.RenderResponse;
031
032
035 public class ConfigurationActionImpl extends BaseConfigurationAction {
036
037 public void processAction(
038 PortletConfig portletConfig, ActionRequest actionRequest,
039 ActionResponse actionResponse)
040 throws Exception {
041
042 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
043
044 if (!cmd.equals(Constants.UPDATE)) {
045 return;
046 }
047
048 String emailMessageSubject = ParamUtil.getString(
049 actionRequest, "emailMessageSubject");
050 String emailMessageBody = ParamUtil.getString(
051 actionRequest, "emailMessageBody");
052
053 if (Validator.isNull(emailMessageSubject)) {
054 SessionErrors.add(actionRequest, "emailMessageSubject");
055 }
056 else if (Validator.isNull(emailMessageBody)) {
057 SessionErrors.add(actionRequest, "emailMessageBody");
058 }
059 else {
060 String portletResource = ParamUtil.getString(
061 actionRequest, "portletResource");
062
063 PortletPreferences preferences =
064 PortletPreferencesFactoryUtil.getPortletSetup(
065 actionRequest, portletResource);
066
067 preferences.setValue("email-message-subject", emailMessageSubject);
068 preferences.setValue("email-message-body", emailMessageBody);
069
070 preferences.store();
071
072 SessionMessages.add(
073 actionRequest, portletConfig.getPortletName() + ".doConfigure");
074 }
075 }
076
077 public String render(
078 PortletConfig portletConfig, RenderRequest renderRequest,
079 RenderResponse renderResponse)
080 throws Exception {
081
082 return "/html/portlet/invitation/configuration.jsp";
083 }
084
085 }