Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/UserServiceImpl.java @ 217:907b61e4d702
Improved the exception handling - added warnings for user authentication errors and errors that occur while fetching supported rivers.
flys-client/trunk@1659 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 08 Apr 2011 10:05:14 +0000 |
parents | d573ae975330 |
children | 924da6695800 |
comparison
equal
deleted
inserted
replaced
216:4b0fb079ead9 | 217:907b61e4d702 |
---|---|
14 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | 14 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
15 import de.intevation.artifacts.httpclient.http.HttpClient; | 15 import de.intevation.artifacts.httpclient.http.HttpClient; |
16 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | 16 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
17 | 17 |
18 import de.intevation.flys.client.client.services.UserService; | 18 import de.intevation.flys.client.client.services.UserService; |
19 import de.intevation.flys.client.shared.exceptions.AuthenticationException; | |
19 import de.intevation.flys.client.shared.model.DefaultUser; | 20 import de.intevation.flys.client.shared.model.DefaultUser; |
20 import de.intevation.flys.client.shared.model.User; | 21 import de.intevation.flys.client.shared.model.User; |
21 | 22 |
22 | 23 |
23 /** | 24 /** |
25 */ | 26 */ |
26 public class UserServiceImpl | 27 public class UserServiceImpl |
27 extends RemoteServiceServlet | 28 extends RemoteServiceServlet |
28 implements UserService | 29 implements UserService |
29 { | 30 { |
30 public User getCurrentUser(String serverUrl) { | 31 public static final String ERROR_NO_SUCH_USER = "error_no_such_user"; |
32 | |
33 public User getCurrentUser(String serverUrl) | |
34 throws AuthenticationException | |
35 { | |
31 HttpClient client = new HttpClientImpl(serverUrl); | 36 HttpClient client = new HttpClientImpl(serverUrl); |
32 | 37 |
33 try { | 38 try { |
34 Document users = (Document) client.listUsers(); | 39 Document users = (Document) client.listUsers(); |
35 | 40 |
55 catch (ConnectionException ce) { | 60 catch (ConnectionException ce) { |
56 System.err.println(ce.getLocalizedMessage()); | 61 System.err.println(ce.getLocalizedMessage()); |
57 } | 62 } |
58 | 63 |
59 System.err.println("No users existing in the server."); | 64 System.err.println("No users existing in the server."); |
60 return null; | 65 throw new AuthenticationException(ERROR_NO_SUCH_USER); |
61 } | 66 } |
62 } | 67 } |
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 68 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |