Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.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 | 88c530c25968 |
children | 924da6695800 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java Fri Apr 08 08:45:15 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/StepForwardServiceImpl.java Fri Apr 08 08:51:28 2011 +0000 @@ -11,6 +11,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.Artifact; import de.intevation.flys.client.shared.model.ArtifactDescription; import de.intevation.flys.client.shared.model.Data; @@ -28,11 +29,15 @@ extends AdvanceServiceImpl implements StepForwardService { - /** XPath that points to the result text of a feed or advance operation.*/ - public static final String XPATH_RESULT = "/art:result/text()"; + /** XPath that points to the result type of a feed or advance operation.*/ + public static final String XPATH_RESULT = "/art:result/@art:type"; /** A constant that marks errors.*/ - public static final String OPERATION_FAILURE = "FAILED"; + public static final String OPERATION_FAILURE = "FAILURE"; + + /** The error message key that is thrown if an error occured while feeding + * new data.*/ + public static final String ERROR_FEED_DATA = "error_feed_data"; /** @@ -45,13 +50,14 @@ * * @return the modified artifact. */ - public Artifact go(String serverUrl, Artifact artifact, Data[] data) { + public Artifact go(String serverUrl, Artifact artifact, Data[] data) + throws ServerException + { Artifact afterFeed = feed(serverUrl, artifact, data); if (afterFeed == null) { System.err.println("StepForwardService.feed() - FAILED"); - // XXX Better handling here! - return null; + throw new ServerException(ERROR_FEED_DATA); } ArtifactDescription desc = afterFeed.getArtifactDescription(); @@ -78,7 +84,9 @@ * * @return a new artifact parsed from the description of FEED. */ - protected Artifact feed(String serverUrl, Artifact artifact, Data[] data) { + protected Artifact feed(String serverUrl, Artifact artifact, Data[] data) + throws ServerException + { Document feed = ClientProtocolUtils.newFeedDocument( artifact.getUuid(), artifact.getHash(), @@ -96,7 +104,7 @@ if (description == null) { System.err.println("StepForwardService.feed() - FAILED"); - return artifact; + throw new ServerException(ERROR_FEED_DATA); } String result = XMLUtils.xpathString( @@ -108,14 +116,16 @@ System.out.println("StepForwardService.feed() - SUCCESS"); return (Artifact) new FLYSArtifactCreator().create(description); } + else if (result != null && result.equals(OPERATION_FAILURE)) { + throw new ServerException(ERROR_FEED_DATA); + } } catch (ConnectionException ce) { System.err.println(ce.getLocalizedMessage()); } System.err.println("StepForwardService.feed() - FAILED"); - - return artifact; + throw new ServerException(ERROR_FEED_DATA); }