Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java @ 1367:ab8eb2f544f2
Replaced stdout and stderr logging with log4j loggers in server classes.
flys-client/trunk@3069 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 25 Oct 2011 12:31:15 +0000 |
parents | 6de435235927 |
children | bc06a671ef60 |
comparison
equal
deleted
inserted
replaced
1366:d0eb2202ffbe | 1367:ab8eb2f544f2 |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import org.w3c.dom.Document; | 3 import org.w3c.dom.Document; |
4 | |
5 import org.apache.log4j.Logger; | |
4 | 6 |
5 import de.intevation.artifacts.common.ArtifactNamespaceContext; | 7 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
6 import de.intevation.artifacts.common.utils.ClientProtocolUtils; | 8 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
7 import de.intevation.artifacts.common.utils.XMLUtils; | 9 import de.intevation.artifacts.common.utils.XMLUtils; |
8 | 10 |
27 */ | 29 */ |
28 public class StepForwardServiceImpl | 30 public class StepForwardServiceImpl |
29 extends AdvanceServiceImpl | 31 extends AdvanceServiceImpl |
30 implements StepForwardService | 32 implements StepForwardService |
31 { | 33 { |
34 private static final Logger logger = | |
35 Logger.getLogger(StepForwardServiceImpl.class); | |
36 | |
37 | |
32 /** XPath that points to the result type of a feed or advance operation.*/ | 38 /** XPath that points to the result type of a feed or advance operation.*/ |
33 public static final String XPATH_RESULT = "/art:result/@art:type"; | 39 public static final String XPATH_RESULT = "/art:result/@art:type"; |
34 | 40 |
35 /** XPath that points to the result type of a feed or advance operation.*/ | 41 /** XPath that points to the result type of a feed or advance operation.*/ |
36 public static final String XPATH_RESULT_MSG = "/art:result/text()"; | 42 public static final String XPATH_RESULT_MSG = "/art:result/text()"; |
55 * @return the modified artifact. | 61 * @return the modified artifact. |
56 */ | 62 */ |
57 public Artifact go(String url, String locale, Artifact artifact, Data[] data) | 63 public Artifact go(String url, String locale, Artifact artifact, Data[] data) |
58 throws ServerException | 64 throws ServerException |
59 { | 65 { |
60 System.out.println("StepForwardServiceImpl.go"); | 66 logger.info("StepForwardServiceImpl.go"); |
61 | 67 |
62 Artifact afterFeed = feed(url, locale, artifact, data); | 68 Artifact afterFeed = feed(url, locale, artifact, data); |
63 | 69 |
64 if (afterFeed == null) { | 70 if (afterFeed == null) { |
65 System.err.println("StepForwardService.feed() - FAILED"); | 71 logger.warn("StepForwardService.feed() - FAILED"); |
66 throw new ServerException(ERROR_FEED_DATA); | 72 throw new ServerException(ERROR_FEED_DATA); |
67 } | 73 } |
68 | 74 |
69 ArtifactDescription desc = afterFeed.getArtifactDescription(); | 75 ArtifactDescription desc = afterFeed.getArtifactDescription(); |
70 String[] reachable = desc.getReachableStates(); | 76 String[] reachable = desc.getReachableStates(); |
71 | 77 |
72 if (reachable == null || reachable.length == 0) { | 78 if (reachable == null || reachable.length == 0) { |
73 System.out.println("Did not find any reachable state."); | 79 logger.debug("Did not find any reachable state."); |
74 return afterFeed; | 80 return afterFeed; |
75 } | 81 } |
76 | 82 |
77 // We use the first reachable state as default target, maybe we need to | 83 // We use the first reachable state as default target, maybe we need to |
78 // change this later. | 84 // change this later. |
95 String locale, | 101 String locale, |
96 Artifact artifact, | 102 Artifact artifact, |
97 Data[] data) | 103 Data[] data) |
98 throws ServerException | 104 throws ServerException |
99 { | 105 { |
100 System.out.println("StepForwardServiceImpl.feed"); | 106 logger.info("StepForwardServiceImpl.feed"); |
101 | 107 |
102 Document feed = ClientProtocolUtils.newFeedDocument( | 108 Document feed = ClientProtocolUtils.newFeedDocument( |
103 artifact.getUuid(), | 109 artifact.getUuid(), |
104 artifact.getHash(), | 110 artifact.getHash(), |
105 createKVP(data)); | 111 createKVP(data)); |
113 artifact.getHash()), | 119 artifact.getHash()), |
114 feed, | 120 feed, |
115 new DocumentResponseHandler()); | 121 new DocumentResponseHandler()); |
116 | 122 |
117 if (description == null) { | 123 if (description == null) { |
118 System.err.println("StepForwardService.feed() - FAILED"); | 124 logger.warn("StepForwardService.feed() - FAILED"); |
119 throw new ServerException(ERROR_FEED_DATA); | 125 throw new ServerException(ERROR_FEED_DATA); |
120 } | 126 } |
121 | 127 |
122 String result = XMLUtils.xpathString( | 128 String result = XMLUtils.xpathString( |
123 description, | 129 description, |
124 XPATH_RESULT, | 130 XPATH_RESULT, |
125 ArtifactNamespaceContext.INSTANCE); | 131 ArtifactNamespaceContext.INSTANCE); |
126 | 132 |
127 if (result == null || !result.equals(OPERATION_FAILURE)) { | 133 if (result == null || !result.equals(OPERATION_FAILURE)) { |
128 System.out.println("StepForwardService.feed() - SUCCESS"); | 134 logger.debug("StepForwardService.feed() - SUCCESS"); |
129 return (Artifact) new FLYSArtifactCreator().create(description); | 135 return (Artifact) new FLYSArtifactCreator().create(description); |
130 } | 136 } |
131 else if (result != null && result.equals(OPERATION_FAILURE)) { | 137 else if (result != null && result.equals(OPERATION_FAILURE)) { |
132 String msg = XMLUtils.xpathString( | 138 String msg = XMLUtils.xpathString( |
133 description, | 139 description, |
135 ArtifactNamespaceContext.INSTANCE); | 141 ArtifactNamespaceContext.INSTANCE); |
136 throw new ServerException(msg); | 142 throw new ServerException(msg); |
137 } | 143 } |
138 } | 144 } |
139 catch (ConnectionException ce) { | 145 catch (ConnectionException ce) { |
140 System.err.println(ce.getLocalizedMessage()); | 146 logger.error(ce, ce); |
141 } | 147 } |
142 | 148 |
143 System.err.println("StepForwardService.feed() - FAILED"); | 149 logger.warn("StepForwardService.feed() - FAILED"); |
144 throw new ServerException(ERROR_FEED_DATA); | 150 throw new ServerException(ERROR_FEED_DATA); |
145 } | 151 } |
146 | 152 |
147 | 153 |
148 /** | 154 /** |