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