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
45 public class ConfigurationActionImpl extends BaseConfigurationAction {
46
47 public void processAction(
48 PortletConfig portletConfig, ActionRequest actionRequest,
49 ActionResponse actionResponse)
50 throws Exception {
51
52 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
53
54 if (!cmd.equals(Constants.UPDATE)) {
55 return;
56 }
57
58 long rootLayoutId = ParamUtil.getLong(actionRequest, "rootLayoutId");
59 String displayDepth = ParamUtil.getString(
60 actionRequest, "displayDepth");
61 boolean includeRootInTree = ParamUtil.getBoolean(
62 actionRequest, "includeRootInTree");
63 boolean showCurrentPage = ParamUtil.getBoolean(
64 actionRequest, "showCurrentPage");
65 boolean useHtmlTitle = ParamUtil.getBoolean(
66 actionRequest, "useHtmlTitle");
67 boolean showHiddenPages = ParamUtil.getBoolean(
68 actionRequest, "showHiddenPages");
69
70 if (rootLayoutId == LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
71 includeRootInTree = false;
72 }
73
74 String portletResource = ParamUtil.getString(
75 actionRequest, "portletResource");
76
77 PortletPreferences preferences =
78 PortletPreferencesFactoryUtil.getPortletSetup(
79 actionRequest, portletResource);
80
81 preferences.setValue("root-layout-id", String.valueOf(rootLayoutId));
82 preferences.setValue("display-depth", displayDepth);
83 preferences.setValue(
84 "include-root-in-tree", String.valueOf(includeRootInTree));
85 preferences.setValue(
86 "show-current-page", String.valueOf(showCurrentPage));
87 preferences.setValue("use-html-title", String.valueOf(useHtmlTitle));
88 preferences.setValue(
89 "show-hidden-pages", String.valueOf(showHiddenPages));
90
91 preferences.store();
92
93 SessionMessages.add(
94 actionRequest, portletConfig.getPortletName() + ".doConfigure");
95 }
96
97 public String render(
98 PortletConfig portletConfig, RenderRequest renderRequest,
99 RenderResponse renderResponse)
100 throws Exception {
101
102 return "/html/portlet/site_map/configuration.jsp";
103 }
104
105 }