001
014
015 package com.liferay.portlet.wikidisplay.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.portlet.PortletPreferencesFactoryUtil;
023 import com.liferay.portlet.wiki.NoSuchNodeException;
024 import com.liferay.portlet.wiki.model.WikiNode;
025 import com.liferay.portlet.wiki.service.WikiNodeServiceUtil;
026
027 import javax.portlet.ActionRequest;
028 import javax.portlet.ActionResponse;
029 import javax.portlet.PortletConfig;
030 import javax.portlet.PortletPreferences;
031 import javax.portlet.RenderRequest;
032 import javax.portlet.RenderResponse;
033
034
037 public class ConfigurationActionImpl extends BaseConfigurationAction {
038
039 public void processAction(
040 PortletConfig portletConfig, ActionRequest actionRequest,
041 ActionResponse actionResponse)
042 throws Exception {
043
044 try {
045 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
046
047 if (!cmd.equals(Constants.UPDATE)) {
048 return;
049 }
050
051 long nodeId = ParamUtil.getLong(actionRequest, "nodeId");
052 String title = ParamUtil.getString(actionRequest, "title");
053
054 WikiNode node = WikiNodeServiceUtil.getNode(nodeId);
055
056 String portletResource = ParamUtil.getString(
057 actionRequest, "portletResource");
058
059 PortletPreferences preferences =
060 PortletPreferencesFactoryUtil.getPortletSetup(
061 actionRequest, portletResource);
062
063 preferences.setValue("node-id", String.valueOf(node.getNodeId()));
064 preferences.setValue("title", title);
065
066 preferences.store();
067
068 SessionMessages.add(
069 actionRequest, portletConfig.getPortletName() + ".doConfigure");
070 }
071 catch (NoSuchNodeException nsne) {
072 SessionErrors.add(actionRequest, nsne.getClass().getName());
073 }
074 }
075
076 public String render(
077 PortletConfig portletConfig, RenderRequest renderRequest,
078 RenderResponse renderResponse)
079 throws Exception {
080
081 return "/html/portlet/wiki_display/configuration.jsp";
082 }
083
084 }