comparison src/main/java/de/intevation/artifacts/httpclient/ConsoleClient.java @ 1:c9ac6642973c

Renamed GNVClient and GNVClientImpl to HttpClient and HttpClientImpl. http-client/trunk@1324 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Feb 2011 10:51:37 +0000
parents a1db30b33f43
children 2fdfa20cfa63
comparison
equal deleted inserted replaced
0:a1db30b33f43 1:c9ac6642973c
28 import org.w3c.dom.NodeList; 28 import org.w3c.dom.NodeList;
29 29
30 import org.apache.log4j.Logger; 30 import org.apache.log4j.Logger;
31 import org.apache.log4j.PropertyConfigurator; 31 import org.apache.log4j.PropertyConfigurator;
32 32
33 import de.intevation.artifacts.httpclient.http.GNVClient; 33 import de.intevation.artifacts.httpclient.http.HttpClient;
34 import de.intevation.artifacts.httpclient.http.GNVClientImpl; 34 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
35 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; 35 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
36 36
37 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; 37 import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
38 import de.intevation.artifacts.httpclient.exceptions.NoSuchOptionException; 38 import de.intevation.artifacts.httpclient.exceptions.NoSuchOptionException;
39 import de.intevation.artifacts.httpclient.objects.Artifact; 39 import de.intevation.artifacts.httpclient.objects.Artifact;
119 } 119 }
120 120
121 121
122 public static void main( String[] args ) 122 public static void main( String[] args )
123 { 123 {
124 logger.info("Starting GNV console client."); 124 logger.info("Starting console client.");
125 125
126 Configuration conf = readConfiguration(); 126 Configuration conf = readConfiguration();
127 127
128 String serverHost = (String) conf.getServerSettings("host"); 128 String serverHost = (String) conf.getServerSettings("host");
129 String serverPort = (String) conf.getServerSettings("port"); 129 String serverPort = (String) conf.getServerSettings("port");
130 GNVClient client = new GNVClientImpl(serverHost + ":" + serverPort); 130 HttpClient client = new HttpClientImpl(serverHost + ":" + serverPort);
131 131
132 try { 132 try {
133 Document create = ArtifactProtocolUtils.createCreateDocument( 133 Document create = ArtifactProtocolUtils.createCreateDocument(
134 (String) conf.getArtifactSettings("fis")); 134 (String) conf.getArtifactSettings("fis"));
135 Artifact artifact = client.create(create); 135 Artifact artifact = client.create(create);
199 catch (IOException ioe) { 199 catch (IOException ioe) {
200 logger.error( 200 logger.error(
201 "IO error while writing the output: " + ioe.getMessage()); 201 "IO error while writing the output: " + ioe.getMessage());
202 } 202 }
203 203
204 logger.debug("Finished GNV console client."); 204 logger.debug("Finished console client.");
205 } 205 }
206 catch (ConnectionException ce) { 206 catch (ConnectionException ce) {
207 logger.error(ce.getMessage()); 207 logger.error(ce.getMessage());
208 } 208 }
209 catch (NoSuchOptionException nsoe) { 209 catch (NoSuchOptionException nsoe) {
212 } 212 }
213 } 213 }
214 214
215 215
216 public static void feedAndGo( 216 public static void feedAndGo(
217 GNVClient client, 217 HttpClient client,
218 Artifact artifact, 218 Artifact artifact,
219 Map attr, 219 Map attr,
220 String target) 220 String target)
221 throws ConnectionException 221 throws ConnectionException
222 { 222 {
235 * XXX I think, this method should be implemented somewhere else to be able 235 * XXX I think, this method should be implemented somewhere else to be able
236 * to re-use this implementation. But this method needs more work to be more 236 * to re-use this implementation. But this method needs more work to be more
237 * abstract, so it needs to be reimplemented later, I think. 237 * abstract, so it needs to be reimplemented later, I think.
238 */ 238 */
239 public static String[] extractOptions( 239 public static String[] extractOptions(
240 GNVClient client, 240 HttpClient client,
241 Artifact artifact, 241 Artifact artifact,
242 String text) 242 String text)
243 throws NoSuchOptionException, ConnectionException 243 throws NoSuchOptionException, ConnectionException
244 { 244 {
245 Document describe = ArtifactProtocolUtils.createDescribeDocument( 245 Document describe = ArtifactProtocolUtils.createDescribeDocument(
297 * configuration from describe document. Currently, this is a special case 297 * configuration from describe document. Currently, this is a special case
298 * that should be handled the same way as all the other options in the 298 * that should be handled the same way as all the other options in the
299 * describe document. 299 * describe document.
300 */ 300 */
301 public static String[] extractMeasurements( 301 public static String[] extractMeasurements(
302 GNVClient client, 302 HttpClient client,
303 Artifact artifact, 303 Artifact artifact,
304 String text) 304 String text)
305 throws NoSuchOptionException, ConnectionException 305 throws NoSuchOptionException, ConnectionException
306 { 306 {
307 Document describe = ArtifactProtocolUtils.createDescribeDocument( 307 Document describe = ArtifactProtocolUtils.createDescribeDocument(

http://dive4elements.wald.intevation.org