diff 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
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java	Tue Jun 21 16:14:10 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/UserCollectionsServiceImpl.java	Tue Jun 21 16:22:39 2011 +0000
@@ -7,6 +7,7 @@
 import javax.xml.xpath.XPathConstants;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -64,7 +65,7 @@
             List<Collection> all = new ArrayList<Collection>(num);
 
             for (int i = 0; i < num; i++) {
-                Collection c = createCollection(list.item(i));
+                Collection c = createCollection((Element) list.item(i));
 
                 if (c != null) {
                     all.add(c);
@@ -91,19 +92,24 @@
      *
      * @return a list of Simplecollections.
      */
-    protected Collection createCollection(Node node) {
-        String creationStr = XMLUtils.xpathString(
-            node, "@art:creation", ArtifactNamespaceContext.INSTANCE);
+    protected Collection createCollection(Element node) {
+        String uri = ArtifactNamespaceContext.NAMESPACE_URI;
 
-        String name = XMLUtils.xpathString(
-            node, "@art:name", ArtifactNamespaceContext.INSTANCE);
+        String creationStr = node.getAttributeNS(uri, "creation");
+        String name        = node.getAttributeNS(uri, "name");
+        String uuid        = node.getAttributeNS(uri, "uuid");
+        String ttlStr      = node.getAttributeNS(uri, "ttl");
 
-        String uuid = XMLUtils.xpathString(
-            node, "@art:uuid", ArtifactNamespaceContext.INSTANCE);
-
-        if (uuid != null) {
-            long time = Long.parseLong(creationStr);
-            return new DefaultCollection(uuid, name, new Date(time));
+        if (uuid != null && ttlStr != null) {
+            try {
+                long time = Long.parseLong(creationStr);
+                long ttl  = Long.parseLong(ttlStr);
+                return new DefaultCollection(uuid, ttl, name, new Date(time));
+            }
+            catch (NumberFormatException nfe) {
+                System.err.println("Error while parsing collection attributes.");
+                return null;
+            }
         }
 
         System.err.println("Found an invalid Collection.");

http://dive4elements.wald.intevation.org