changeset 856:ec5c75da5c7a

Bugfix flys/issue166: Parse Collection names from DESCRIBE. flys-client/trunk@2648 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 06 Sep 2011 07:47:15 +0000 (2011-09-06)
parents 2c48d75c4ab7
children fa8efe5b8aee
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java
diffstat 4 files changed, 36 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Sep 06 07:14:17 2011 +0000
+++ b/flys-client/ChangeLog	Tue Sep 06 07:47:15 2011 +0000
@@ -1,3 +1,18 @@
+2011-09-06  Ingo Weinzierl <ingo@intevation.de>
+
+	  flys/issue166 (Projektname in die Fensterleiste übernehmen)
+
+	* src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java:
+	  Read the name from Collection's DESCRIBE document and create new
+	  Collection objects with this information.
+
+	* src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java:
+	  Adapted constructors which now require a name.
+
+	* src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java:
+	  Use the UUID as Collection name after a Collection has been created - at
+	  that time no user defined name is existing.
+
 2011-09-06	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
 
 	Minor cosmetics.
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java	Tue Sep 06 07:14:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/CreateCollectionServiceImpl.java	Tue Sep 06 07:47:15 2011 +0000
@@ -66,7 +66,7 @@
                 throw new ServerException(ERROR_CREATE_COLLECTION);
             }
 
-            return new DefaultCollection(uuid, Long.valueOf(ttlStr));
+            return new DefaultCollection(uuid, Long.valueOf(ttlStr), uuid);
         }
         catch (ConnectionException ce) {
             System.err.println(ce.getLocalizedMessage());
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java	Tue Sep 06 07:14:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java	Tue Sep 06 07:47:15 2011 +0000
@@ -125,6 +125,11 @@
             "art:artifact-collection/@art:ttl",
             ArtifactNamespaceContext.INSTANCE);
 
+        String name = XMLUtils.xpathString(
+            description,
+            "art:artifact-collection/@art:name",
+            ArtifactNamespaceContext.INSTANCE);
+
         if (uuid.length() == 0 || ttlStr.length() == 0) {
             System.err.println("Found an invalid Collection!");
             return null;
@@ -142,9 +147,11 @@
         Map<String, ThemeList> themeList = parseThemeLists(description);
         List<Recommendation> recommended = parseRecommendations(description);
 
+        name = (name != null && name.length() > 0) ? name : uuid;
+
         Collection c = !themeList.isEmpty()
-            ? new DefaultCollection(uuid, ttl, recommended, themeList)
-            : new DefaultCollection(uuid, ttl, recommended);
+            ? new DefaultCollection(uuid, ttl, name, recommended, themeList)
+            : new DefaultCollection(uuid, ttl, name, recommended);
 
         NodeList items = (NodeList) XMLUtils.xpath(
             description,
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java	Tue Sep 06 07:14:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/DefaultCollection.java	Tue Sep 06 07:47:15 2011 +0000
@@ -42,9 +42,10 @@
     }
 
 
-    public DefaultCollection(String uuid, long ttl) {
+    public DefaultCollection(String uuid, long ttl, String name) {
         this.uuid       = uuid;
         this.ttl        = ttl;
+        this.name       = name;
         this.items      = new ArrayList<CollectionItem>();
         this.themeLists = new HashMap<String, ThemeList>();
         this.recommendations = new ArrayList<Recommendation>();
@@ -56,8 +57,13 @@
      *
      * @param uuid The UUID.
      */
-    public DefaultCollection(String uuid, long ttl, List<Recommendation> recs) {
-        this(uuid, ttl);
+    public DefaultCollection(
+        String uuid,
+        long   ttl,
+        String name,
+        List<Recommendation> recs
+    ) {
+        this(uuid, ttl, name);
 
         this.recommendations = recs;
     }
@@ -66,10 +72,11 @@
     public DefaultCollection(
         String uuid,
         long   ttl,
+        String name,
         List<Recommendation> recommendations,
         Map<String, ThemeList> themeLists)
     {
-        this(uuid, ttl, recommendations);
+        this(uuid, ttl, name, recommendations);
         this.themeLists = themeLists;
     }
 
@@ -79,19 +86,6 @@
      *
      * @param uuid The identifier of this collection.
      * @param name The name of this collection.
-     */
-    public DefaultCollection(String uuid, long ttl, String name) {
-        this(uuid, ttl, new ArrayList<Recommendation>());
-
-        this.name = name;
-    }
-
-
-    /**
-     * Creates a new DefaultCollection with uuid and name.
-     *
-     * @param uuid The identifier of this collection.
-     * @param name The name of this collection.
      * @param creation The creation time.
      */
     public DefaultCollection(String uuid, long ttl, String name, Date creation){

http://dive4elements.wald.intevation.org