annotate src/main/java/de/intevation/artifacts/httpclient/http/HttpClientImpl.java @ 11:ea8b7e244e61

Bugfix: repaired a condition that prevented setting the locale of the request object. http-client/trunk@1680 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 14 Apr 2011 07:51:51 +0000
parents e79283dad6f2
children 5b62267a1c3c
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;
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
13 import java.util.ArrayList;
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
14 import java.util.List;
1
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.apache.log4j.Logger;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.restlet.Client;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.restlet.Request;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.restlet.Response;
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
21 import org.restlet.data.ClientInfo;
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
22 import org.restlet.data.Language;
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 import org.restlet.data.MediaType;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import org.restlet.data.Method;
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
25 import org.restlet.data.Preference;
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 import org.restlet.data.Protocol;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 import org.restlet.data.Status;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 import org.restlet.ext.xml.DomRepresentation;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 import org.restlet.representation.Representation;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 import org.w3c.dom.Document;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41
1
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 /**
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 * @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
45 */
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 public class HttpClientImpl implements HttpClient {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 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
49
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
50 /** 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
51 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
52
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
53 /** 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
54 * 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
55 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
56
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
57 /** 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
58 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
59
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
60 /** 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
61 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
62
6
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
63 /** 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
64 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
65
9
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
66 /** The URL path of the resource to work with an artifact collections.*/
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
67 public static final String PATH_OUT_COLLECTION = "/collection";
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
68
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 private String serverUrl;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
71 private String localeString;
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
72
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 public HttpClientImpl(String serverUrl) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 this.serverUrl = serverUrl;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
79 /**
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
80 * This constructor might be used to modify the request's locale manually.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
81 * E.g. the localization should not be based on the configured browser
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
82 * locale, but site specific configuration - than you are able to set the
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
83 * locale in this constructor.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
84 *
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
85 * @param serverUrl The url that is used for the request.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
86 * @param localeString The string representation of the desired locale.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
87 */
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
88 public HttpClientImpl(String serverUrl, String localeString) {
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
89 this(serverUrl);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
90
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
91 this.localeString = localeString;
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
92 }
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
93
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
94
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 @Override
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96 public ArtifactFactory[] getArtifactFactories()
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 throws ConnectionException
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99 ResponseHandler handler = new DocumentResponseHandler();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 try {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 String url = serverUrl + "/factories";
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103 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
104
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 return ArtifactProtocolUtils.extractArtifactFactories(result);
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 catch (IOException ioe) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 throw new ConnectionException(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 "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
110 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 }
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
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
114 /**
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
115 * 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
116 * 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
117 * {@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
118 *
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
119 * @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
120 * @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
121 * 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
122 *
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
123 * @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
124 */
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 @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
126 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
127 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
128 {
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 ResponseHandler handler = new DocumentResponseHandler();
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 try {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 String url = serverUrl + "/create";
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133 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
134
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
135 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
136 ? 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
137 : creator.create(result);
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139 catch (IOException ioe) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140 throw new ConnectionException(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 "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
142 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144
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 @Override
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 public Object describe(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 Artifact artifact,
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 Document doc,
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150 ResponseHandler handler)
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 throws ConnectionException
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 try {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 String url = serverUrl + "/artifact/" + artifact.getUuid();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155 return handler.handle(doPost(url, doc));
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 catch (IOException ioe) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 throw new ConnectionException(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 "Connection to server failed: " + ioe.getMessage());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 }
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
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 @Override
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 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
166 throws ConnectionException
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 try {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 String url = serverUrl + "/artifact/" + artifact.getUuid();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 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
171
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172 return result;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 catch (IOException ioe) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 throw new ConnectionException(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 "Connection to server failed: " + ioe.getMessage());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 }
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
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 @Override
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 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
183 throws ConnectionException
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184 {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 try {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 String url = serverUrl + "/artifact/" + artifact.getUuid();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 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
188
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 return result;
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 catch (IOException ioe) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192 throw new ConnectionException(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 "Connection to server failed: " + ioe.getMessage());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 }
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
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 @Override
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199 public void out(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200 Artifact artifact,
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 Document doc,
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 String target,
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 OutputStream out)
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 throws ConnectionException
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 try {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207 String url =
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208 serverUrl
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 + "/artifact/"
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 + artifact.getUuid()
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 + "/" + target;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213 ResponseHandler handler = new StreamResponseHandler();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 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
216
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 byte[] b = new byte[4096];
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218 int i = -1;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 while ((i = stream.read(b)) > 0) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 out.write(b, 0, i);
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 catch (IOException ioe) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 throw new ConnectionException(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 "Connection to server failed: " + ioe.getMessage());
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 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
230 //==============================
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
231 // HTTP specific methods
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
232 //==============================
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
233
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234 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
235 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
236
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 Client client = new Client(Protocol.HTTP);
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
238 Request request = prepareRequest(Method.POST, url);
1
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 Representation representation = new DomRepresentation(
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 MediaType.APPLICATION_XML,
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242 body);
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244 request.setEntity(representation);
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 Response response = client.handle(request);
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 Status status = response.getStatus();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 if (status.getCode() != 200) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 logger.error("Response status: " + status.getCode());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 throw new IOException(status.getDescription());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 return response;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 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
258 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
259
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260 Client client = new Client(Protocol.HTTP);
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
261 Request request = prepareRequest(Method.GET, url);
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 Response response = client.handle(request);
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 Status status = response.getStatus();
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 if (status.getCode() != 200) {
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267 logger.error("Response status: " + status.getCode());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 throw new IOException(status.getDescription());
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271 return response;
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 }
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
273
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
274
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
275 /**
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
276 * This method prepares the request object.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
277 *
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
278 * @param method The HTTP method (GET,POST).
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
279 * @param url The URL used for the request.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
280 *
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
281 * @return the request object.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
282 */
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
283 private Request prepareRequest(Method method, String url) {
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
284 Request request = new Request(method, url);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
285
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
286 ClientInfo info = request.getClientInfo();
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
287
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
288 setLocale(info);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
289
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
290 request.setClientInfo(info);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
291
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
292 return request;
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
293 }
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
294
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
295
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
296 /**
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
297 * This method is called to set the request's locale.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
298 *
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
299 * @param info The ClientInfo that is used to provide request information.
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
300 */
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
301 private void setLocale(ClientInfo info) {
11
ea8b7e244e61 Bugfix: repaired a condition that prevented setting the locale of the request object.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 10
diff changeset
302 if (localeString == null) {
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
303 return;
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
304 }
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
305
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
306 List<Preference<Language>> accepted =
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
307 new ArrayList<Preference<Language>>();
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
308
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
309 Language lang = Language.valueOf(localeString);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
310
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
311 if (lang != null) {
11
ea8b7e244e61 Bugfix: repaired a condition that prevented setting the locale of the request object.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 10
diff changeset
312 logger.info("Set locale of the request object: " + lang.toString());
ea8b7e244e61 Bugfix: repaired a condition that prevented setting the locale of the request object.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 10
diff changeset
313
10
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
314 Preference<Language> pref = new Preference<Language>();
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
315 pref.setMetadata(lang);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
316 accepted.add(pref);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
317
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
318 info.setAcceptedLanguages(accepted);
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
319 }
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
320 }
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
321
e79283dad6f2 Added the option to set the request's locale manually.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 9
diff changeset
322
6
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
323 //==============================
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
324 // 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
325 //==============================
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
326
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
327 /**
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
328 * 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
329 * 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
330 *
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
331 * @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
332 * @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
333 * @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
334 *
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
335 * @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
336 */
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
337 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
338 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
339 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
340 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
341 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
342 {
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
343 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
344
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
345 try {
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
346 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
347 }
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
348 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
349 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
350 }
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
351 }
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
352
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
353
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
354 /**
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
355 * 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
356 * 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
357 *
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
358 * @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
359 * @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
360 * @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
361 *
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
362 * @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
363 */
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
364 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
365 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
366 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
367 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
368 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
369 {
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
370 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
371
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
372 try {
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
373 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
374 }
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
375 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
376 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
377 }
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
378 }
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
379
09a84c6e263a Enhanced the HttpClient with a method sto trigger a collection specific action.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 5
diff changeset
380
9
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
381 /**
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
382 * This method triggers the out() operation of a Collection. The result of
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
383 * this operation is written to <i>out</i> directly - there is no return
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
384 * value.
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
385 *
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
386 * @param doc The request document for the out() operation.
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
387 * @param uuid The identifier of the Collection.
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
388 * @param type The name of the output type.
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
389 * @param out The OutputStream.
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
390 */
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
391 public void collectionOut(
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
392 Document doc,
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
393 String uuid,
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
394 String type,
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
395 OutputStream out)
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
396 throws ConnectionException
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
397 {
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
398 String url = serverUrl + PATH_OUT_COLLECTION + "/" + uuid + "/" + type;
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
399
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
400 ResponseHandler handler = new StreamResponseHandler();
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
401
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
402 try {
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
403 InputStream stream = (InputStream) handler.handle(doPost(url, doc));
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
404
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
405 byte[] b = new byte[4096];
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
406 int i = -1;
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
407 while ((i = stream.read(b)) > 0) {
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
408 out.write(b, 0, i);
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
409 }
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
410 }
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
411 catch (IOException ioe) {
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
412 throw new ConnectionException(ioe.getMessage(), ioe);
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
413 }
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
414 }
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
415
072e8d488f83 Enhanced the HttpClient with a method to trigger the out() operation of Collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 7
diff changeset
416
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
417 /*******************************
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
418 * 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
419 *******************************/
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
420
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
421 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
422 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
423 {
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
424 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
425
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
426 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
427
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
428 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
429 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
430 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
431 }
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
432 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
433 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
434 "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
435 }
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
436 }
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
437
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
438
7917c21fad01 Enabled the HttpClient to call services that are registered at the artifact server.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 4
diff changeset
439 /*******************************
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
440 * 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
441 *******************************/
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
442
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
443 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
444 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
445 {
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
446 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
447 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
448
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
449 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
450 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
451 }
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
452 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
453 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
454 }
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
455 }
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
456
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
457
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
458 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
459 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
460 {
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
461 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
462
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
463 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
464
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
465 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
466 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
467 }
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
468 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
469 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
470 }
06e9e25632cd Added a method to the HttpClient to list the collection of a user.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 6
diff changeset
471 }
1
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
472 }
c9ac6642973c Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
473 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org