Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java @ 223:964abeb76771
Added more i18n error messages.
flys-client/trunk@1668 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 12 Apr 2011 10:51:39 +0000 |
parents | e02f50a3ad59 |
children | 924da6695800 |
rev | line source |
---|---|
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Document; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.httpclient.http.HttpClient; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
12 import de.intevation.flys.client.shared.exceptions.ServerException; |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.flys.client.shared.model.Artifact; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.flys.client.shared.model.Collection; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.client.client.services.AddArtifactService; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 /** |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 */ |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public class AddArtifactServiceImpl |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
87
diff
changeset
|
22 extends DescribeCollectionServiceImpl |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 implements AddArtifactService |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 { |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
25 public static final String ERROR_ADD_ARTIFACT = "error_add_artifact"; |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
26 |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
27 public Collection add(Collection collection, Artifact artifact, String url) |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
28 throws ServerException |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
29 { |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
87
diff
changeset
|
30 System.out.println("AddArtifactServiceImpl.add"); |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 Document add = ClientProtocolUtils.newAddArtifactDocument( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 artifact.getUuid(), null); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 HttpClient client = new HttpClientImpl(url); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 try { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 Document response = (Document) client.doCollectionAction( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 add, collection.identifier(), new DocumentResponseHandler()); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 Collection c = parseCollection(response); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 if (c == null) { |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
44 throw new ServerException(ERROR_ADD_ARTIFACT); |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 return c; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 catch (ConnectionException ce) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 System.err.println(ce.getLocalizedMessage()); |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
51 |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
54 throw new ServerException(ERROR_ADD_ARTIFACT); |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |