Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.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 | ba1b27b7d282 |
children | 07b9404d7170 |
comparison
equal
deleted
inserted
replaced
1366:d0eb2202ffbe | 1367:ab8eb2f544f2 |
---|---|
7 import javax.xml.xpath.XPathConstants; | 7 import javax.xml.xpath.XPathConstants; |
8 | 8 |
9 import org.w3c.dom.Document; | 9 import org.w3c.dom.Document; |
10 import org.w3c.dom.Element; | 10 import org.w3c.dom.Element; |
11 import org.w3c.dom.NodeList; | 11 import org.w3c.dom.NodeList; |
12 | |
13 import org.apache.log4j.Logger; | |
12 | 14 |
13 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 15 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
14 | 16 |
15 import de.intevation.artifacts.common.ArtifactNamespaceContext; | 17 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
16 import de.intevation.artifacts.common.utils.XMLUtils; | 18 import de.intevation.artifacts.common.utils.XMLUtils; |
34 */ | 36 */ |
35 public class UserCollectionsServiceImpl | 37 public class UserCollectionsServiceImpl |
36 extends RemoteServiceServlet | 38 extends RemoteServiceServlet |
37 implements UserCollectionsService | 39 implements UserCollectionsService |
38 { | 40 { |
41 private static final Logger logger = Logger.getLogger( | |
42 UserCollectionsServiceImpl.class); | |
43 | |
44 | |
39 public Collection[] getUserCollections( | 45 public Collection[] getUserCollections( |
40 String serverUrl, | 46 String serverUrl, |
41 String locale, | 47 String locale, |
42 String userid) | 48 String userid) |
43 { | 49 { |
44 System.out.println("UserCollectionsServiceImpl.getUserCollections"); | 50 logger.info("UserCollectionsServiceImpl.getUserCollections"); |
45 | 51 |
46 HttpClient client = new HttpClientImpl(serverUrl, locale); | 52 HttpClient client = new HttpClientImpl(serverUrl, locale); |
47 | 53 |
48 try { | 54 try { |
49 Document result = client.listUserCollections(userid); | 55 Document result = client.listUserCollections(userid); |
53 "/art:artifact-collections/art:artifact-collection", | 59 "/art:artifact-collections/art:artifact-collection", |
54 XPathConstants.NODESET, | 60 XPathConstants.NODESET, |
55 ArtifactNamespaceContext.INSTANCE); | 61 ArtifactNamespaceContext.INSTANCE); |
56 | 62 |
57 if (list == null || list.getLength() == 0) { | 63 if (list == null || list.getLength() == 0) { |
58 System.out.println("No collection found for user: " + userid); | 64 logger.debug("No collection found for user: " + userid); |
59 return null; | 65 return null; |
60 } | 66 } |
61 | 67 |
62 int num = list.getLength(); | 68 int num = list.getLength(); |
63 | 69 |
69 if (c != null) { | 75 if (c != null) { |
70 all.add(c); | 76 all.add(c); |
71 } | 77 } |
72 } | 78 } |
73 | 79 |
74 System.out.println("User has " + all.size() + " collections."); | 80 logger.debug("User has " + all.size() + " collections."); |
75 | 81 |
76 return (Collection[]) all.toArray(new Collection[all.size()]); | 82 return (Collection[]) all.toArray(new Collection[all.size()]); |
77 } | 83 } |
78 catch (ConnectionException ce) { | 84 catch (ConnectionException ce) { |
79 System.err.println(ce.getLocalizedMessage()); | 85 logger.error(ce, ce); |
80 } | 86 } |
81 | 87 |
82 System.err.println("No user collections found."); | 88 logger.debug("No user collections found."); |
83 return null; | 89 return null; |
84 } | 90 } |
85 | 91 |
86 | 92 |
87 /** | 93 /** |
104 long time = Long.parseLong(creationStr); | 110 long time = Long.parseLong(creationStr); |
105 long ttl = Long.parseLong(ttlStr); | 111 long ttl = Long.parseLong(ttlStr); |
106 return new DefaultCollection(uuid, ttl, name, new Date(time)); | 112 return new DefaultCollection(uuid, ttl, name, new Date(time)); |
107 } | 113 } |
108 catch (NumberFormatException nfe) { | 114 catch (NumberFormatException nfe) { |
109 System.err.println("Error while parsing collection attributes."); | 115 logger.warn("Error while parsing collection attributes."); |
110 return null; | 116 return null; |
111 } | 117 } |
112 } | 118 } |
113 | 119 |
114 System.err.println("Found an invalid Collection."); | 120 logger.warn("Found an invalid Collection."); |
115 return null; | 121 return null; |
116 } | 122 } |
117 } | 123 } |
118 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 124 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |