001
014
015 package com.liferay.portlet.bookmarks.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.bookmarks.model.BookmarksFolderConstants;
024 import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
025 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
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 entriesPerPage = ParamUtil.getInteger(
062 actionRequest, "entriesPerPage");
063 String entryColumns = ParamUtil.getString(
064 actionRequest, "entryColumns");
065
066 String portletResource = ParamUtil.getString(
067 actionRequest, "portletResource");
068
069 PortletPreferences preferences =
070 PortletPreferencesFactoryUtil.getPortletSetup(
071 actionRequest, portletResource);
072
073 if (rootFolderId != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
074 try {
075 BookmarksFolderLocalServiceUtil.getFolder(rootFolderId);
076 }
077 catch (NoSuchFolderException e) {
078 SessionErrors.add(actionRequest, "rootFolderIdInvalid");
079 }
080 }
081
082 preferences.setValue("rootFolderId", String.valueOf(rootFolderId));
083
084 preferences.setValue(
085 "showFoldersSearch", String.valueOf(showFoldersSearch));
086 preferences.setValue("showSubfolders", String.valueOf(showSubfolders));
087 preferences.setValue("foldersPerPage", String.valueOf(foldersPerPage));
088 preferences.setValue("folderColumns", folderColumns);
089
090 preferences.setValue(
091 "entriesPerPage", String.valueOf(entriesPerPage));
092 preferences.setValue("entryColumns", entryColumns);
093
094 if (SessionErrors.isEmpty(actionRequest)) {
095 preferences.store();
096
097 SessionMessages.add(
098 actionRequest, portletConfig.getPortletName() + ".doConfigure");
099 }
100 }
101
102 public String render(
103 PortletConfig portletConfig, RenderRequest renderRequest,
104 RenderResponse renderResponse)
105 throws Exception {
106
107 return "/html/portlet/bookmarks/configuration.jsp";
108 }
109
110 }