001
014
015 package com.liferay.portlet.documentlibrary.action;
016
017 import com.liferay.portal.kernel.portlet.BaseConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionErrors;
019 import com.liferay.portal.kernel.servlet.SessionMessages;
020 import com.liferay.portal.kernel.util.Constants;
021 import com.liferay.portal.kernel.util.ParamUtil;
022 import com.liferay.portlet.PortletPreferencesFactoryUtil;
023 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
024 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
025 import com.liferay.portlet.documentlibrary.service.DLFolderLocalServiceUtil;
026
027 import javax.portlet.ActionRequest;
028 import javax.portlet.ActionResponse;
029 import javax.portlet.PortletConfig;
030 import javax.portlet.PortletPreferences;
031 import javax.portlet.RenderRequest;
032 import javax.portlet.RenderResponse;
033
034
037 public class ConfigurationActionImpl extends BaseConfigurationAction {
038
039 public void processAction(
040 PortletConfig portletConfig, ActionRequest actionRequest,
041 ActionResponse actionResponse)
042 throws Exception {
043
044 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
045
046 if (!cmd.equals(Constants.UPDATE)) {
047 return;
048 }
049
050 long rootFolderId = ParamUtil.getLong(actionRequest, "rootFolderId");
051
052 boolean showFoldersSearch = ParamUtil.getBoolean(
053 actionRequest, "showFoldersSearch");
054 boolean showSubfolders = ParamUtil.getBoolean(
055 actionRequest, "showSubfolders");
056 int foldersPerPage = ParamUtil.getInteger(
057 actionRequest, "foldersPerPage");
058 String folderColumns = ParamUtil.getString(
059 actionRequest, "folderColumns");
060
061 int fileEntriesPerPage = ParamUtil.getInteger(
062 actionRequest, "fileEntriesPerPage");
063 String fileEntryColumns = ParamUtil.getString(
064 actionRequest, "fileEntryColumns");
065
066 boolean enableCommentRatings = ParamUtil.getBoolean(
067 actionRequest, "enableCommentRatings");
068
069 String portletResource = ParamUtil.getString(
070 actionRequest, "portletResource");
071
072 PortletPreferences preferences =
073 PortletPreferencesFactoryUtil.getPortletSetup(
074 actionRequest, portletResource);
075
076 if (rootFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
077 try {
078 DLFolderLocalServiceUtil.getFolder(rootFolderId);
079 }
080 catch (NoSuchFolderException e) {
081 SessionErrors.add(actionRequest, "rootFolderIdInvalid");
082 }
083 }
084
085 preferences.setValue("rootFolderId", String.valueOf(rootFolderId));
086
087 preferences.setValue(
088 "showFoldersSearch", String.valueOf(showFoldersSearch));
089 preferences.setValue("showSubfolders", String.valueOf(showSubfolders));
090 preferences.setValue("foldersPerPage", String.valueOf(foldersPerPage));
091 preferences.setValue("folderColumns", folderColumns);
092
093 preferences.setValue(
094 "fileEntriesPerPage", String.valueOf(fileEntriesPerPage));
095 preferences.setValue("fileEntryColumns", fileEntryColumns);
096
097 preferences.setValue(
098 "enable-comment-ratings", String.valueOf(enableCommentRatings));
099
100 if (SessionErrors.isEmpty(actionRequest)) {
101 preferences.store();
102
103 SessionMessages.add(
104 actionRequest, portletConfig.getPortletName() + ".doConfigure");
105 }
106 }
107
108 public String render(
109 PortletConfig portletConfig, RenderRequest renderRequest,
110 RenderResponse renderResponse)
111 throws Exception {
112
113 return "/html/portlet/document_library/configuration.jsp";
114 }
115
116 }