diff flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java @ 215:e02f50a3ad59

Improved the exception handling of artifact / collection specific operations. Warning dialog are displayed after such an exception. flys-client/trunk@1657 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 08 Apr 2011 08:51:28 +0000
parents f7967d12ce6e
children 924da6695800
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java	Fri Apr 08 08:45:15 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java	Fri Apr 08 08:51:28 2011 +0000
@@ -20,6 +20,7 @@
 import de.intevation.artifacts.httpclient.http.HttpClientImpl;
 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
 
+import de.intevation.flys.client.shared.exceptions.ServerException;
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.CollectionItem;
 import de.intevation.flys.client.shared.model.DefaultCollection;
@@ -40,7 +41,15 @@
 extends      RemoteServiceServlet
 implements   DescribeCollectionService
 {
-    public Collection describe(String uuid, String serverUrl) {
+    /** The error message key that is thrown if an error occured while
+     * describe() a Collection.*/
+    public static final String ERROR_DESCRIBE_COLLECTION =
+        "error_describe_collection";
+
+
+    public Collection describe(String uuid, String serverUrl)
+    throws ServerException
+    {
         System.out.println("DescribeCollectionServiceImpl.describe");
 
         Document describe = ClientProtocolUtils.newDescribeCollectionDocument(
@@ -55,7 +64,7 @@
             Collection c = parseCollection(response);
 
             if (c == null) {
-                throw new NullPointerException("No collection returned.");
+                throw new ServerException(ERROR_DESCRIBE_COLLECTION);
             }
 
             return c;
@@ -64,7 +73,7 @@
             System.err.println(ce.getLocalizedMessage());
         }
 
-        return null;
+        throw new ServerException(ERROR_DESCRIBE_COLLECTION);
     }
 
 

http://dive4elements.wald.intevation.org