annotate gwt-client/src/main/java/org/dive4elements/river/client/server/FeedServiceImpl.java @ 8870:c26fb37899ca

Introduced groups for modules. Modules marked with the same group-id, will be put together in the ui. Also using now the localization info from the server instead of localizing the modules again on the client side.
author gernotbelger
date Wed, 07 Feb 2018 11:59:13 +0100
parents 238fc722f87a
children 0a5239a1e46e
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
1367
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 853
diff changeset
16 import org.apache.log4j.Logger;
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 853
diff changeset
17
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
18 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@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.common.ArtifactNamespaceContext;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.artifacts.common.utils.ClientProtocolUtils;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.artifacts.common.utils.XMLUtils;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
23
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
24 import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.artifacts.httpclient.http.HttpClient;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.artifacts.httpclient.http.HttpClientImpl;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.artifacts.httpclient.http.response.DocumentResponseHandler;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
28
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
29 import org.dive4elements.river.client.shared.exceptions.ServerException;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
30 import org.dive4elements.river.client.shared.model.Artifact;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
31 import org.dive4elements.river.client.shared.model.Data;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
32 import org.dive4elements.river.client.shared.model.DataItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
33 import org.dive4elements.river.client.client.services.FeedService;
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
34
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 * This interface provides a method that bundles the artifact specific
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
37 * operation FEED.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
38 */
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
39 public class FeedServiceImpl
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
40 extends RemoteServiceServlet
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
41 implements FeedService
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@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 = Logger.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
44
ab8eb2f544f2 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 853
diff changeset
45
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
46 /** 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
47 public static final String XPATH_RESULT = "/art:result/@art:type";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
48
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
49 /** 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
50 public static final String XPATH_RESULT_MSG = "/art:result/text()";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
51
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
52 /** A constant that marks errors.*/
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
53 public static final String OPERATION_FAILURE = "FAILURE";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
54
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
55 /** 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
56 * new data.*/
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
57 public static final String ERROR_FEED_DATA = "error_feed_data";
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
58
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 * This method triggers the FEED operation.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
62 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
63 * @param artifact The artifact that needs to be fed.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
64 * @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
65 * are used for the FEED operation.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
66 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
67 * @return a new artifact parsed from the description of FEED.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
68 */
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
69 public Artifact feed(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
70 String locale,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
71 Artifact artifact,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
72 Data[] data)
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
73 throws ServerException
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
74 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
75 log.info("StepForwardServiceImpl.feed");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
76
1425
bc06a671ef60 Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1367
diff changeset
77 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
78
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
79 Document feed = ClientProtocolUtils.newFeedDocument(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
80 artifact.getUuid(),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
81 artifact.getHash(),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
82 createKVP(data));
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
83
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
84 HttpClient client = new HttpClientImpl(url, locale);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
85
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
86 try {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
87 Document description = (Document) client.feed(
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
88 new org.dive4elements.artifacts.httpclient.objects.Artifact(
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
89 artifact.getUuid(),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
90 artifact.getHash()),
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
91 feed,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
92 new DocumentResponseHandler());
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
93
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
94 if (description == null) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
95 log.warn("StepForwardService.feed() - FAILED");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
96 throw new ServerException(ERROR_FEED_DATA);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
97 }
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 String result = XMLUtils.xpathString(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
100 description,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
101 XPATH_RESULT,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
102 ArtifactNamespaceContext.INSTANCE);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
103
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
104 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
105 log.debug("StepForwardService.feed() - SUCCESS");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
106 return (Artifact) new FLYSArtifactCreator().create(description);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
107 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
108 else if (result != null && result.equals(OPERATION_FAILURE)) {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
109 String msg = XMLUtils.xpathString(
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
110 description,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
111 XPATH_RESULT_MSG,
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
112 ArtifactNamespaceContext.INSTANCE);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
113 throw new ServerException(msg);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
114 }
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 catch (ConnectionException ce) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
117 log.error(ce, ce);
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
118 }
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
119
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
120 log.warn("StepForwardService.feed() - FAILED");
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
121 throw new ServerException(ERROR_FEED_DATA);
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
122 }
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 /**
1518
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
126 * 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
127 *
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
128 * @param artifacts Artifacts that shall be fed.
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
129 * @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
130 * are used for the FEED operation.
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
131 *
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
132 * @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
133 */
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
134 public List<Artifact> feedMany(
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
135 String locale,
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
136 List<Artifact> artifacts,
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
137 Data[] data)
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
138 throws ServerException
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
139 {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
140 log.info("StepForwardServiceImpl.feedMany");
1518
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
141
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
142 String url = getServletContext().getInitParameter("server-url");
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
143
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
144 List<Artifact> resultArtifacts = new ArrayList<Artifact>();
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
145
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
146 for (Artifact artifact: artifacts) {
8203
238fc722f87a sed 's/logger/log/g' src/**/*.java
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
147 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
148 Artifact fedArtifact = feed(locale, artifact, data);
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
149 resultArtifacts.add(fedArtifact);
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
150 }
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 return resultArtifacts;
e8706fec0ee9 Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1425
diff changeset
153 }
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 /**
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
157 * 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
158 * 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
159 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
160 * @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
161 *
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
162 * @return a string array that contains key/value pairs.
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
163 */
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
164 protected String[][] createKVP(Data[] data) {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
165 String[][] kvp = new String[data.length][];
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
166
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
167 int i = 0;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
168
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
169 for (Data d: data) {
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
170 DataItem[] items = d.getItems();
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
171 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
172 String value = d.getStringValue();
851
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
173
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
174 kvp[i++] = new String[] { key, value };
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
175 }
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 return kvp;
aa83a6a864b4 Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff changeset
178 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org