Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/FeedServiceImpl.java @ 4571:95e23bcf6a50
Fix FLYS logo URL for printing.
Remove obsolete code from MapPanel.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 20 Nov 2012 15:28:07 +0100 |
parents | d0a9acddbea2 |
children |
rev | line source |
---|---|
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 |
1518
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
3 import java.util.ArrayList; |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
4 import java.util.List; |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
5 |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 import org.w3c.dom.Document; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
8 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
|
9 |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.common.utils.XMLUtils; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import de.intevation.artifacts.httpclient.http.HttpClient; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.client.shared.exceptions.ServerException; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 import de.intevation.flys.client.shared.model.Artifact; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.Data; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.model.DataItem; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.client.services.FeedService; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 /** |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 * This interface provides a method that bundles the artifact specific |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 * operation FEED. |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 */ |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 public class FeedServiceImpl |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 extends RemoteServiceServlet |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 implements FeedService |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
35 private static final Logger logger = Logger.getLogger(FeedServiceImpl.class); |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
36 |
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
37 |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 /** 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
|
39 public static final String XPATH_RESULT = "/art:result/@art:type"; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 /** 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
|
42 public static final String XPATH_RESULT_MSG = "/art:result/text()"; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 /** A constant that marks errors.*/ |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 public static final String OPERATION_FAILURE = "FAILURE"; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 /** 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
|
48 * new data.*/ |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 public static final String ERROR_FEED_DATA = "error_feed_data"; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 |
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 /** |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 * This method triggers the FEED operation. |
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 * @param artifact The artifact that needs to be fed. |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 * @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
|
57 * are used for the FEED operation. |
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 * @return a new artifact parsed from the description of FEED. |
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 public Artifact feed( |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 String locale, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 Artifact artifact, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 Data[] data) |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 throws ServerException |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
67 logger.info("StepForwardServiceImpl.feed"); |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 |
1425
bc06a671ef60
Removed the URL parameter from service calls. The service
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1367
diff
changeset
|
69 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
|
70 |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 Document feed = ClientProtocolUtils.newFeedDocument( |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 artifact.getUuid(), |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 artifact.getHash(), |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 createKVP(data)); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 HttpClient client = new HttpClientImpl(url, locale); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 try { |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 Document description = (Document) client.feed( |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 new de.intevation.artifacts.httpclient.objects.Artifact( |
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 feed, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 new DocumentResponseHandler()); |
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 if (description == null) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
87 logger.warn("StepForwardService.feed() - FAILED"); |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 throw new ServerException(ERROR_FEED_DATA); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 } |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 String result = XMLUtils.xpathString( |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 description, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 XPATH_RESULT, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 ArtifactNamespaceContext.INSTANCE); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 if (result == null || !result.equals(OPERATION_FAILURE)) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
97 logger.debug("StepForwardService.feed() - SUCCESS"); |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 return (Artifact) new FLYSArtifactCreator().create(description); |
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 else if (result != null && result.equals(OPERATION_FAILURE)) { |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 String msg = XMLUtils.xpathString( |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 description, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 XPATH_RESULT_MSG, |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 ArtifactNamespaceContext.INSTANCE); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 throw new ServerException(msg); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 } |
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 catch (ConnectionException ce) { |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
109 logger.error(ce, ce); |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 } |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 |
1367
ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
853
diff
changeset
|
112 logger.warn("StepForwardService.feed() - FAILED"); |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 throw new ServerException(ERROR_FEED_DATA); |
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 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 /** |
1518
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
118 * 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
|
119 * |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
120 * @param artifacts Artifacts that shall be fed. |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
121 * @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
|
122 * are used for the FEED operation. |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
123 * |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
124 * @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
|
125 */ |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
126 public List<Artifact> feedMany( |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
127 String locale, |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
128 List<Artifact> artifacts, |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
129 Data[] data) |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
130 throws ServerException |
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 logger.info("StepForwardServiceImpl.feedMany"); |
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 String url = getServletContext().getInitParameter("server-url"); |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
135 |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
136 List<Artifact> resultArtifacts = new ArrayList<Artifact>(); |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
137 |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
138 for (Artifact artifact: artifacts) { |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
139 logger.info("feedMany: Relay to StepForwardServiceImpl.feed"); |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
140 Artifact fedArtifact = feed(locale, artifact, data); |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
141 resultArtifacts.add(fedArtifact); |
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 |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
144 return resultArtifacts; |
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 |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
147 |
e8706fec0ee9
Added feedMany() implementation to feed-service.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1425
diff
changeset
|
148 /** |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 * 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
|
150 * 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
|
151 * |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 * @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
|
153 * |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 * @return a string array that contains key/value pairs. |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 */ |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 protected String[][] createKVP(Data[] data) { |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 String[][] kvp = new String[data.length][]; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
159 int i = 0; |
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 for (Data d: data) { |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 DataItem[] items = d.getItems(); |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 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
|
164 String value = d.getStringValue(); |
851
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
166 kvp[i++] = new String[] { key, value }; |
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 |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
169 return kvp; |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
170 } |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 } |
aa83a6a864b4
Added FeedService Implementation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |