Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java @ 165:183850730a90
Made all Interfaces Serailizable and add UID to all Objects issue71
Organize Imports
gnv/trunk@328 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Thu, 12 Nov 2009 11:03:11 +0000 |
parents | 5570d9b3282f |
children | 4ec95d586f31 |
rev | line source |
---|---|
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
1 /** |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
2 * |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
3 */ |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
4 package de.intevation.gnv.artifactdatabase.client; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
5 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
6 import java.io.IOException; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
7 import java.io.InputStream; |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
8 import java.io.OutputStream; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 import java.util.ArrayList; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 import java.util.Collection; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
11 import java.util.HashMap; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 import java.util.Iterator; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
13 import java.util.Map; |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
14 import java.util.List; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
15 import java.util.Locale; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
18 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import org.restlet.Client; |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
20 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 import org.restlet.data.Method; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 import org.restlet.data.Protocol; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import org.restlet.data.Request; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 import org.restlet.data.Response; |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
25 import org.restlet.data.Preference; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
26 import org.restlet.data.Language; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
27 import org.restlet.data.ClientInfo; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
28 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
29 import org.restlet.representation.Representation; |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
30 import org.restlet.representation.StringRepresentation; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
31 import org.w3c.dom.Document; |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
32 import org.w3c.dom.Element; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 import org.w3c.dom.Node; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 import org.w3c.dom.NodeList; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
35 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
36 import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException; |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
37 import de.intevation.gnv.artifactdatabase.objects.Artifact; |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
38 import de.intevation.gnv.artifactdatabase.objects.ArtifactDescription; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
39 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
40 import de.intevation.gnv.artifactdatabase.objects.ArtifactObject; |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
41 import de.intevation.gnv.artifactdatabase.objects.ArtifactStatisticsSet; |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
42 import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticValue; |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
43 import de.intevation.gnv.artifactdatabase.objects.DefaultArtifactStatisticsSet; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
44 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputMode; |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
45 import de.intevation.gnv.artifactdatabase.objects.DefaultOutputParameter; |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
46 import de.intevation.gnv.artifactdatabase.objects.InputParameter; |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
47 import de.intevation.gnv.artifactdatabase.objects.OutputMode; |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
48 import de.intevation.gnv.artifactdatabase.objects.OutputParameter; |
23
b11f941f7eb2
Made ArtifactDatabase URL configurable
Tim Englich <tim.englich@intevation.de>
parents:
19
diff
changeset
|
49 import de.intevation.gnv.propertiesreader.PropertiesReader; |
b11f941f7eb2
Made ArtifactDatabase URL configurable
Tim Englich <tim.englich@intevation.de>
parents:
19
diff
changeset
|
50 import de.intevation.gnv.propertiesreader.PropertiesReaderFactory; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
51 import de.intevation.gnv.util.XMLUtils; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
52 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 /** |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 * @author Tim Englich <tim.englich@intevation.de> |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
55 * |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
56 */ |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
57 public class DefaultArtifactDatabaseClient implements ArtifactDatabaseClient { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 /** |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
59 * The URI of the namespace of the artifacts. |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
60 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
61 public final static String NAMESPACE_URI = "http://www.intevation.de/2009/artifacts"; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
62 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
63 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
64 * The XML prefix for the artifacts namespace. |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
65 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
66 public final static String NAMESPACE_PREFIX = "art"; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
67 |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
68 /** |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
69 * the logger, used to log exceptions and additonaly information |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
70 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
71 private static Logger log = Logger |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
72 .getLogger(DefaultArtifactDatabaseClient.class); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
73 |
25 | 74 /** |
75 * The Databases which could be used | |
76 */ | |
77 private static Collection<String> artifactDatabases = null; | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
78 |
25 | 79 /** |
80 * Is the Class initialized? | |
81 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 private static boolean initialized = false; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
83 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
84 /** |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
85 * Request locale |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
86 */ |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
87 private Locale locale; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
88 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
89 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
90 /** |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
91 * Constructor |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
92 */ |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 public DefaultArtifactDatabaseClient() { |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
94 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
95 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
96 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
97 /** |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
98 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getArtifactFactories() |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
99 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
100 public Collection<ArtifactObject> getArtifactFactories() |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
101 throws ArtifactDatabaseClientException { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
102 Collection<ArtifactObject> resultValues = null; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
103 if (!initialized) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
104 this.initialize(); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
105 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
106 try { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
107 log.debug("DefaultArtifactDatabaseClient.getArtifactFactories"); |
25 | 108 Iterator<String> it = artifactDatabases.iterator(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
109 while (it.hasNext()) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
110 String server = it.next(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
111 String url = server + "/factories"; |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
112 Document document = this.doGetRequest(url); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
113 if (resultValues == null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
114 resultValues = this.getArtifactFactories(document, server); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
115 } else { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
116 resultValues.addAll(this.getArtifactFactories(document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
117 server)); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
118 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
119 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
120 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
121 log.error(e, e); |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
122 throw new ArtifactDatabaseClientException(e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
123 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
124 return resultValues; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
125 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
126 |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
127 private Collection<ArtifactObject> getArtifactFactories(Document document, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
128 String server) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
129 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
130 NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
131 "/result/factories/factory"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
132 Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
133 artifactFactories.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
134 if (artifactFactories != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
135 for (int i = 0; i < artifactFactories.getLength(); i++) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
136 Node artifactFactoryNode = artifactFactories.item(i); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
137 String name = xmlUtils.getStringXPath(artifactFactoryNode, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
138 "@name"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
139 String description = xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
140 artifactFactoryNode, "@description"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
141 ArtifactFactory artifactFactory = new ArtifactFactory(name, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
142 description, server); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
143 resultValues.add(artifactFactory); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
144 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
145 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
146 return resultValues; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
147 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
148 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
149 /** |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
150 * @throws IOException |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
151 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
152 private Document doGetRequest(String requestUrl) throws IOException, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
153 ArtifactDatabaseClientException { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
154 return this.doGetRequest(requestUrl, null); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
155 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
156 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
157 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
158 * @throws IOException |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
159 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
160 private Document doGetRequest(String requestUrl, Document requestBody) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
161 throws IOException, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
162 ArtifactDatabaseClientException { |
25 | 163 XMLUtils xmlUtils = new XMLUtils(); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
164 Representation output = doGetRequestInternal(requestUrl, requestBody); |
25 | 165 Document document = xmlUtils.readDocument(output.getStream()); |
166 this.check4ExceptionReport(document); | |
167 return document; | |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
168 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
169 |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
170 protected Request initialize(Request request) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
171 return initialize(request, locale); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
172 } |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
173 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
174 protected Request initialize(Request request, Locale locale) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
175 if (locale != null) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
176 ClientInfo clientInfo = request.getClientInfo(); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
177 String lang = locale.getLanguage(); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
178 Language language = new Language(lang); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
179 List<Preference<Language>> acceptedLanguages = |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
180 new ArrayList<Preference<Language>>(2); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
181 acceptedLanguages.add(new Preference(language, 1.0f)); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
182 acceptedLanguages.add(new Preference(Language.ALL, 0.5f)); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
183 clientInfo.setAcceptedLanguages(acceptedLanguages); |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
184 } |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
185 return request; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
186 } |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
187 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
188 /** |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
189 * @param requestUrl |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
190 * @param requestBody |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
191 * @return |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
192 */ |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
193 private Representation doGetRequestInternal(String requestUrl, |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
194 Document requestBody) throws IOException { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
195 Client client = new Client(Protocol.HTTP); |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
196 Request request = initialize(new Request(Method.GET, requestUrl)); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
197 if (requestBody != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
198 String documentBody = new XMLUtils() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
199 .writeDocument2String(requestBody); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
200 Representation representation = new StringRepresentation( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
201 documentBody); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
202 request.setEntity(representation); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
203 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
204 Response response = client.handle(request); |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
205 if (response.getStatus().getCode() != 200){ |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
206 throw new IOException(response.getStatus().getDescription()); |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
207 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
208 Representation output = response.getEntity(); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
209 return output; |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
210 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
211 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
212 /** |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
213 * @throws IOException |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
214 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
215 private InputStream doPostRequest(String requestUrl, Document requestBody) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
216 throws IOException { |
34
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
32
diff
changeset
|
217 log.debug("##################################################"); |
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
32
diff
changeset
|
218 log.debug(new XMLUtils().writeDocument2String(requestBody)); |
25fdec8b4c69
Added Global Errorhandling to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
32
diff
changeset
|
219 log.debug("##################################################"); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
220 Client client = new Client(Protocol.HTTP); |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
221 Request request = initialize(new Request(Method.POST, requestUrl)); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
222 String documentBody = new XMLUtils().writeDocument2String(requestBody); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
223 Representation representation = new StringRepresentation(documentBody); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
224 request.setEntity(representation); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
225 Response response = client.handle(request); |
47
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
226 if (response.getStatus().getCode() != 200){ |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
227 throw new IOException(response.getStatus().getDescription()); |
f35b7d7a04d6
Read the Status-Code from the Response and throw an Exception which Message will be visualized in the GUI. gnv/issue18
Tim Englich <tim.englich@intevation.de>
parents:
40
diff
changeset
|
228 } |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
229 Representation output = response.getEntity(); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
230 return output.getStream(); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
231 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
232 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
233 private synchronized void initialize() { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
234 if (!initialized) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
235 PropertiesReader pr = PropertiesReaderFactory.getInstance() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
236 .getPropertiesReader(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
237 int count = Integer.parseInt(pr.getPropertieValue( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
238 ARTIFACTDATABASE_COUNT_ID, "0")); |
25 | 239 artifactDatabases = new ArrayList<String>(count); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
240 for (int i = 0; i < count; i++) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
241 artifactDatabases.add(pr.getPropertieValue( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
242 ARTIFACTDATABASE_URL_ID + "." + (i + 1), "N/N")); |
23
b11f941f7eb2
Made ArtifactDatabase URL configurable
Tim Englich <tim.englich@intevation.de>
parents:
19
diff
changeset
|
243 } |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
244 initialized = true; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
245 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
246 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
247 } |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
248 |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
249 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
250 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#createNewArtifact(de.intevation.gnv.artifactdatabase.objects.ArtifactObject) |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
251 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
252 public ArtifactObject createNewArtifact(ArtifactObject artifactFactory) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
253 throws ArtifactDatabaseClientException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
254 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
255 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
256 Document request = this.createCreateRequestBody(artifactFactory |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
257 .getId()); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
258 Document result = doPostRequest(artifactFactory, request, "create"); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
259 return this.getArtifact(result); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
260 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
261 log.error(e, e); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
262 throw new ArtifactDatabaseClientException(e); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
263 } |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
264 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
265 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
266 private ArtifactObject getArtifact(Document document) { |
35 | 267 XMLUtils xmlUtils = new XMLUtils(); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
268 String uuid = xmlUtils.getStringXPath(document, "/result/uuid/@value"); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
269 String hash = xmlUtils.getStringXPath(document, "/result/hash/@value"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
270 log.info("NEW Artifact: " + uuid + " / " + hash); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
271 return new Artifact(uuid, hash); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
272 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
273 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
274 private Document createCreateRequestBody(String artifactFactoryName) { |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
275 Document document = new XMLUtils().newDocument(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
276 Node rootNode = this.createRootNode(document); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
277 Element typeNode = this.createArtifactElement(document, "type"); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
278 typeNode.setAttribute("name", "create"); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
279 rootNode.appendChild(typeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
280 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
281 Element factoyNode = this.createArtifactElement(document, "factory"); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
282 factoyNode.setAttribute("name", artifactFactoryName); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
283 rootNode.appendChild(factoyNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
284 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
285 return document; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
286 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
287 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
288 private Element createRootNode(Document document) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
289 Element rootNode = this.createArtifactElement(document, "action"); |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
290 document.appendChild(rootNode); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
291 return rootNode; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
292 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
293 |
7
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
294 /** |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
295 * @param document |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
296 * @return |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
297 */ |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
298 private Element createArtifactElement(Document document, String name) { |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
299 Element node = document.createElementNS(NAMESPACE_URI, name); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
300 node.setPrefix(NAMESPACE_PREFIX); |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
301 return node; |
fe6a64545552
Support for creating an Artifact integrated
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
302 } |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
303 |
25 | 304 /** |
305 * @param artifactFactory | |
306 * @param xmlUtils | |
307 * @param request | |
308 * @throws IOException | |
309 */ | |
310 private Document doPostRequest(ArtifactObject artifactFactory, | |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
311 Document request, String suburl) |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
312 throws IOException, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
313 ArtifactDatabaseClientException { |
25 | 314 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
315 String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
316 InputStream is = this.doPostRequest(url + "/" + suburl, request); |
25 | 317 Document result = xmlUtils.readDocument(is); |
318 this.check4ExceptionReport(result); | |
319 return result; | |
320 } | |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
321 |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
322 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
323 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#getCurrentStepDescription(de.intevation.gnv.artifactdatabase.objects.ArtifactFactory, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
324 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject) |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
325 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
326 public ArtifactDescription getCurrentStepDescription( |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
327 ArtifactObject artifactFactory, |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
328 ArtifactObject currentArtifact, |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
329 boolean includeUI) |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
330 throws ArtifactDatabaseClientException { |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
331 try { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
332 String url = this.getArtifactUrl(artifactFactory, currentArtifact); |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
333 Document request = this.createDescribeRequestBody(currentArtifact, |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
334 includeUI); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
335 InputStream describeResult = this.doPostRequest(url, request); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
336 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
337 return this.readDescription(new XMLUtils().readDocument(describeResult), |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
338 currentArtifact); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
339 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
340 log.error(e, e); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
341 throw new ArtifactDatabaseClientException(e); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
342 } |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
343 } |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
344 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
345 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
346 private Document createDescribeRequestBody(ArtifactObject currentArtifact, |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
347 boolean includeUI){ |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
348 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
349 Document document = new XMLUtils().newDocument(); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
350 Node rootNode = this.createRootNode(document); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
351 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
352 Element typeNode = this.createArtifactElement(document, "type"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
353 typeNode.setAttribute("name", "describe"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
354 rootNode.appendChild(typeNode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
355 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
356 Element uuidNode = this.createArtifactElement(document, "uuid"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
357 uuidNode.setAttribute("value", currentArtifact.getId()); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
358 rootNode.appendChild(uuidNode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
359 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
360 Element hashNode = this.createArtifactElement(document, "hash"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
361 hashNode.setAttribute("value", currentArtifact.getHash()); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
362 rootNode.appendChild(hashNode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
363 Element includeUINode = this.createArtifactElement(document, "include-ui"); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
364 includeUINode.appendChild(document.createTextNode(""+includeUI)); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
365 rootNode.appendChild(includeUINode); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
366 return document; |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
367 } |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
368 |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
369 /** |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
370 * @param artifactFactory |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
371 * @param currentArtifact |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
372 * @return |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
373 */ |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
374 private String getArtifactUrl(ArtifactObject artifactFactory, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
375 ArtifactObject currentArtifact) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
376 String url = ((ArtifactFactory) artifactFactory).getDataBaseUrl() |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
377 + "/artifact/" + currentArtifact.getId(); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
378 return url; |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
379 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
380 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
381 private ArtifactDescription readDescription(Document document, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
382 ArtifactObject artifact) |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
383 throws ArtifactDatabaseClientException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
384 // Check if there was an Error or Exception reported from the |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
385 // ArtifactDatabase |
25 | 386 this.check4ExceptionReport(document); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
387 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
388 if (artifact instanceof ArtifactDescription) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
389 ArtifactDescription ad = (ArtifactDescription) artifact; |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
390 Node uiNode = xmlUtils.getNodeXPath(document, "/result/ui"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
391 Node outputNode = xmlUtils |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
392 .getNodeXPath(document, "/result/outputs"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
393 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
394 Map<String, OutputMode> outputModes = null; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
395 if (outputNode != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
396 NodeList outputModesNodes = xmlUtils.getNodeSetXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
397 outputNode, "output"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
398 if (outputModesNodes != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
399 outputModes = new HashMap<String, OutputMode>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
400 outputModesNodes.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
401 for (int i = 0; i < outputModesNodes.getLength(); i++) { |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
402 Node outputModeNode = outputModesNodes.item(i); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
403 String name = xmlUtils.getStringXPath(outputModeNode, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
404 "@name"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
405 String mimeType = xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
406 outputModeNode, "@mime-type"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
407 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
408 NodeList parameterNodes = xmlUtils.getNodeSetXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
409 outputModeNode, "parameter/parameter"); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
410 Collection<OutputParameter> parameter = null; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
411 if (parameterNodes != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
412 parameter = new ArrayList<OutputParameter>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
413 parameterNodes.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
414 for (int j = 0; j < parameterNodes.getLength(); j++) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
415 Node outputParameterNode = parameterNodes |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
416 .item(j); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
417 parameter.add(new DefaultOutputParameter( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
418 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
419 outputParameterNode, "@name"), |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
420 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
421 outputParameterNode, "@value"), |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
422 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
423 outputParameterNode, "@name"), |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
424 xmlUtils.getStringXPath( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
425 outputParameterNode, "@type"))); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
426 } |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
427 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
428 outputModes.put(name, new DefaultOutputMode(name, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
429 mimeType, parameter)); |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
430 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
431 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
432 } |
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
433 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
434 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
435 String currentState = xmlUtils.getStringXPath(document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
436 "/result/state/@name"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
437 NodeList statesList = xmlUtils.getNodeSetXPath(document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
438 "/result/reachable-states/state/@name"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
439 Collection<String> reachableStates = new ArrayList<String>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
440 statesList.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
441 for (int i = 0; i < statesList.getLength(); i++) { |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
442 reachableStates.add(statesList.item(i).getNodeValue()); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
443 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
444 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
445 NodeList inputNodes = xmlUtils.getNodeSetXPath(document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
446 "/result/model/input"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
447 if (inputNodes != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
448 Collection<String> inputParameter = new ArrayList<String>( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
449 inputNodes.getLength()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
450 for (int i = 0; i < inputNodes.getLength(); i++) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
451 Node inputNode = inputNodes.item(i); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
452 String name = xmlUtils.getStringXPath(inputNode, "@name"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
453 inputParameter.add(name); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
454 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
455 ad.setInputParameter(inputParameter); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
456 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
457 |
30
07e9c137a2f1
Added dynamic Outputparameter Support and Outputparameter-manipulation
Tim Englich <tim.englich@intevation.de>
parents:
25
diff
changeset
|
458 ad.setOutputModes(outputModes); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
459 ad.setCurrentOut(outputNode); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
460 ad.setCurrentUI(uiNode); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
461 ad.setCurrentState(currentState); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
462 ad.setReachableStates(reachableStates); |
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
463 return ad; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
464 } else { |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
465 log.error("Artifact must be Instance of ArtifactDescription"); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
466 throw new ArtifactDatabaseClientException( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
467 "Artifact must be Instance of ArtifactDescription"); |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
468 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
469 |
9
a4cb6d175a6e
Support for Initial DescribeCall to ArtifactDatabase implemented
Tim Englich <tim.englich@intevation.de>
parents:
7
diff
changeset
|
470 } |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
471 |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
472 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
473 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doNextStep(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
474 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
475 * java.lang.String, java.util.Collection) |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
476 */ |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
477 public ArtifactDescription doNextStep( |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
478 ArtifactObject artifactFactory, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
479 ArtifactObject currentArtifact, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
480 String target, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
481 Collection<InputParameter> inputParameter) |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
482 throws ArtifactDatabaseClientException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
483 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
484 try { |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
485 // 1 Feed |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
486 this.doFeed(artifactFactory, currentArtifact, inputParameter); |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
487 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
488 // 2. Noch einmal Describe um das jetzt zu erreichende Ziel zu ermitteln |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
489 ArtifactDescription ad = this.getCurrentStepDescription(artifactFactory, |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
490 new Artifact(currentArtifact.getId(), |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
491 currentArtifact.getHash()), |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
492 false); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
493 target = ad.getReachableStates().iterator().next(); |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
494 |
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
495 // 3 Advance |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
496 String url = this.getArtifactUrl(artifactFactory, currentArtifact); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
497 Document advanceDocument = this.createAdvanceRequestBody( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
498 currentArtifact, target); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
499 InputStream advanceResult = this |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
500 .doPostRequest(url, advanceDocument); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
501 this.check4ExceptionReport(new XMLUtils() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
502 .readDocument(advanceResult)); |
25 | 503 // 3 Describe |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
504 return this.getCurrentStepDescription(artifactFactory, |
157
013d47662161
Switched the Communication for Describe-Calls to the artifact-database from get to post.
Tim Englich <tim.englich@intevation.de>
parents:
154
diff
changeset
|
505 currentArtifact,true); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
506 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
507 log.error(e, e); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
508 throw new ArtifactDatabaseClientException(e); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
509 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
510 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
511 |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
512 private Document createFeedRequestBody( |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
513 ArtifactObject currentArtifact, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
514 Collection<InputParameter> inputParameter) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
515 Document document = new XMLUtils().newDocument(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
516 Node rootNode = this.createRootNode(document); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
517 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
518 Element typeNode = this.createArtifactElement(document, "type"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
519 typeNode.setAttribute("name", "feed"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
520 rootNode.appendChild(typeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
521 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
522 Element uuidNode = this.createArtifactElement(document, "uuid"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
523 uuidNode.setAttribute("value", currentArtifact.getId()); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
524 rootNode.appendChild(uuidNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
525 |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
526 Element hashNode = this.createArtifactElement(document, "hash"); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
527 hashNode.setAttribute("value", currentArtifact.getHash()); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
528 rootNode.appendChild(hashNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
529 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
530 Node dataNode = this.createParameterNodes(inputParameter, document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
531 "data"); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
532 rootNode.appendChild(dataNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
533 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
534 return document; |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
535 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
536 |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
537 /** |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
538 * @param inputParameter |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
539 * @param document |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
540 * @param rootNode |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
541 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
542 private Node createParameterNodes( |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
543 Collection<InputParameter> inputParameter, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
544 Document document, String nodeName) { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
545 Element dataNode = this.createArtifactElement(document, nodeName); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
546 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
547 if (inputParameter != null) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
548 Iterator<InputParameter> it = inputParameter.iterator(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
549 while (it.hasNext()) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
550 InputParameter ip = it.next(); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
551 String name = ip.getName(); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
552 String[] values = ip.getValues(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
553 if (values != null) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
554 for (int i = 0; i < values.length; i++) { |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
555 String value = values[i]; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
556 Element inputNode = this.createArtifactElement( |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
557 document, "input"); |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
558 inputNode.setAttribute("name", name); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
559 inputNode.setAttribute("value", value); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
560 dataNode.appendChild(inputNode); |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
561 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
562 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
563 } |
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
564 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
565 return dataNode; |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
566 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
567 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
568 private Document createAdvanceRequestBody(ArtifactObject currentArtifact, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
569 String target) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
570 Document document = new XMLUtils().newDocument(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
571 Node rootNode = this.createRootNode(document); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
572 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
573 Element typeNode = this.createArtifactElement(document, "type"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
574 typeNode.setAttribute("name", "advance"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
575 rootNode.appendChild(typeNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
576 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
577 Element uuidNode = this.createArtifactElement(document, "uuid"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
578 uuidNode.setAttribute("value", currentArtifact.getId()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
579 rootNode.appendChild(uuidNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
580 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
581 Element hashNode = this.createArtifactElement(document, "hash"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
582 hashNode.setAttribute("value", currentArtifact.getHash()); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
583 rootNode.appendChild(hashNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
584 Element targetNode = this.createArtifactElement(document, "target"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
585 targetNode.setAttribute("name", target); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
586 rootNode.appendChild(targetNode); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
587 return document; |
12
4ebe57b170d3
Integration of moving through the Artifact-States and rendering the UI.
Tim Englich <tim.englich@intevation.de>
parents:
11
diff
changeset
|
588 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
589 |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
590 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
591 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doOutput(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
592 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
593 * java.io.OutputStream, java.lang.String, java.lang.String, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
594 * java.util.Collection) |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
595 */ |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
596 public void doOutput(ArtifactObject artifactFactory, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
597 ArtifactObject currentArtifact, OutputStream stream, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
598 String targetName, String mimeType, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
599 Collection<InputParameter> inputParameter) |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
600 throws ArtifactDatabaseClientException { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
601 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
602 Document requestBody = this.createOutRequestBody(currentArtifact, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
603 targetName, mimeType, inputParameter); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
604 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
605 String requestUrl = this.getArtifactUrl(artifactFactory, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
606 currentArtifact) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
607 + "/" + targetName; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
608 InputStream is = this.doPostRequest(requestUrl, requestBody); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
609 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
610 byte[] b = new byte[4096]; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
611 int i = -1; |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
612 while ((i = is.read(b)) > 0) { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
613 stream.write(b, 0, i); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
614 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
615 } catch (IOException e) { |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
616 log.error(e, e); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
617 throw new ArtifactDatabaseClientException(e); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
618 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
619 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
620 |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
621 private Document createOutRequestBody( |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
622 ArtifactObject currentArtifact, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
623 String target, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
624 String mimeType, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
625 Collection<InputParameter> inputParameter) { |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
626 Document document = new XMLUtils().newDocument(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
627 Node rootNode = this.createRootNode(document); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
628 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
629 Element typeNode = this.createArtifactElement(document, "type"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
630 typeNode.setAttribute("name", "out"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
631 rootNode.appendChild(typeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
632 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
633 Element uuidNode = this.createArtifactElement(document, "uuid"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
634 uuidNode.setAttribute("value", currentArtifact.getId()); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
635 rootNode.appendChild(uuidNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
636 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
637 Element hashNode = this.createArtifactElement(document, "hash"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
638 hashNode.setAttribute("value", currentArtifact.getHash()); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
639 rootNode.appendChild(hashNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
640 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
641 Element outNode = this.createArtifactElement(document, "out"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
642 outNode.setAttribute("name", target); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
643 rootNode.appendChild(outNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
644 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
645 Element mimeTypeNode = this.createArtifactElement(document, "out"); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
646 mimeTypeNode.setAttribute("value", mimeType); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
647 outNode.appendChild(mimeTypeNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
648 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
649 Node parameterNode = this.createParameterNodes(inputParameter, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
650 document, "params"); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
651 outNode.appendChild(parameterNode); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
652 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
653 return document; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
654 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
655 |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
656 /** |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
657 * @see de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient#doFeed(de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
658 * de.intevation.gnv.artifactdatabase.objects.ArtifactObject, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
659 * java.util.Collection) |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
660 */ |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
661 public void doFeed(ArtifactObject artifactFactory, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
662 ArtifactObject currentArtifact, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
663 Collection<InputParameter> inputParameter) |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
664 throws ArtifactDatabaseClientException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
665 |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
666 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
667 Document feedDocument = this.createFeedRequestBody(currentArtifact, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
668 inputParameter); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
669 String url = this.getArtifactUrl(artifactFactory, currentArtifact); |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
670 InputStream feedResult = this.doPostRequest(url, feedDocument); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
671 Document feedResultDocument = new XMLUtils() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
672 .readDocument(feedResult); |
25 | 673 this.check4ExceptionReport(feedResultDocument); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
674 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
675 log.error(e, e); |
25 | 676 throw new ArtifactDatabaseClientException(e); |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
677 } |
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
678 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
679 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
680 private void check4ExceptionReport(Document document) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
681 throws ArtifactDatabaseClientException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
682 |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
683 String message = new XMLUtils().getStringXPath(document, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
684 "/exceptionreport/exception"); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
685 if (message != null) { |
25 | 686 throw new ArtifactDatabaseClientException(message); |
687 } | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
688 |
25 | 689 } |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
690 |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
691 public Collection<ArtifactStatisticsSet> calculateStatistics( |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
692 ArtifactObject artifactFactory, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
693 ArtifactObject currentArtifact) |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
694 throws ArtifactDatabaseClientException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
695 log.debug("DefaultArtifactDatabaseClient.calculateStatistics"); |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
696 Collection<ArtifactStatisticsSet> resultValues = null; |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
697 |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
698 try { |
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
699 String targetName = "statistics"; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
700 String requestUrl = this.getArtifactUrl(artifactFactory, |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
701 currentArtifact) + "/" + targetName; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
702 Document requestBody = this.createOutRequestBody(currentArtifact, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
703 targetName, "text/xml", null); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
704 XMLUtils xmlUtils = new XMLUtils(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
705 InputStream is = this.doPostRequest(requestUrl, requestBody); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
706 Document resultDocument = xmlUtils.readDocument(is); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
707 if (resultDocument != null) { |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
708 |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
709 NodeList statisticSetNodes = xmlUtils.getNodeSetXPath(resultDocument, |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
710 "/statistics/statistic"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
711 resultValues = new ArrayList<ArtifactStatisticsSet> |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
712 (statisticSetNodes.getLength()); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
713 for (int i = 0; i < statisticSetNodes.getLength(); i++) { |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
714 Element statisticSetNode = (Element)statisticSetNodes.item(i); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
715 String name = statisticSetNode.getAttribute("name"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
716 ArtifactStatisticsSet set = |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
717 new DefaultArtifactStatisticsSet(name); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
718 NodeList resultNodes = xmlUtils.getNodeSetXPath(statisticSetNode, |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
719 "statistic-value"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
720 if (resultNodes != null) { |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
721 for (int j = 0; j < resultNodes.getLength(); j++) { |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
722 Element statisticNode = (Element)resultNodes.item(j); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
723 String statisticName = statisticNode. |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
724 getAttribute("name"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
725 String statisticValue = statisticNode. |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
726 getAttribute("value"); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
727 set.addStatisticValues( |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
728 new DefaultArtifactStatisticValue |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
729 (statisticName,statisticValue)); |
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
730 } |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
731 } |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
732 resultValues.add(set); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
733 } |
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
734 } |
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
735 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
736 log.error(e, e); |
35 | 737 throw new ArtifactDatabaseClientException(e); |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
738 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
739 |
164
5570d9b3282f
Implemented a better GUI-Structure for displaying the Statisticdata. issue83
Tim Englich <tim.englich@intevation.de>
parents:
157
diff
changeset
|
740 return resultValues; |
32
0f4362d75e9e
Adding StatisticsOutput to the GUI
Tim Englich <tim.englich@intevation.de>
parents:
30
diff
changeset
|
741 } |
40
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
742 |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
743 public void setLocale(Locale locale) { |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
744 this.locale = locale; |
23a4f196d7d6
Adding Languagetransfer to the ArtifactDatabase to the GNV-Client
Tim Englich <tim.englich@intevation.de>
parents:
38
diff
changeset
|
745 } |
13
2535158e2687
Chartoutput Added to the View
Tim Englich <tim.englich@intevation.de>
parents:
12
diff
changeset
|
746 } |