001
014
015 package com.liferay.portlet.wiki.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.ParamUtil;
020 import com.liferay.portal.kernel.util.Validator;
021
022 import javax.portlet.ActionRequest;
023 import javax.portlet.ActionResponse;
024 import javax.portlet.PortletConfig;
025
026
029 public class ConfigurationActionImpl extends DefaultConfigurationAction {
030
031 @Override
032 public void processAction(
033 PortletConfig portletConfig, ActionRequest actionRequest,
034 ActionResponse actionResponse)
035 throws Exception {
036
037 String tabs2 = ParamUtil.getString(actionRequest, "tabs2");
038
039 if (tabs2.equals("display-settings")) {
040 validateDisplaySettings(actionRequest);
041 }
042 else if (tabs2.equals("email-from")) {
043 validateEmailFrom(actionRequest);
044 }
045 else if (tabs2.equals("page-added-email")) {
046 validateEmailPageAdded(actionRequest);
047 }
048 else if (tabs2.equals("page-updated-email")) {
049 validateEmailPageUpdated(actionRequest);
050 }
051
052 super.processAction(portletConfig, actionRequest, actionResponse);
053 }
054
055 protected void validateDisplaySettings(ActionRequest actionRequest)
056 throws Exception {
057
058 String visibleNodes = getParameter(actionRequest, "visibleNodes");
059
060 if (Validator.isNull(visibleNodes)) {
061 SessionErrors.add(actionRequest, "visibleNodesCount");
062 }
063 }
064
065 protected void validateEmailFrom(ActionRequest actionRequest)
066 throws Exception {
067
068 String emailFromName = getParameter(actionRequest, "emailFromName");
069 String emailFromAddress = getParameter(
070 actionRequest, "emailFromAddress");
071
072 if (Validator.isNull(emailFromName)) {
073 SessionErrors.add(actionRequest, "emailFromName");
074 }
075 else if (!Validator.isEmailAddress(emailFromAddress) &&
076 !Validator.isVariableTerm(emailFromAddress)) {
077
078 SessionErrors.add(actionRequest, "emailFromAddress");
079 }
080 }
081
082 protected void validateEmailPageAdded(ActionRequest actionRequest)
083 throws Exception {
084
085 String emailPageAddedSubjectPrefix = getParameter(
086 actionRequest, "emailPageAddedSubjectPrefix");
087 String emailPageAddedBody = getParameter(
088 actionRequest, "emailPageAddedBody");
089
090 if (Validator.isNull(emailPageAddedSubjectPrefix)) {
091 SessionErrors.add(actionRequest, "emailPageAddedSubjectPrefix");
092 }
093 else if (Validator.isNull(emailPageAddedBody)) {
094 SessionErrors.add(actionRequest, "emailPageAddedBody");
095 }
096 }
097
098 protected void validateEmailPageUpdated(ActionRequest actionRequest)
099 throws Exception {
100
101 String emailPageUpdatedSubjectPrefix = getParameter(
102 actionRequest, "emailPageUpdatedSubjectPrefix");
103 String emailPageUpdatedBody = getParameter(
104 actionRequest, "emailPageUpdatedBody");
105
106 if (Validator.isNull(emailPageUpdatedSubjectPrefix)) {
107 SessionErrors.add(actionRequest, "emailPageUpdatedSubjectPrefix");
108 }
109 else if (Validator.isNull(emailPageUpdatedBody)) {
110 SessionErrors.add(actionRequest, "emailPageUpdatedBody");
111 }
112 }
113
114 }