001
014
015 package com.liferay.portlet.documentlibrary.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.portal.kernel.util.ParamUtil;
021 import com.liferay.portal.kernel.util.Validator;
022 import com.liferay.portal.util.PortletKeys;
023 import com.liferay.portlet.documentlibrary.NoSuchFolderException;
024 import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
025 import com.liferay.portlet.documentlibrary.service.DLAppLocalServiceUtil;
026
027 import javax.portlet.ActionRequest;
028 import javax.portlet.ActionResponse;
029 import javax.portlet.PortletConfig;
030
031
034 public class ConfigurationActionImpl extends DefaultConfigurationAction {
035
036 @Override
037 public void processAction(
038 PortletConfig portletConfig, ActionRequest actionRequest,
039 ActionResponse actionResponse)
040 throws Exception {
041
042 String portletResource = ParamUtil.getString(
043 actionRequest, "portletResource");
044
045 if (portletResource.equals(PortletKeys.DOCUMENT_LIBRARY)) {
046 validateDisplayStyleViews(actionRequest);
047 }
048
049 validateRootFolder(actionRequest);
050
051 super.processAction(portletConfig, actionRequest, actionResponse);
052 }
053
054 protected void validateDisplayStyleViews(ActionRequest actionRequest)
055 throws Exception {
056
057 String displayViews = GetterUtil.getString(
058 getParameter(actionRequest, "displayViews"));
059
060 if (Validator.isNull(displayViews)) {
061 SessionErrors.add(actionRequest, "displayViewsInvalid");
062 }
063 }
064
065 protected void validateRootFolder(ActionRequest actionRequest)
066 throws Exception {
067
068 long rootFolderId = GetterUtil.getLong(
069 getParameter(actionRequest, "rootFolderId"));
070
071 if (rootFolderId != DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
072 try {
073 DLAppLocalServiceUtil.getFolder(rootFolderId);
074 }
075 catch (NoSuchFolderException nsfe) {
076 SessionErrors.add(actionRequest, "rootFolderIdInvalid");
077 }
078 }
079 }
080
081 }