001
014
015 package com.liferay.portlet.bookmarks.action;
016
017 import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
018 import com.liferay.portal.kernel.servlet.SessionErrors;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portlet.bookmarks.model.BookmarksFolderConstants;
021 import com.liferay.portlet.bookmarks.service.BookmarksFolderLocalServiceUtil;
022 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
023
024 import javax.portlet.ActionRequest;
025 import javax.portlet.ActionResponse;
026 import javax.portlet.PortletConfig;
027
028
031 public class ConfigurationActionImpl extends DefaultConfigurationAction {
032
033 @Override
034 public void processAction(
035 PortletConfig portletConfig, ActionRequest actionRequest,
036 ActionResponse actionResponse)
037 throws Exception {
038
039 validateRootFolder(actionRequest);
040
041 super.processAction(portletConfig, actionRequest, actionResponse);
042 }
043
044 protected void validateRootFolder(ActionRequest actionRequest)
045 throws Exception {
046
047 long rootFolderId = GetterUtil.getLong(
048 getParameter(actionRequest, "rootFolderId"));
049
050 if (rootFolderId != BookmarksFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
051 try {
052 BookmarksFolderLocalServiceUtil.getFolder(rootFolderId);
053 }
054 catch (NoSuchFolderException nsfe) {
055 SessionErrors.add(actionRequest, "rootFolderIdInvalid");
056 }
057 }
058 }
059
060 }