comparison 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
comparison
equal deleted inserted replaced
1309:a95e82d6bcc1 1310:c4c957a9c092
33 { 33 {
34 public static final String XPATH_RESULT = "/art:result/text()"; 34 public static final String XPATH_RESULT = "/art:result/text()";
35 35
36 public static final String OPERATION_FAILURE = "FAILED"; 36 public static final String OPERATION_FAILURE = "FAILED";
37 37
38 public static final String ERROR_NO_STYLES_FOUND =
39 "error_no_theme_styles_found";
40
38 41
39 public CollectionItemAttribute getCollectionItemAttribute( 42 public CollectionItemAttribute getCollectionItemAttribute(
40 Collection collection, 43 Collection collection,
41 String artifact, 44 String artifact,
42 String url, 45 String url,
74 return readXML (res, artifact); 77 return readXML (res, artifact);
75 } 78 }
76 catch (ConnectionException ce) { 79 catch (ConnectionException ce) {
77 System.err.println(ce.getLocalizedMessage()); 80 System.err.println(ce.getLocalizedMessage());
78 } 81 }
79 throw new ServerException(""); 82
83 throw new ServerException(ERROR_NO_STYLES_FOUND);
80 } 84 }
81 85
82 86
83 public void setCollectionItemAttribute( 87 public void setCollectionItemAttribute(
84 Collection collection, 88 Collection collection,
106 System.err.println(ce.getLocalizedMessage()); 110 System.err.println(ce.getLocalizedMessage());
107 } 111 }
108 throw new ServerException(""); 112 throw new ServerException("");
109 } 113 }
110 114
111 protected CollectionItemAttribute readXML (Document doc, String artifact) { 115 protected CollectionItemAttribute readXML(Document doc, String artifact)
116 throws ServerException
117 {
112 CollectionItemAttribute cia = new CollectionItemAttribute(); 118 CollectionItemAttribute cia = new CollectionItemAttribute();
113 cia.setArtifact(artifact); 119 cia.setArtifact(artifact);
114 120
115 Element root = doc.getDocumentElement(); 121 Element root = doc.getDocumentElement();
116 NodeList themes = root.getElementsByTagName("art:themes"); 122 NodeList themes = root.getElementsByTagName("art:themes");
117 123
118 if (themes.getLength() != 1) { 124 if (themes == null || themes.getLength() == 0) {
119 return null; 125 throw new ServerException(ERROR_NO_STYLES_FOUND);
120 } 126 }
121 127
122 Element e = (Element) themes.item(0); 128 Element e = (Element) themes.item(0);
123 NodeList items = e.getElementsByTagName("theme"); 129 NodeList items = e.getElementsByTagName("theme");
124 130

http://dive4elements.wald.intevation.org