Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java @ 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.
flys-client/trunk@2757 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 15 Sep 2011 12:55:36 +0000 |
parents | c0105b4dc6d1 |
children | ab8eb2f544f2 |
comparison
equal
deleted
inserted
replaced
904:1e08a5b0add9 | 905:478a571f1f94 |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | |
3 import org.w3c.dom.Document; | |
4 | |
5 import de.intevation.artifacts.common.utils.ClientProtocolUtils; | |
6 | |
7 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; | |
8 import de.intevation.artifacts.httpclient.http.HttpClient; | |
9 import de.intevation.artifacts.httpclient.http.HttpClientImpl; | |
10 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; | |
11 | 2 |
12 import de.intevation.flys.client.shared.exceptions.ServerException; | 3 import de.intevation.flys.client.shared.exceptions.ServerException; |
13 import de.intevation.flys.client.shared.model.Artifact; | 4 import de.intevation.flys.client.shared.model.Artifact; |
14 import de.intevation.flys.client.shared.model.Collection; | 5 import de.intevation.flys.client.shared.model.Collection; |
15 import de.intevation.flys.client.client.services.AddArtifactService; | 6 import de.intevation.flys.client.client.services.AddArtifactService; |
20 */ | 11 */ |
21 public class AddArtifactServiceImpl | 12 public class AddArtifactServiceImpl |
22 extends DescribeCollectionServiceImpl | 13 extends DescribeCollectionServiceImpl |
23 implements AddArtifactService | 14 implements AddArtifactService |
24 { | 15 { |
25 public static final String ERROR_ADD_ARTIFACT = "error_add_artifact"; | |
26 | |
27 public Collection add( | 16 public Collection add( |
28 Collection collection, | 17 Collection collection, |
29 Artifact artifact, | 18 Artifact artifact, |
30 String url, | 19 String url, |
31 String locale) | 20 String locale) |
32 throws ServerException | 21 throws ServerException |
33 { | 22 { |
34 System.out.println("AddArtifactServiceImpl.add"); | 23 System.out.println("AddArtifactServiceImpl.add"); |
35 | 24 |
36 Document add = ClientProtocolUtils.newAddArtifactDocument( | 25 return CollectionHelper.addArtifact(collection, artifact, url, locale); |
37 artifact.getUuid(), null); | |
38 | |
39 HttpClient client = new HttpClientImpl(url, locale); | |
40 | |
41 try { | |
42 Document response = (Document) client.doCollectionAction( | |
43 add, collection.identifier(), new DocumentResponseHandler()); | |
44 | |
45 Collection c = parseCollection(response); | |
46 | |
47 if (c == null) { | |
48 throw new ServerException(ERROR_ADD_ARTIFACT); | |
49 } | |
50 | |
51 return c; | |
52 } | |
53 catch (ConnectionException ce) { | |
54 System.err.println(ce.getLocalizedMessage()); | |
55 } | |
56 | |
57 throw new ServerException(ERROR_ADD_ARTIFACT); | |
58 } | 26 } |
59 } | 27 } |
60 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 28 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |