1
22
23 package com.liferay.portlet.sitemap.action;
24
25 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
26 import com.liferay.portal.kernel.servlet.SessionMessages;
27 import com.liferay.portal.kernel.util.Constants;
28 import com.liferay.portal.kernel.util.ParamUtil;
29 import com.liferay.portal.model.LayoutConstants;
30 import com.liferay.portlet.PortletPreferencesFactoryUtil;
31
32 import javax.portlet.ActionRequest;
33 import javax.portlet.ActionResponse;
34 import javax.portlet.PortletConfig;
35 import javax.portlet.PortletPreferences;
36 import javax.portlet.RenderRequest;
37 import javax.portlet.RenderResponse;
38
39
44 public class ConfigurationActionImpl extends BaseConfigurationAction {
45
46 public void processAction(
47 PortletConfig portletConfig, ActionRequest actionRequest,
48 ActionResponse actionResponse)
49 throws Exception {
50
51 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
52
53 if (!cmd.equals(Constants.UPDATE)) {
54 return;
55 }
56
57 long rootLayoutId = ParamUtil.getLong(actionRequest, "rootLayoutId");
58 String displayDepth = ParamUtil.getString(
59 actionRequest, "displayDepth");
60 boolean includeRootInTree = ParamUtil.getBoolean(
61 actionRequest, "includeRootInTree");
62 boolean showCurrentPage = ParamUtil.getBoolean(
63 actionRequest, "showCurrentPage");
64 boolean useHtmlTitle = ParamUtil.getBoolean(
65 actionRequest, "useHtmlTitle");
66 boolean showHiddenPages = ParamUtil.getBoolean(
67 actionRequest, "showHiddenPages");
68
69 if (rootLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
70 includeRootInTree = false;
71 }
72
73 String portletResource = ParamUtil.getString(
74 actionRequest, "portletResource");
75
76 PortletPreferences preferences =
77 PortletPreferencesFactoryUtil.getPortletSetup(
78 actionRequest, portletResource);
79
80 preferences.setValue("root-layout-id", String.valueOf(rootLayoutId));
81 preferences.setValue("display-depth", displayDepth);
82 preferences.setValue(
83 "include-root-in-tree", String.valueOf(includeRootInTree));
84 preferences.setValue(
85 "show-current-page", String.valueOf(showCurrentPage));
86 preferences.setValue("use-html-title", String.valueOf(useHtmlTitle));
87 preferences.setValue(
88 "show-hidden-pages", String.valueOf(showHiddenPages));
89
90 preferences.store();
91
92 SessionMessages.add(
93 actionRequest, portletConfig.getPortletName() + ".doConfigure");
94 }
95
96 public String render(
97 PortletConfig portletConfig, RenderRequest renderRequest,
98 RenderResponse renderResponse)
99 throws Exception {
100
101 return "/html/portlet/site_map/configuration.jsp";
102 }
103
104 }