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