diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2015-02-17 10:20:41 +0200 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2015-02-17 10:20:41 +0200 |
commit | a6d629529d79def3f1f211168433c3f7553256ad (patch) | |
tree | 7991cd443a50e9559fe8ad922e31c1af046866bf /server/src/com | |
parent | c417195029fe79dd6c60413f998731877c534d51 (diff) | |
download | vaadin-framework-a6d629529d79def3f1f211168433c3f7553256ad.tar.gz vaadin-framework-a6d629529d79def3f1f211168433c3f7553256ad.zip |
Refactor critical notifications handling. (#16592)
Change-Id: I235804a80b1d70a564a54953b9255416a7386fe6
Diffstat (limited to 'server/src/com')
-rw-r--r-- | server/src/com/vaadin/server/VaadinService.java | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 2aaab31dd1..be4dd045be 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -1574,30 +1574,11 @@ public abstract class VaadinService implements Serializable { String message, String details, String url) { String returnString = ""; try { - if (message == null) { - message = details; - } else if (details != null) { - message += "<br/><br/>" + details; - } - JsonObject appError = Json.createObject(); - if (caption == null) { - appError.put("caption", Json.createNull()); - } else { - appError.put("caption", caption); - } - - if (message == null) { - appError.put("message", Json.createNull()); - } else { - appError.put("message", message); - } - - if (url == null) { - appError.put("url", Json.createNull()); - } else { - appError.put("url", url); - } + putValueOrJsonNull(appError, "caption", caption); + putValueOrJsonNull(appError, "url", url); + putValueOrJsonNull(appError, "message", + createCriticalNotificationMessage(message, details)); JsonObject meta = Json.createObject(); meta.put("appError", appError); @@ -1617,6 +1598,24 @@ public abstract class VaadinService implements Serializable { return "for(;;);[" + returnString + "]"; } + private static String createCriticalNotificationMessage(String message, String details) { + if(message == null) { + return details; + } else if(details != null) { + return message + "<br/><br/>" + details; + } + + return message; + } + + private static void putValueOrJsonNull(JsonObject json, String key, String value) { + if(value == null) { + json.put(key, Json.createNull()); + } else { + json.put(key, value); + } + } + /** * @deprecated As of 7.0. Will likely change or be removed in a future * version |