aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/server/SystemMessages.java
blob: 9bb403b2d0bd1ed5ef030e8cbf31caf634501489 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
/*
 * Copyright 2000-2018 Vaadin Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.vaadin.server;

import java.io.Serializable;

/**
 * Contains the system messages used to notify the user about various critical
 * situations that can occur.
 * <p>
 * Use {@link VaadinService#setSystemMessagesProvider(SystemMessagesProvider)}
 * to customize.
 * </p>
 * <p>
 * The defaults defined in this class are:
 * <ul>
 * <li><b>sessionExpiredURL</b> = null</li>
 * <li><b>sessionExpiredNotificationEnabled</b> = true</li>
 * <li><b>sessionExpiredCaption</b> = ""</li>
 * <li><b>sessionExpiredMessage</b> = "Take note of any unsaved data, and
 * <u>click here</u> to continue."</li>
 * <li><b>communicationErrorURL</b> = null</li>
 * <li><b>communicationErrorNotificationEnabled</b> = true</li>
 * <li><b>communicationErrorCaption</b> = "Communication problem"</li>
 * <li><b>communicationErrorMessage</b> = "Take note of any unsaved data, and
 * <u>click here</u> to continue."</li>
 * <li><b>internalErrorURL</b> = null</li>
 * <li><b>internalErrorNotificationEnabled</b> = true</li>
 * <li><b>internalErrorCaption</b> = "Internal error"</li>
 * <li><b>internalErrorMessage</b> = "Please notify the administrator.<br/>
 * Take note of any unsaved data, and <u>click here</u> to continue."</li>
 * <li><b>cookiesDisabledURL</b> = null</li>
 * <li><b>cookiesDisabledNotificationEnabled</b> = true</li>
 * <li><b>cookiesDisabledCaption</b> = "Cookies disabled"</li>
 * <li><b>cookiesDisabledMessage</b> = "This application requires cookies to
 * function.<br/>
 * Please enable cookies in your browser and <u>click here</u> to try
 * again.</li>
 * </ul>
 * </p>
 *
 */
public class SystemMessages implements Serializable {
    protected String sessionExpiredURL = null;
    protected boolean sessionExpiredNotificationEnabled = true;
    protected String sessionExpiredCaption = "Session Expired";
    protected String sessionExpiredMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC key to continue.";

    protected String communicationErrorURL = null;
    protected boolean communicationErrorNotificationEnabled = true;
    protected String communicationErrorCaption = "Communication problem";
    protected String communicationErrorMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";

    protected String authenticationErrorURL = null;
    protected boolean authenticationErrorNotificationEnabled = true;
    protected String authenticationErrorCaption = "Authentication problem";
    protected String authenticationErrorMessage = "Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";

    protected String internalErrorURL = null;
    protected boolean internalErrorNotificationEnabled = true;
    protected String internalErrorCaption = "Internal error";
    protected String internalErrorMessage = "Please notify the administrator.<br/>Take note of any unsaved data, and <u>click here</u> or press ESC to continue.";

    protected String cookiesDisabledURL = null;
    protected boolean cookiesDisabledNotificationEnabled = true;
    protected String cookiesDisabledCaption = "Cookies disabled";
    protected String cookiesDisabledMessage = "This application requires cookies to function.<br/>Please enable cookies in your browser and <u>click here</u> or press ESC to try again.";

    /**
     * Use {@link CustomizedSystemMessages} to customize
     */
    SystemMessages() {

    }

    /**
     * @return null to indicate that the application will be restarted after
     *         session expired message has been shown.
     */
    public String getSessionExpiredURL() {
        return sessionExpiredURL;
    }

    /**
     * @return true to show session expiration message.
     */
    public boolean isSessionExpiredNotificationEnabled() {
        return sessionExpiredNotificationEnabled;
    }

    /**
     * @return "" to show no caption.
     */
    public String getSessionExpiredCaption() {
        return (sessionExpiredNotificationEnabled ? sessionExpiredCaption
                : null);
    }

