001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.journal.action;
016    
017    import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
018    import com.liferay.portal.kernel.util.LocaleUtil;
019    import com.liferay.portal.util.PropsValues;
020    import com.liferay.util.ContentUtil;
021    
022    import javax.portlet.ActionRequest;
023    import javax.portlet.ActionResponse;
024    import javax.portlet.PortletConfig;
025    import javax.portlet.PortletPreferences;
026    import javax.portlet.PortletRequest;
027    
028    /**
029     * @author Brian Wing Shun Chan
030     */
031    public class ConfigurationActionImpl extends DefaultConfigurationAction {
032    
033            @Override
034            public void postProcess(
035                    long companyId, PortletRequest portletRequest,
036                    PortletPreferences portletPreferences) {
037    
038                    String languageId = LocaleUtil.toLanguageId(
039                            LocaleUtil.getSiteDefault());
040    
041                    removeDefaultValue(
042                            portletRequest, portletPreferences,
043                            "emailArticleAddedBody_" + languageId,
044                            ContentUtil.get(PropsValues.JOURNAL_EMAIL_ARTICLE_ADDED_BODY));
045                    removeDefaultValue(
046                            portletRequest, portletPreferences,
047                            "emailArticleAddedSubject_" + languageId,
048                            ContentUtil.get(PropsValues.JOURNAL_EMAIL_ARTICLE_ADDED_SUBJECT));
049                    removeDefaultValue(
050                            portletRequest, portletPreferences,
051                            "emailArticleApprovalDeniedBody_" + languageId,
052                            ContentUtil.get(
053                                    PropsValues.JOURNAL_EMAIL_ARTICLE_APPROVAL_DENIED_BODY));
054                    removeDefaultValue(
055                            portletRequest, portletPreferences,
056                            "emailArticleApprovalDeniedSubject_" + languageId,
057                            ContentUtil.get(
058                                    PropsValues.JOURNAL_EMAIL_ARTICLE_APPROVAL_DENIED_SUBJECT));
059                    removeDefaultValue(
060                            portletRequest, portletPreferences,
061                            "emailArticleApprovalGrantedBody_" + languageId,
062                            ContentUtil.get(
063                                    PropsValues.JOURNAL_EMAIL_ARTICLE_APPROVAL_GRANTED_BODY));
064                    removeDefaultValue(
065                            portletRequest, portletPreferences,
066                            "emailArticleApprovalGrantedSubject_" + languageId,
067                            ContentUtil.get(
068                                    PropsValues.JOURNAL_EMAIL_ARTICLE_APPROVAL_GRANTED_SUBJECT));
069                    removeDefaultValue(
070                            portletRequest, portletPreferences,
071                            "emailArticleApprovalRequestedBody_" + languageId,
072                            ContentUtil.get(
073                                    PropsValues.JOURNAL_EMAIL_ARTICLE_APPROVAL_REQUESTED_BODY));
074                    removeDefaultValue(
075                            portletRequest, portletPreferences,
076                            "emailArticleApprovalRequestedSubject_" + languageId,
077                            ContentUtil.get(
078                                    PropsValues.JOURNAL_EMAIL_ARTICLE_APPROVAL_REQUESTED_SUBJECT));
079                    removeDefaultValue(
080                            portletRequest, portletPreferences,
081                            "emailArticleReviewBody_" + languageId,
082                            ContentUtil.get(PropsValues.JOURNAL_EMAIL_ARTICLE_REVIEW_BODY));
083                    removeDefaultValue(
084                            portletRequest, portletPreferences,
085                            "emailArticleReviewSubject_" + languageId,
086                            ContentUtil.get(PropsValues.JOURNAL_EMAIL_ARTICLE_REVIEW_SUBJECT));
087                    removeDefaultValue(
088                            portletRequest, portletPreferences,
089                            "emailArticleUpdatedBody_" + languageId,
090                            ContentUtil.get(PropsValues.JOURNAL_EMAIL_ARTICLE_UPDATED_BODY));
091                    removeDefaultValue(
092                            portletRequest, portletPreferences,
093                            "emailArticleUpdatedSubject_" + languageId,
094                            ContentUtil.get(PropsValues.JOURNAL_EMAIL_ARTICLE_UPDATED_SUBJECT));
095            }
096    
097            @Override
098            public void processAction(
099                            PortletConfig portletConfig, ActionRequest actionRequest,
100                            ActionResponse actionResponse)
101                    throws Exception {
102    
103                    validateEmail(actionRequest, "emailArticleAdded");
104                    validateEmail(actionRequest, "emailArticleApprovalDenied");
105                    validateEmail(actionRequest, "emailArticleApprovalGranted");
106                    validateEmail(actionRequest, "emailArticleApprovalRequested");
107                    validateEmail(actionRequest, "emailArticleReview");
108                    validateEmail(actionRequest, "emailArticleUpdated");
109                    validateEmailFrom(actionRequest);
110    
111                    super.processAction(portletConfig, actionRequest, actionResponse);
112            }
113    
114    }