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