annotate gwt-client/src/main/java/org/dive4elements/river/client/server/FeedServiceImpl.java @ 9801:1d7a72a50183 3.2.x tip

Assume Compose V2, consistently
author Tom Gottfried <tom@intevation.de>
date Thu, 23 Nov 2023 10:14:13 +0100
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;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
10
1518
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
11 import java.util.ArrayList;
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
12 import java.util.List;
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
13
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
14 import org.w3c.dom.Document;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
15
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
16 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
17 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: 853
diff changeset
18
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
19 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
20
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.artifacts.common.ArtifactNamespaceContext;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 import org.dive4elements.artifacts.common.utils.XMLUtils;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@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.artifacts.httpclient.exceptions.ConnectionException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
29
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
30 import org.dive4elements.river.client.shared.exceptions.ServerException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
31 import org.dive4elements.river.client.shared.model.Artifact;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
32 import org.dive4elements.river.client.shared.model.Data;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
33 import org.dive4elements.river.client.shared.model.DataItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
34 import org.dive4elements.river.client.client.services.FeedService;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
35
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
36 /**
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 * This interface provides a method that bundles the artifact specific
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 * operation FEED.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 */
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 public class FeedServiceImpl
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 extends RemoteServiceServlet
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
42 implements FeedService
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
43 {
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 8203
diff changeset
44 private static final Logger log = LogManager.getLogger(FeedServiceImpl.class);
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 853
diff changeset
45
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 853
diff changeset
46
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
47 /** XPath that points to the result type of a feed or advance operation.*/
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48 public static final String XPATH_RESULT = "/art:result/@art:type";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
50 /** XPath that points to the result type of a feed or advance operation.*/
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51 public static final String XPATH_RESULT_MSG = "/art:result/text()";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 /** A constant that marks errors.*/
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54 public static final String OPERATION_FAILURE = "FAILURE";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
56 /** The error message key that is thrown if an error occured while feeding
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 * new data.*/
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58 public static final String ERROR_FEED_DATA = "error_feed_data";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
59
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
60
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
61 /**
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 * This method triggers the FEED operation.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 * @param artifact The artifact that needs to be fed.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
65 * @param data An array of Data objects that contain the information that
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 * are used for the FEED operation.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 * @return a new artifact parsed from the description of FEED.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 */
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 public Artifact feed(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 String locale,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 Artifact artifact,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 Data[] data)
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 throws ServerException
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
75 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
76 log.info("StepForwardServiceImpl.feed");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
77
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
78 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
79
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 Document feed = ClientProtocolUtils.newFeedDocument(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 artifact.getUuid(),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 artifact.getHash(),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83 createKVP(data));
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85 HttpClient client = new HttpClientImpl(url, locale);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 try {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
88 Document description = (Document) client.feed(
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
89 new org.dive4elements.artifacts.httpclient.objects.Artifact(
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 artifact.getUuid(),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 artifact.getHash()),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92 feed,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93 new DocumentResponseHandler());
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
95 if (description == null) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
96 log.warn("StepForwardService.feed() - FAILED");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 throw new ServerException(ERROR_FEED_DATA);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
98 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
99
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 String result = XMLUtils.xpathString(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 description,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 XPATH_RESULT,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103 ArtifactNamespaceContext.INSTANCE);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
105 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
106 log.debug("StepForwardService.feed() - SUCCESS");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 return (Artifact) new FLYSArtifactCreator().create(description);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109 else if (result != null && result.equals(OPERATION_FAILURE)) {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 String msg = XMLUtils.xpathString(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 description,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 XPATH_RESULT_MSG,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 ArtifactNamespaceContext.INSTANCE);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114 throw new ServerException(msg);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
115 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
116 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
117 catch (ConnectionException ce) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
118 log.error(ce, ce);
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
120
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
121 log.warn("StepForwardService.feed() - FAILED");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 throw new ServerException(ERROR_FEED_DATA);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
123 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
124
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
125
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
126 /**
1518
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
127 * Triggers FEED operation, many artifacts, same data item(s).
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
128 *
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
129 * @param artifacts Artifacts that shall be fed.
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
130 * @param data An array of Data objects that contain the information that
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
131 * are used for the FEED operation.
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
132 *
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
133 * @return a new artifact parsed from the description of FEED.
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
134 */
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
135 public List<Artifact> feedMany(
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
136 String locale,
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
137 List<Artifact> artifacts,
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
138 Data[] data)
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
139 throws ServerException
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
140 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
141 log.info("StepForwardServiceImpl.feedMany");
1518
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
142
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
143 String url = getServletContext().getInitParameter("server-url");
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
144
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
145 List<Artifact> resultArtifacts = new ArrayList<Artifact>();
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
146
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
147 for (Artifact artifact: artifacts) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
148 log.info("feedMany: Relay to StepForwardServiceImpl.feed");
1518
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
149 Artifact fedArtifact = feed(locale, artifact, data);
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
150 resultArtifacts.add(fedArtifact);
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
151 }
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
152
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
153 return resultArtifacts;
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
154 }
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
155
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
156
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
157 /**
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
158 * This method creates an array of key/value pairs from an array of Data
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
159 * objects. The string array is used as parameter for the feed() operation.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
160 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
161 * @param data The data that should be transformed into the string array.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
163 * @return a string array that contains key/value pairs.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 */
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 protected String[][] createKVP(Data[] data) {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166 String[][] kvp = new String[data.length][];
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168 int i = 0;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 for (Data d: data) {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 DataItem[] items = d.getItems();
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
172 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: 1518
diff changeset
173 String value = d.getStringValue();
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
174
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 kvp[i++] = new String[] { key, value };
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
176 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
177
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
178 return kvp;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
179 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
180 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
181 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org