Mercurial > dive4elements > http-client
annotate src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 7:06e9e25632cd 0.1
Added a method to the HttpClient to list the collection of a user.
http-client/trunk@1615 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 30 Mar 2011 07:48:39 +0000 |
parents | 09a84c6e263a |
children | 072e8d488f83 |
rev | line source |
---|---|
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 /* |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 * |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 */ |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.artifacts.httpclient.http; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import java.io.InputStream; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import java.io.IOException; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import java.io.OutputStream; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import org.restlet.Client; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import org.restlet.Request; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.restlet.Response; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import org.restlet.data.MediaType; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import org.restlet.data.Method; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import org.restlet.data.Protocol; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import org.restlet.data.Status; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import org.restlet.ext.xml.DomRepresentation; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import org.restlet.representation.Representation; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import org.w3c.dom.Document; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.artifacts.httpclient.http.response.ResponseHandler; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 import de.intevation.artifacts.httpclient.http.response.StreamResponseHandler; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 import de.intevation.artifacts.httpclient.objects.Artifact; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 import de.intevation.artifacts.httpclient.objects.ArtifactFactory; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 import de.intevation.artifacts.httpclient.utils.ArtifactProtocolUtils; |
2
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
35 import de.intevation.artifacts.httpclient.utils.ArtifactCreator; |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
36 |
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 /** |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 */ |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 public class HttpClientImpl implements HttpClient { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 private static final Logger logger = Logger.getLogger(HttpClient.class); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 |
4
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
45 /** The URL part of the resource to list the existing users of the server.*/ |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
46 public static final String PATH_LIST_USERS = "/list-users"; |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
47 |
7
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
48 /** The URL part of the resource to list the Collections owned by a specific |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
49 * user.*/ |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
50 public static final String PATH_USER_COLLECTIONS = "/list-collections"; |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
51 |
5
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
52 /** The URL part of the resource to call a specific service.*/ |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
53 public static final String PATH_SERVICE = "/service"; |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
54 |
3
19a617578b88
Added a new method to the HttpClient that triggers the creation of a new artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
55 /** The URL path of the resource to create new artifact collections.*/ |
19a617578b88
Added a new method to the HttpClient that triggers the creation of a new artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
56 public static final String PATH_CREATE_COLLECTION = "/create-collection"; |
19a617578b88
Added a new method to the HttpClient that triggers the creation of a new artifact collection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2
diff
changeset
|
57 |
6
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
58 /** The URL path of the resource to work with an artifact collections.*/ |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
59 public static final String PATH_ACTION_COLLECTION = "/collection"; |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
60 |
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 private String serverUrl; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 public HttpClientImpl(String serverUrl) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 this.serverUrl = serverUrl; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 @Override |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 public ArtifactFactory[] getArtifactFactories() |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 throws ConnectionException |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 ResponseHandler handler = new DocumentResponseHandler(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 try { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 String url = serverUrl + "/factories"; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 Document result = (Document) handler.handle(doGet(url)); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 return ArtifactProtocolUtils.extractArtifactFactories(result); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 catch (IOException ioe) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 throw new ConnectionException( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 "Connection to server failed. No Factories recieved."); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
2
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
88 /** |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
89 * This method creates a new artifact in the artifact server and returns |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
90 * this artifact. The new artifact is created using <i>creator</i>. If no |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
91 * {@link ArtifactCreator} is given (null), an {@link Artifact} is returned. |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
92 * |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
93 * @param doc The CREATE document. |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
94 * @param creator The {@link ArtifactCreator} that is used to extract the |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
95 * new artifact from response document of the server. |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
96 * |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
97 * @return the new artifact. |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
98 */ |
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 @Override |
2
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
100 public Object create(Document doc, ArtifactCreator creator) |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
101 throws ConnectionException |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
102 { |
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 ResponseHandler handler = new DocumentResponseHandler(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 try { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 String url = serverUrl + "/create"; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 Document result = (Document) handler.handle(doPost(url, doc)); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 |
2
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
109 return creator == null |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
110 ? ArtifactProtocolUtils.extractArtifact(result) |
2fdfa20cfa63
Added an interface that is used to create instances of artifacts depending on the framework that includes this lib. The create() method of the HttpClient makes use of this interface.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1
diff
changeset
|
111 : creator.create(result); |
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 catch (IOException ioe) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 throw new ConnectionException( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 "Connection to server failed. No Artifact created."); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 @Override |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 public Object describe( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 Artifact artifact, |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 Document doc, |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 ResponseHandler handler) |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 throws ConnectionException |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 try { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 String url = serverUrl + "/artifact/" + artifact.getUuid(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 return handler.handle(doPost(url, doc)); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 catch (IOException ioe) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 throw new ConnectionException( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 "Connection to server failed: " + ioe.getMessage()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 @Override |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 public Object feed(Artifact artifact, Document doc, ResponseHandler handler) |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 throws ConnectionException |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 try { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 String url = serverUrl + "/artifact/" + artifact.getUuid(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 Document result = (Document) handler.handle(doPost(url, doc)); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 return result; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
148 catch (IOException ioe) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
149 throw new ConnectionException( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 "Connection to server failed: " + ioe.getMessage()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 @Override |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 public Object advance(Artifact artifact, Document doc, ResponseHandler handler) |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 throws ConnectionException |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 try { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 String url = serverUrl + "/artifact/" + artifact.getUuid(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 Document result = (Document) handler.handle(doPost(url, doc)); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 return result; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 catch (IOException ioe) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 throw new ConnectionException( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 "Connection to server failed: " + ioe.getMessage()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 @Override |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 public void out( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 Artifact artifact, |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 Document doc, |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 String target, |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 OutputStream out) |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 throws ConnectionException |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 try { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 String url = |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 serverUrl |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 + "/artifact/" |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 + artifact.getUuid() |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 + "/" + target; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 ResponseHandler handler = new StreamResponseHandler(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 InputStream stream = (InputStream) handler.handle(doPost(url, doc)); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 byte[] b = new byte[4096]; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 int i = -1; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 while ((i = stream.read(b)) > 0) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 out.write(b, 0, i); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 catch (IOException ioe) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 throw new ConnectionException( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 "Connection to server failed: " + ioe.getMessage()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 private Response doPost(String url, Document body) throws IOException { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 logger.info("Start HTTP-POST request to: "+ url); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 Client client = new Client(Protocol.HTTP); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 Request request = new Request(Method.POST, url); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 Representation representation = new DomRepresentation( |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 MediaType.APPLICATION_XML, |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 body); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 request.setEntity(representation); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 Response response = client.handle(request); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
216 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
217 Status status = response.getStatus(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 if (status.getCode() != 200) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 logger.error("Response status: " + status.getCode()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 throw new IOException(status.getDescription()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
221 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
222 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
223 return response; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
224 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
225 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
226 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
227 private Response doGet(String url) throws IOException { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
228 logger.info("Start HTTP-POST request to: "+ url); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
229 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
230 Client client = new Client(Protocol.HTTP); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
231 Request request = new Request(Method.GET, url); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
232 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
233 Response response = client.handle(request); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
234 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
235 Status status = response.getStatus(); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
236 if (status.getCode() != 200) { |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
237 logger.error("Response status: " + status.getCode()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
238 throw new IOException(status.getDescription()); |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
239 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
240 |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
241 return response; |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
242 } |
4
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
243 |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
244 |
6
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
245 //============================== |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
246 // Collection API |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
247 //============================== |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
248 |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
249 /** |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
250 * This method triggers the artifact servers resource to create a new |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
251 * artifact collection. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
252 * |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
253 * @param create The CREATE document for the collection. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
254 * @param ownerId The uuid of the creator. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
255 * @param handler The handler that is used to create the result object. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
256 * |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
257 * @return a result object created by <i>handler</i>. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
258 */ |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
259 public Object createCollection( |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
260 Document create, |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
261 String ownerId, |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
262 ResponseHandler handler) |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
263 throws ConnectionException |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
264 { |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
265 String url = serverUrl + PATH_CREATE_COLLECTION + "/" + ownerId; |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
266 |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
267 try { |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
268 return handler.handle(doPost(url, create)); |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
269 } |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
270 catch (IOException ioe) { |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
271 throw new ConnectionException(ioe.getMessage(), ioe); |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
272 } |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
273 } |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
274 |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
275 |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
276 /** |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
277 * This method might be used to trigger a collection specific action. The |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
278 * action that is executed depends on the document <i>actionDoc</i>. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
279 * |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
280 * @param actionDoc The document that describes the action to be executed. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
281 * @param uuid The uuid of the collection. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
282 * @param handler The handler that is used to create the result object. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
283 * |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
284 * @return a result object created by <i>handler</i>. |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
285 */ |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
286 public Object doCollectionAction( |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
287 Document actionDoc, |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
288 String uuid, |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
289 ResponseHandler handler) |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
290 throws ConnectionException |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
291 { |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
292 String url = serverUrl + PATH_ACTION_COLLECTION + "/" + uuid; |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
293 |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
294 try { |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
295 return handler.handle(doPost(url, actionDoc)); |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
296 } |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
297 catch (IOException ioe) { |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
298 throw new ConnectionException(ioe.getMessage(), ioe); |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
299 } |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
300 } |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
301 |
09a84c6e263a
Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
5
diff
changeset
|
302 |
4
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
303 /******************************* |
5
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
304 * Service API |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
305 *******************************/ |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
306 |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
307 public Document callService(String url, String service, Document input) |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
308 throws ConnectionException |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
309 { |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
310 logger.info("Start service call to '" + service + "'"); |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
311 |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
312 DocumentResponseHandler handler = new DocumentResponseHandler(); |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
313 |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
314 try { |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
315 String serverUrl = url + PATH_SERVICE + "/" + service; |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
316 return (Document) handler.handle(doPost(serverUrl, input)); |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
317 } |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
318 catch (IOException ioe) { |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
319 throw new ConnectionException( |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
320 "Connection to server failed: " + ioe.getMessage()); |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
321 } |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
322 } |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
323 |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
324 |
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
325 /******************************* |
4
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
326 * Users API |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
327 *******************************/ |
5
7917c21fad01
Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4
diff
changeset
|
328 |
4
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
329 public Document listUsers() |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
330 throws ConnectionException |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
331 { |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
332 ResponseHandler handler = new DocumentResponseHandler(); |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
333 String url = serverUrl + PATH_LIST_USERS; |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
334 |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
335 try { |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
336 return (Document) handler.handle(doGet(url)); |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
337 } |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
338 catch (IOException ioe) { |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
339 throw new ConnectionException(ioe.getMessage(), ioe); |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
340 } |
19b3ba7f2568
Added a method to the http client to list the existing users of the artifact database.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3
diff
changeset
|
341 } |
7
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
342 |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
343 |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
344 public Document listUserCollections(String userid) |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
345 throws ConnectionException |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
346 { |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
347 ResponseHandler handler = new DocumentResponseHandler(); |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
348 |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
349 String url = serverUrl + PATH_USER_COLLECTIONS + "/" + userid; |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
350 |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
351 try { |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
352 return (Document) handler.handle(doGet(url)); |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
353 } |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
354 catch (IOException ioe) { |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
355 throw new ConnectionException(ioe.getMessage(), ioe); |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
356 } |
06e9e25632cd
Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
6
diff
changeset
|
357 } |
1
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
358 } |
c9ac6642973c
Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
359 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |