File: 90-backport_failedauth_explaination.patch

package info (click to toggle)
josm 0.0.svn3376-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 53,192 kB
  • ctags: 15,964
  • sloc: java: 109,690; xml: 7,599; perl: 821; makefile: 51; sh: 21
file content (57 lines) | stat: -rw-r--r-- 2,174 bytes parent folder | download
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
From: David Paleino <dapal@debian.org>
Subject: backport fixed failed authorisation dialog from 4021
Origin: vendor
Forwarded: not-needed

---
 src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java |    3 +-
 src/org/openstreetmap/josm/tools/ExceptionUtil.java     |   24 ++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

--- josm.orig/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
+++ josm/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
@@ -271,9 +271,10 @@ public class ExceptionDialogUtil {
      * @param e the exception
      */
     public static void explainAuthorizationFailed(OsmApiException e) {
+        // Fixme: add special handling that calls ExceptionUtil.explainFailedOAuthAuthorisation(e)
         HelpAwareOptionPane.showOptionDialog(
                 Main.parent,
-                ExceptionUtil.explainFailedOAuthAuthorisation(e),
+                ExceptionUtil.explainFailedAuthorisation(e),
                 tr("Authorisation Failed"),
                 JOptionPane.ERROR_MESSAGE,
                 ht("/ErrorMessages#AuthenticationFailed")
--- josm.orig/src/org/openstreetmap/josm/tools/ExceptionUtil.java
+++ josm/src/org/openstreetmap/josm/tools/ExceptionUtil.java
@@ -128,6 +128,30 @@ public class ExceptionUtil {
         );
     }
 
+   public static String explainFailedAuthorisation(OsmApiException e) {
+        e.printStackTrace();
+        String header = e.getErrorHeader();
+        String body = e.getErrorBody();
+        String msg = null;
+        if (header != null) {
+            if (body != null && !header.equals(body)) {
+                msg = header + " (" + body + ")";
+            } else {
+                msg = header;
+            }
+        } else {
+            msg = body;
+        }
+
+        return tr("<html>"
+                + "Authorisation at the OSM server failed.<br>"
+                + "The server reported the following error:<br>"
+                + "''{0}''"
+                + "</html>",
+                msg
+        );
+    }
+
     public static String explainFailedOAuthAuthorisation(OsmApiException e) {
         e.printStackTrace();
         return tr("<html>"