Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java @ 1338:c730f0438510
Set window position to page center.
flys-client/trunk@2983 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 17 Oct 2011 10:22:19 +0000 |
parents | ec5c75da5c7a |
children | ab8eb2f544f2 |
rev | line source |
---|---|
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Document; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import de.intevation.artifacts.common.utils.XMLUtils; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.httpclient.http.HttpClient; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
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:
71
diff
changeset
|
16 import de.intevation.flys.client.shared.exceptions.ServerException; |
71
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
17 import de.intevation.flys.client.shared.model.Collection; |
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
18 import de.intevation.flys.client.shared.model.DefaultCollection; |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.flys.client.client.services.CreateCollectionService; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 /** |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * This interface provides the createCollection service to create new |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * collections in the artifact server. |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 * |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 */ |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 public class CreateCollectionServiceImpl |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 extends RemoteServiceServlet |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 implements CreateCollectionService |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 { |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 /** XPath to figure out the uuid of the created collection.*/ |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public static final String XPATH_COLLECTION_UUID = |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 "/art:result/art:artifact-collection/@art:uuid"; |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
587
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
36 /** XPath to figure out the ttl of the created collection.*/ |
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
37 public static final String XPATH_COLLECTION_TTL = |
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
38 "/art:result/art:artifact-collection/@art:ttl"; |
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
39 |
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:
71
diff
changeset
|
40 /** Error message key that is thrown if an error occured while creating |
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:
71
diff
changeset
|
41 * a new 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:
71
diff
changeset
|
42 public static final String ERROR_CREATE_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:
71
diff
changeset
|
43 "error_create_collection"; |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
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:
71
diff
changeset
|
45 |
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
|
46 public Collection create(String serverUrl, String locale, String ownerId) |
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:
71
diff
changeset
|
47 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:
71
diff
changeset
|
48 { |
71
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
49 System.out.println("Start creating a new collection."); |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
71
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
51 Document create = |
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
52 ClientProtocolUtils.newCreateCollectionDocument(null); |
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
|
53 HttpClient client = new HttpClientImpl(serverUrl, locale); |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 try { |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 Document doc = (Document) client.createCollection( |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 create, ownerId, new DocumentResponseHandler()); |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
71
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
59 String uuid = XMLUtils.xpathString( |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 doc, XPATH_COLLECTION_UUID, ArtifactNamespaceContext.INSTANCE); |
71
987567f31200
Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
26
diff
changeset
|
61 |
587
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
62 String ttlStr = XMLUtils.xpathString( |
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
63 doc, XPATH_COLLECTION_TTL, ArtifactNamespaceContext.INSTANCE); |
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
64 |
53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
65 if (uuid.trim().length() == 0 || ttlStr.length() == 0) { |
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:
71
diff
changeset
|
66 throw new ServerException(ERROR_CREATE_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:
71
diff
changeset
|
67 } |
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:
71
diff
changeset
|
68 |
856
ec5c75da5c7a
Bugfix flys/issue166: Parse Collection names from DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
587
diff
changeset
|
69 return new DefaultCollection(uuid, Long.valueOf(ttlStr), uuid); |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 } |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 catch (ConnectionException ce) { |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 System.err.println(ce.getLocalizedMessage()); |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 } |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
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:
71
diff
changeset
|
75 throw new ServerException(ERROR_CREATE_COLLECTION); |
26
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 } |
c19985f75118
Implemented a service that triggers the artifact-collection creation in the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |