Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/server/StepForwardServiceImpl.java @ 9755:0834c2591e14 3.2.x
Route MapServer through wiki container
This reduces the need for local configuration changes to get
a working Docker-based setup.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 12 Oct 2022 12:53:36 +0200 |
parents | 0a5239a1e46e |
children |
rev | line source |
---|---|
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5993
ea9eef426962
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5861
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5861
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
172338b1407f
GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
9 package org.dive4elements.river.client.server; |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import org.w3c.dom.Document; |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
9726 | 13 import org.apache.logging.log4j.Logger; |
14 import org.apache.logging.log4j.LogManager; | |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
230
diff
changeset
|
15 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
16 import org.dive4elements.artifacts.common.ArtifactNamespaceContext; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
17 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
18 import org.dive4elements.artifacts.common.utils.XMLUtils; |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
20 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
21 import org.dive4elements.artifacts.httpclient.http.HttpClient; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
22 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
23 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler; |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
25 import org.dive4elements.river.client.shared.exceptions.ServerException; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
26 import org.dive4elements.river.client.shared.model.Artifact; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
27 import org.dive4elements.river.client.shared.model.ArtifactDescription; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
28 import org.dive4elements.river.client.shared.model.Data; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
29 import org.dive4elements.river.client.shared.model.DataItem; |
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
30 import org.dive4elements.river.client.client.services.StepForwardService; |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 /** |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * This interface provides a method that bundles the artifact specific |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 * operations FEED and ADVANCE. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 * |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 */ |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 public class StepForwardServiceImpl |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 extends AdvanceServiceImpl |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 implements StepForwardService |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
43 private static final Logger log = |
9726 | 44 LogManager.getLogger(StepForwardServiceImpl.class); |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
230
diff
changeset
|
45 |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
230
diff
changeset
|
46 |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
47 /** XPath that points to the result type of a feed or advance operation.*/ |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
48 public static final String XPATH_RESULT = "/art:result/@art:type"; |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
230
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
50 /** XPath that points to the result type of a feed or advance operation.*/ |
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
51 public static final String XPATH_RESULT_MSG = "/art:result/text()"; |
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
52 |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 /** A constant that marks errors.*/ |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
54 public static final String OPERATION_FAILURE = "FAILURE"; |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
55 |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
56 /** The error message key that is thrown if an error occured while feeding |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
57 * new data.*/ |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
58 public static final String ERROR_FEED_DATA = "error_feed_data"; |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 /** |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * This method wraps the artifact operations FEED and ADVANCE. FEED is |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 * always triggerd, ADVANCE only, if there is at least one reachable state. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 * |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
65 * @param locale The locale used for the request. |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 * @param artifact The artifact that needs to be fed. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * @param data An array of Data objects that contain the information that |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 * |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 * @return the modified artifact. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 */ |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
71 public Artifact go(String locale, Artifact artifact, Data[] data) |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
72 throws ServerException |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
73 { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
74 log.info("StepForwardServiceImpl.go"); |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
75 |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
76 String url = getServletContext().getInitParameter("server-url"); |
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
77 |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
78 Artifact afterFeed = feed(url, locale, artifact, data); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 if (afterFeed == null) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
81 log.warn("StepForwardService.feed() - FAILED"); |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
82 throw new ServerException(ERROR_FEED_DATA); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 ArtifactDescription desc = afterFeed.getArtifactDescription(); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 String[] reachable = desc.getReachableStates(); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 if (reachable == null || reachable.length == 0) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
89 log.debug("Did not find any reachable state."); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 return afterFeed; |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 // We use the first reachable state as default target, maybe we need to |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 // change this later. |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
95 return advance(locale, afterFeed, reachable[0]); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 /** |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 * This method triggers the FEED operation. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 * |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
102 * @param url The url of the artifact server. |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 * @param artifact The artifact that needs to be fed. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 * @param data An array of Data objects that contain the information that |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 * are used for the FEED operation. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 * |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 * @return a new artifact parsed from the description of FEED. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 */ |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
109 protected Artifact feed( |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
110 String url, |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
111 String locale, |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
112 Artifact artifact, |
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
113 Data[] data) |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
114 throws ServerException |
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
115 { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
116 log.info("StepForwardServiceImpl.feed"); |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
117 |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 Document feed = ClientProtocolUtils.newFeedDocument( |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 artifact.getUuid(), |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 artifact.getHash(), |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 createKVP(data)); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 |
229
924da6695800
Each service is now called with the name of the current locale to set the request object's locale manually in the HttpClient.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
215
diff
changeset
|
123 HttpClient client = new HttpClientImpl(url, locale); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 try { |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 Document description = (Document) client.feed( |
5835
821a02bbfb4e
Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5834
diff
changeset
|
127 new org.dive4elements.artifacts.httpclient.objects.Artifact( |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 artifact.getUuid(), |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 artifact.getHash()), |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 feed, |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 new DocumentResponseHandler()); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 if (description == null) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
134 log.warn("StepForwardService.feed() - FAILED"); |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
135 throw new ServerException(ERROR_FEED_DATA); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 String result = XMLUtils.xpathString( |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 description, |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 XPATH_RESULT, |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 ArtifactNamespaceContext.INSTANCE); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 if (result == null || !result.equals(OPERATION_FAILURE)) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
144 log.debug("StepForwardService.feed() - SUCCESS"); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 return (Artifact) new FLYSArtifactCreator().create(description); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 } |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
147 else if (result != null && result.equals(OPERATION_FAILURE)) { |
230
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
148 String msg = XMLUtils.xpathString( |
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
149 description, |
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
150 XPATH_RESULT_MSG, |
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
151 ArtifactNamespaceContext.INSTANCE); |
6de435235927
Added error messages that are displayed during the feed operation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
229
diff
changeset
|
152 throw new ServerException(msg); |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
153 } |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 catch (ConnectionException ce) { |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
156 log.error(ce, ce); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 |
8203
238fc722f87a
sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5993
diff
changeset
|
159 log.warn("StepForwardService.feed() - FAILED"); |
215
e02f50a3ad59
Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
32
diff
changeset
|
160 throw new ServerException(ERROR_FEED_DATA); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
162 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 /** |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 * This method creates an array of key/value pairs from an array of Data |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 * objects. The string array is used as parameter for the feed() operation. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 * |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 * @param data The data that should be transformed into the string array. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 * |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 * @return a string array that contains key/value pairs. |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 */ |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 protected String[][] createKVP(Data[] data) { |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 String[][] kvp = new String[data.length][]; |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 int i = 0; |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 for (Data d: data) { |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 DataItem[] items = d.getItems(); |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 String key = d.getLabel(); |
2535
d0a9acddbea2
Added an int data item used in int array data and added getter that returns
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1425
diff
changeset
|
180 String value = d.getStringValue(); |
32
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 kvp[i++] = new String[] { key, value }; |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 return kvp; |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 } |
88c530c25968
Added a service for the ADVANCE operation and a service that bundles FEED and ADVANCE in a single service.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |