Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/RiverServiceImpl.java @ 76:1c0731f69dc6
Fixed a typo.
flys-client/trunk@1580 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 28 Mar 2011 09:14:52 +0000 |
parents | 44c63e7fd0d0 |
children | 907b61e4d702 |
rev | line source |
---|---|
29
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import javax.xml.xpath.XPathConstants; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.NodeList; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.Node; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.common.utils.XMLUtils; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.httpclient.http.HttpClient; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.shared.model.DefaultRiver; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.client.shared.model.River; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.client.services.RiverService; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 /** |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 * This interface provides a method to list the supported rivers of the artifact |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 * server. |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 * |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 */ |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public class RiverServiceImpl |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 extends RemoteServiceServlet |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 implements RiverService |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 { |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 /** The XPath string that points to the rivers in the resulting document.*/ |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 public static final String XPATH_RIVERS = "/art:rivers/art:river"; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public River[] list(String serverUrl) { |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 Document doc = XMLUtils.newDocument(); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 doc, |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 ArtifactNamespaceContext.NAMESPACE_URI, |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 ArtifactNamespaceContext.NAMESPACE_PREFIX); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 doc.appendChild(ec.create("action")); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 HttpClient client = new HttpClientImpl(serverUrl); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 try { |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 Document res = client.callService(serverUrl, "rivers", doc); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 NodeList rivers = (NodeList) XMLUtils.xpath( |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 res, |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 XPATH_RIVERS, |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 XPathConstants.NODESET, |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 ArtifactNamespaceContext.INSTANCE); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 int count = rivers.getLength(); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 List<River> theRivers = new ArrayList<River>(count); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 for (int i = 0; i < count; i++) { |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 Node tmp = rivers.item(i); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 String name = XMLUtils.xpathString( |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 tmp, "@art:name", ArtifactNamespaceContext.INSTANCE); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 theRivers.add(new DefaultRiver(name)); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 } |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 return (River[]) theRivers.toArray(new River[count]); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 catch (ConnectionException ce) { |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 System.err.println(ce.getLocalizedMessage()); |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 } |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 return null; |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 } |
44c63e7fd0d0
Added a service to list the supported rivers of the artifact server. The FLYS instance serves a method that retrieves this list.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |