Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java @ 587:53ad6dd2cb2b
The project list displays the favorite state of a collection now. A gold star means, that a collection is a owner's favorite project and will never die. A silver star means, that the project is a common project.
flys-client/trunk@2181 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 21 Jun 2011 16:22:39 +0000 |
parents | 924da6695800 |
children | 80626c4a5bbf |
comparison
equal
deleted
inserted
replaced
586:e3c8e045737b | 587:53ad6dd2cb2b |
---|---|
5 import java.util.List; | 5 import java.util.List; |
6 | 6 |
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.Node; | 11 import org.w3c.dom.Node; |
11 import org.w3c.dom.NodeList; | 12 import org.w3c.dom.NodeList; |
12 | 13 |
13 import com.google.gwt.user.server.rpc.RemoteServiceServlet; | 14 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
14 | 15 |
62 int num = list.getLength(); | 63 int num = list.getLength(); |
63 | 64 |
64 List<Collection> all = new ArrayList<Collection>(num); | 65 List<Collection> all = new ArrayList<Collection>(num); |
65 | 66 |
66 for (int i = 0; i < num; i++) { | 67 for (int i = 0; i < num; i++) { |
67 Collection c = createCollection(list.item(i)); | 68 Collection c = createCollection((Element) list.item(i)); |
68 | 69 |
69 if (c != null) { | 70 if (c != null) { |
70 all.add(c); | 71 all.add(c); |
71 } | 72 } |
72 } | 73 } |
89 * | 90 * |
90 * @param node Contains information about a collection. | 91 * @param node Contains information about a collection. |
91 * | 92 * |
92 * @return a list of Simplecollections. | 93 * @return a list of Simplecollections. |
93 */ | 94 */ |
94 protected Collection createCollection(Node node) { | 95 protected Collection createCollection(Element node) { |
95 String creationStr = XMLUtils.xpathString( | 96 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
96 node, "@art:creation", ArtifactNamespaceContext.INSTANCE); | |
97 | 97 |
98 String name = XMLUtils.xpathString( | 98 String creationStr = node.getAttributeNS(uri, "creation"); |
99 node, "@art:name", ArtifactNamespaceContext.INSTANCE); | 99 String name = node.getAttributeNS(uri, "name"); |
100 String uuid = node.getAttributeNS(uri, "uuid"); | |
101 String ttlStr = node.getAttributeNS(uri, "ttl"); | |
100 | 102 |
101 String uuid = XMLUtils.xpathString( | 103 if (uuid != null && ttlStr != null) { |
102 node, "@art:uuid", ArtifactNamespaceContext.INSTANCE); | 104 try { |
103 | 105 long time = Long.parseLong(creationStr); |
104 if (uuid != null) { | 106 long ttl = Long.parseLong(ttlStr); |
105 long time = Long.parseLong(creationStr); | 107 return new DefaultCollection(uuid, ttl, name, new Date(time)); |
106 return new DefaultCollection(uuid, name, new Date(time)); | 108 } |
109 catch (NumberFormatException nfe) { | |
110 System.err.println("Error while parsing collection attributes."); | |
111 return null; | |
112 } | |
107 } | 113 } |
108 | 114 |
109 System.err.println("Found an invalid Collection."); | 115 System.err.println("Found an invalid Collection."); |
110 return null; | 116 return null; |
111 } | 117 } |