    /**
     * @return "Take note of any unsaved data, and <u>click here</u> to
     *         continue."
     */
    public String getSessionExpiredMessage() {
        return (sessionExpiredNotificationEnabled ? sessionExpiredMessage
                : null);
    }

    /**
     * @return null to reload the application after communication error message.
     */
    public String getCommunicationErrorURL() {
        return communicationErrorURL;
    }

    /**
     * @return true to show the communication error message.
     */
    public boolean isCommunicationErrorNotificationEnabled() {
        return communicationErrorNotificationEnabled;
    }

    /**
     * @return "Communication problem"
     */
    public String getCommunicationErrorCaption() {
        return (communicationErrorNotificationEnabled
                ? communicationErrorCaption
                : null);
    }

    /**
     * @return "Take note of any unsaved data, and <u>click here</u> to
     *         continue."
     */
    public String getCommunicationErrorMessage() {
        return (communicationErrorNotificationEnabled
                ? communicationErrorMessage
                : null);
    }

    /**
     * @return null to reload the application after authentication error
     *         message.
     */
    public String getAuthenticationErrorURL() {
        return authenticationErrorURL;
    }

    /**
     * @return true to show the authentication error message.
     */
    public boolean isAuthenticationErrorNotificationEnabled() {
        return authenticationErrorNotificationEnabled;
    }

    /**
     * @return "Authentication problem"
     */
    public String getAuthenticationErrorCaption() {
        return (authenticationErrorNotificationEnabled
                ? authenticationErrorCaption
                : null);
    }

    /**
     * @return "Take note of any unsaved data, and <u>click here</u> to
     *         continue."
     */
    public String getAuthenticationErrorMessage() {
        return (authenticationErrorNotificationEnabled
                ? authenticationErrorMessage
                : null);
    }

    /**
     * @return null to reload the current URL after internal error message has
     *         been shown.
     */
    public String getInternalErrorURL() {
        return internalErrorURL;
    }

    /**
     * @return true to enable showing of internal error message.
     */
    public boolean isInternalErrorNotificationEnabled() {
        return internalErrorNotificationEnabled;
    }

    /**
     * @return "Internal error"
     */
    public String getInternalErrorCaption() {
        return (internalErrorNotificationEnabled ? internalErrorCaption : null);
    }

    /**
     * @return "Please notify the administrator.<br/>
     *         Take note of any unsaved data, and <u>click here</u> to
     *         continue."
     */
    public String getInternalErrorMessage() {
        return (internalErrorNotificationEnabled ? internalErrorMessage : null);
    }

    /**
     * Returns the URL the user should be redirected to after dismissing the
     * "you have to enable your cookies" message. Typically null.
     *
     * @return A URL the user should be redirected to after dismissing the
     *         message or null to reload the current URL.
     */
    public String getCookiesDisabledURL() {
        return cookiesDisabledURL;
    }

    /**
     * Determines if "cookies disabled" messages should be shown to the end user
     * or not. If the notification is disabled the user will be immediately
     * redirected to the URL returned by {@link #getCookiesDisabledURL()}.
     *
     * @return true to show "cookies disabled" messages to the end user, false
     *         to redirect to the given URL directly
     */
    public boolean isCookiesDisabledNotificationEnabled() {
        return cookiesDisabledNotificationEnabled;
    }

    /**
     * Returns the caption of the message shown to the user when cookies are
     * disabled in the browser.
     *
     * @return The caption of the "cookies disabled" message
     */
    public String getCookiesDisabledCaption() {
        return (cookiesDisabledNotificationEnabled ? cookiesDisabledCaption
                : null);
    }

    /**
     * Returns the message shown to the user when cookies are disabled in the
     * browser.
     *
     * @return The "cookies disabled" message
     */
    public String getCookiesDisabledMessage() {
        return (cookiesDisabledNotificationEnabled ? cookiesDisabledMessage
                : null);
    }

}