1
14
15 package com.liferay.portlet.documentlibrary.action;
16
17 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
18 import com.liferay.portal.kernel.servlet.SessionErrors;
19 import com.liferay.portal.kernel.servlet.SessionMessages;
20 import com.liferay.portal.kernel.util.Constants;
21 import com.liferay.portal.kernel.util.ParamUtil;
22 import com.liferay.portlet.PortletPreferencesFactoryUtil;
23 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
24 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
25 import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
26
27 import javax.portlet.ActionRequest;
28 import javax.portlet.ActionResponse;
29 import javax.portlet.PortletConfig;
30 import javax.portlet.PortletPreferences;
31 import javax.portlet.RenderRequest;
32 import javax.portlet.RenderResponse;
33
34
39 public class ConfigurationActionImpl extends BaseConfigurationAction {
40
41 public void processAction(
42 PortletConfig portletConfig, ActionRequest actionRequest,
43 ActionResponse actionResponse)
44 throws Exception {
45
46 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
47
48 if (!cmd.equals(Constants.UPDATE)) {
49 return;
50 }
51
52 long rootFolderId = ParamUtil.getLong(actionRequest, "rootFolderId");
53
54 boolean showFoldersSearch = ParamUtil.getBoolean(
55 actionRequest, "showFoldersSearch");
56 boolean showSubfolders = ParamUtil.getBoolean(
57 actionRequest, "showSubfolders");
58 int foldersPerPage = ParamUtil.getInteger(
59 actionRequest, "foldersPerPage");
60 String folderColumns = ParamUtil.getString(
61 actionRequest, "folderColumns");
62
63 int fileEntriesPerPage = ParamUtil.getInteger(
64 actionRequest, "fileEntriesPerPage");
65 String fileEntryColumns = ParamUtil.getString(
66 actionRequest, "fileEntryColumns");
67
68 boolean enableCommentRatings = ParamUtil.getBoolean(
69 actionRequest, "enableCommentRatings");
70
71 String portletResource = ParamUtil.getString(
72 actionRequest, "portletResource");
73
74 PortletPreferences preferences =
75 PortletPreferencesFactoryUtil.getPortletSetup(
76 actionRequest, portletResource);
77
78 if (rootFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
79 try {
80 DLFolderLocalServiceUtil.getFolder(rootFolderId);
81 }
82 catch (NoSuchFolderException e) {
83 SessionErrors.add(actionRequest, "rootFolderIdInvalid");
84 }
85 }
86
87 preferences.setValue("rootFolderId", String.valueOf(rootFolderId));
88
89 preferences.setValue(
90 "showFoldersSearch", String.valueOf(showFoldersSearch));
91 preferences.setValue("showSubfolders", String.valueOf(showSubfolders));
92 preferences.setValue("foldersPerPage", String.valueOf(foldersPerPage));
93 preferences.setValue("folderColumns", folderColumns);
94
95 preferences.setValue(
96 "fileEntriesPerPage", String.valueOf(fileEntriesPerPage));
97 preferences.setValue("fileEntryColumns", fileEntryColumns);
98
99 preferences.setValue(
100 "enable-comment-ratings", String.valueOf(enableCommentRatings));
101
102 if (SessionErrors.isEmpty(actionRequest)) {
103 preferences.store();
104
105 SessionMessages.add(
106 actionRequest, portletConfig.getPortletName() + ".doConfigure");
107 }
108 }
109
110 public String render(
111 PortletConfig portletConfig, RenderRequest renderRequest,
112 RenderResponse renderResponse)
113 throws Exception {
114
115 return "/html/portlet/document_library/configuration.jsp";
116 }
117
118 }