diff flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java @ 1310:c4c957a9c092

Improved exception handling while fetching theme styles. flys-client/trunk@2944 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 12 Oct 2011 09:34:38 +0000
parents d9cb362b8b34
children 974c6b3700de
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java	Wed Oct 12 08:53:17 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/CollectionItemAttributeServiceImpl.java	Wed Oct 12 09:34:38 2011 +0000
@@ -35,6 +35,9 @@
 
     public static final String OPERATION_FAILURE = "FAILED";
 
+    public static final String ERROR_NO_STYLES_FOUND =
+        "error_no_theme_styles_found";
+
 
     public CollectionItemAttribute getCollectionItemAttribute(
         Collection collection,
@@ -76,7 +79,8 @@
         catch (ConnectionException ce) {
             System.err.println(ce.getLocalizedMessage());
         }
-        throw new ServerException("");
+
+        throw new ServerException(ERROR_NO_STYLES_FOUND);
     }
 
 
@@ -108,15 +112,17 @@
         throw new ServerException("");
     }
 
-    protected CollectionItemAttribute readXML (Document doc, String artifact) {
+    protected CollectionItemAttribute readXML(Document doc, String artifact)
+    throws    ServerException
+    {
         CollectionItemAttribute cia = new CollectionItemAttribute();
         cia.setArtifact(artifact);
 
         Element root = doc.getDocumentElement();
         NodeList themes = root.getElementsByTagName("art:themes");
 
-        if (themes.getLength() != 1) {
-            return null;
+        if (themes == null || themes.getLength() == 0) {
+            throw new ServerException(ERROR_NO_STYLES_FOUND);
         }
 
         Element e = (Element) themes.item(0);

http://dive4elements.wald.intevation.org