Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java @ 103:deaa50a8be82
Removed some out commented code that have been commited by mistaken.
flys-client/trunk@1620 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 30 Mar 2011 08:35:50 +0000 |
parents | f7967d12ce6e |
children | e02f50a3ad59 |
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 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 |
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 * @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
|
19 */ |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 public class AddArtifactServiceImpl |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
87
diff
changeset
|
21 extends DescribeCollectionServiceImpl |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 implements AddArtifactService |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 public Collection add(Collection collection, Artifact artifact, String url) { |
99
5c3d685546a6
Added a new service to describe collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
87
diff
changeset
|
25 System.out.println("AddArtifactServiceImpl.add"); |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 Document add = ClientProtocolUtils.newAddArtifactDocument( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 artifact.getUuid(), null); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 HttpClient client = new HttpClientImpl(url); |
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 try { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 Document response = (Document) client.doCollectionAction( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 add, collection.identifier(), new DocumentResponseHandler()); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 Collection c = parseCollection(response); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 if (c == null) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 throw new NullPointerException("No collection returned."); |
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 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 return c; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 catch (ConnectionException ce) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 System.err.println(ce.getLocalizedMessage()); |
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 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |