comparison flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.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 d5fb88ba99d2
children f43862cc1e6e
comparison
equal deleted inserted replaced
1366:d0eb2202ffbe 1367:ab8eb2f544f2
6 import javax.xml.xpath.XPathConstants; 6 import javax.xml.xpath.XPathConstants;
7 7
8 import org.w3c.dom.Document; 8 import org.w3c.dom.Document;
9 import org.w3c.dom.Element; 9 import org.w3c.dom.Element;
10 import org.w3c.dom.NodeList; 10 import org.w3c.dom.NodeList;
11
12 import org.apache.log4j.Logger;
11 13
12 import de.intevation.artifacts.common.utils.XMLUtils; 14 import de.intevation.artifacts.common.utils.XMLUtils;
13 import de.intevation.artifacts.common.ArtifactNamespaceContext; 15 import de.intevation.artifacts.common.ArtifactNamespaceContext;
14 16
15 import de.intevation.artifacts.httpclient.utils.ArtifactCreator; 17 import de.intevation.artifacts.httpclient.utils.ArtifactCreator;
26 * uuid, hash) and returns a new {@link Artifact} instance. 28 * uuid, hash) and returns a new {@link Artifact} instance.
27 * 29 *
28 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> 30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
29 */ 31 */
30 public class FLYSArtifactCreator implements ArtifactCreator { 32 public class FLYSArtifactCreator implements ArtifactCreator {
33
34 private static final Logger logger =
35 Logger.getLogger(FLYSArtifactCreator.class);
36
31 37
32 /** The XPath to the artifact's uuid.*/ 38 /** The XPath to the artifact's uuid.*/
33 public static final String XPATH_UUID = "/art:result/art:uuid/@art:value"; 39 public static final String XPATH_UUID = "/art:result/art:uuid/@art:value";
34 40
35 /** The XPath to the artifact's hash value.*/ 41 /** The XPath to the artifact's hash value.*/
80 * @param doc The result of the CREATE operation. 86 * @param doc The result of the CREATE operation.
81 * 87 *
82 * @return an instance of an {@link Artifact}. 88 * @return an instance of an {@link Artifact}.
83 */ 89 */
84 protected Artifact extractArtifact(Document doc) { 90 protected Artifact extractArtifact(Document doc) {
85 System.out.println("FLYSArtifactCreator - extractArtifact()"); 91 logger.debug("FLYSArtifactCreator - extractArtifact()");
86 92
87 String uuid = XMLUtils.xpathString( 93 String uuid = XMLUtils.xpathString(
88 doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); 94 doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE);
89 95
90 String hash = XMLUtils.xpathString( 96 String hash = XMLUtils.xpathString(
101 background = Boolean.valueOf(backgroundStr); 107 background = Boolean.valueOf(backgroundStr);
102 } 108 }
103 109
104 List<CalculationMessage> msg = parseBackgroundMessages(doc); 110 List<CalculationMessage> msg = parseBackgroundMessages(doc);
105 111
106 System.out.println("NEW Artifact UUID: " + uuid); 112 logger.debug("NEW Artifact UUID: " + uuid);
107 System.out.println("NEW Artifact HASH: " + hash); 113 logger.debug("NEW Artifact HASH: " + hash);
108 System.out.println("NEW Artifact NAME: " + name); 114 logger.debug("NEW Artifact NAME: " + name);
109 System.out.println("NEW Artifact IN BACKGROUND: " + background); 115 logger.debug("NEW Artifact IN BACKGROUND: " + background);
110 116
111 if (name == null) { 117 if (name == null) {
112 return new DefaultArtifact(uuid, hash, background, msg); 118 return new DefaultArtifact(uuid, hash, background, msg);
113 } 119 }
114 120
115 name = name.trim(); 121 name = name.trim();
116 122
117 if (name.length() > 0 && name.equals("winfo")) { 123 if (name.length() > 0 && name.equals("winfo")) {
118 System.out.println("+++++ NEW WINFO ARTIFACT."); 124 logger.debug("+++++ NEW WINFO ARTIFACT.");
119 return new WINFOArtifact(uuid, hash, background, msg); 125 return new WINFOArtifact(uuid, hash, background, msg);
120 } 126 }
121 127
122 return new DefaultArtifact(uuid, hash, background, msg); 128 return new DefaultArtifact(uuid, hash, background, msg);
123 } 129 }
128 d, XPATH_BACKGROUND, XPathConstants.NODESET, 134 d, XPATH_BACKGROUND, XPathConstants.NODESET,
129 ArtifactNamespaceContext.INSTANCE); 135 ArtifactNamespaceContext.INSTANCE);
130 136
131 int len = list != null ? list.getLength() : 0; 137 int len = list != null ? list.getLength() : 0;
132 138
133 System.out.println("Found " + len + " background messages."); 139 logger.debug("Found " + len + " background messages.");
134 140
135 List<CalculationMessage> res = new ArrayList<CalculationMessage>(len); 141 List<CalculationMessage> res = new ArrayList<CalculationMessage>(len);
136 142
137 for (int i = 0; i < len; i++) { 143 for (int i = 0; i < len; i++) {
138 CalculationMessage msg = parseBackgroundMessage( 144 CalculationMessage msg = parseBackgroundMessage(

http://dive4elements.wald.intevation.org