Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java @ 1320:5733c05ce24c
Added removeArtifact CollectionHelper method.
flys-client/trunk@2961 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 13 Oct 2011 12:30:08 +0000 |
parents | 478a571f1f94 |
children | ab8eb2f544f2 |
rev | line source |
---|---|
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Document; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.httpclient.http.HttpClient; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
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
|
14 import de.intevation.flys.client.shared.exceptions.ServerException; |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.flys.client.shared.model.Collection; |
905
478a571f1f94
Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
856
diff
changeset
|
16 |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.flys.client.client.services.DescribeCollectionService; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 /** |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 * This service implements a method that queries the DESCRIBE document of a |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 * specific collection and returns a Collection object with the information of |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * the document. |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 */ |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 public class DescribeCollectionServiceImpl |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 extends RemoteServiceServlet |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 implements DescribeCollectionService |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 { |
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
|
31 /** The error message key that is thrown if an error occured while |
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
|
32 * describe() a Collection.*/ |
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
|
33 public static final String ERROR_DESCRIBE_COLLECTION = |
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
|
34 "error_describe_collection"; |
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
|
35 |
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
|
36 |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
37 public Collection describe(String uuid, String serverUrl, String locale) |
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
|
38 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
|
39 { |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 System.out.println("DescribeCollectionServiceImpl.describe"); |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 Document describe = ClientProtocolUtils.newDescribeCollectionDocument( |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 uuid); |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
45 HttpClient client = new HttpClientImpl(serverUrl, locale); |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 try { |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 Document response = (Document) client.doCollectionAction( |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 describe, uuid, new DocumentResponseHandler()); |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
905
478a571f1f94
Refactored server code - HTTP related code moved to ArtifactsHelper and CollectionHelper which makes us able to combine Artifact and Collection protocol stuff in a single RPC service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
856
diff
changeset
|
51 Collection c = CollectionHelper.parseCollection(response); |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 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
|
54 throw new ServerException(ERROR_DESCRIBE_COLLECTION); |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
524
ba238f917b94
The theme list information stored in the attribute of a collection is read and added in form of Themes and ThemeLists to the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
270
diff
changeset
|
57 System.out.println("Collection successfully parsed."); |
ba238f917b94
The theme list information stored in the attribute of a collection is read and added in form of Themes and ThemeLists to the Collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
270
diff
changeset
|
58 |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 return c; |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 } |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 catch (ConnectionException ce) { |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 System.err.println(ce.getLocalizedMessage()); |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 } |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
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
|
65 throw new ServerException(ERROR_DESCRIBE_COLLECTION); |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 } |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 } |
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |