changeset 714:21735fb8d29b

Display an error message if the artifact server is down but the user tried to load an artifat (issue258). gnv/trunk@985 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 26 Apr 2010 10:32:22 +0000
parents c84147a3105c
children 0aeac0fe5db2
files gnv/ChangeLog gnv/src/main/java/de/intevation/gnv/action/LoadAction.java
diffstat 2 files changed, 51 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/gnv/ChangeLog	Mon Apr 26 09:36:40 2010 +0000
+++ b/gnv/ChangeLog	Mon Apr 26 10:32:22 2010 +0000
@@ -1,3 +1,11 @@
+2010-04-26  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	  Issue258
+
+	* src/main/java/de/intevation/gnv/action/LoadAction.java: An error message
+	  is displayed if the user tried to load an existing project and the
+	  artifact server is down.
+
 2010-04-26  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	  Issue259
--- a/gnv/src/main/java/de/intevation/gnv/action/LoadAction.java	Mon Apr 26 09:36:40 2010 +0000
+++ b/gnv/src/main/java/de/intevation/gnv/action/LoadAction.java	Mon Apr 26 10:32:22 2010 +0000
@@ -6,6 +6,8 @@
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
 
+import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException;
+
 import de.intevation.gnv.artifactdatabase.objects.Artifact;
 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory;
 
@@ -92,36 +94,50 @@
                         return super.getExceptionForward(mapping);
                     }
 
-                    ArtifactDatabaseClientFactory adcf =
-                        ArtifactDatabaseClientFactory.getInstance();
-                    ArtifactDatabaseClient adc =
-                        adcf.getArtifactDatabaseClient(getLocale(request));
-                    ArtifactFactory factory = (ArtifactFactory)
-                        (( List)adc.getArtifactFactories()).get(0);
-
-                    SessionModelFactory sf = SessionModelFactory.getInstance();
-                    SessionModel        sm = sf.getSessionModel(request);
-                    sm.selectArtifactFactory(factory.getId());
-
-                    Document describe = adc.doImport(
-                        factory,
-                        artifactDocument);
+                    try {
+                        ArtifactDatabaseClientFactory adcf =
+                            ArtifactDatabaseClientFactory.getInstance();
+                        ArtifactDatabaseClient adc =
+                            adcf.getArtifactDatabaseClient(getLocale(request));
+                        ArtifactFactory factory = (ArtifactFactory)
+                            (( List)adc.getArtifactFactories()).get(0);
 
-                    String uuid = XMLUtils.xpathString(
-                        describe,
-                        "/art:result/art:uuid/@value",
-                        ArtifactNamespaceContext.INSTANCE);
-                    String hash = XMLUtils.xpathString(
-                        describe,
-                        "/art:result/art:hash/@value",
-                        ArtifactNamespaceContext.INSTANCE);
+                        SessionModelFactory sf =
+                            SessionModelFactory.getInstance();
+                        SessionModel        sm = sf.getSessionModel(request);
+                        sm.selectArtifactFactory(factory.getId());
 
-                    Artifact artifact = new Artifact(uuid, hash);
-                    sm.setCurrentArtifact(artifact);
+                        Document describe = adc.doImport(
+                            factory,
+                            artifactDocument);
 
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Imported artifact UUID: "+artifact.getId());
-                        logger.debug("Imported artifact HASH: "+artifact.getHash());
+                        String uuid = XMLUtils.xpathString(
+                            describe,
+                            "/art:result/art:uuid/@value",
+                            ArtifactNamespaceContext.INSTANCE);
+                        String hash = XMLUtils.xpathString(
+                            describe,
+                            "/art:result/art:hash/@value",
+                            ArtifactNamespaceContext.INSTANCE);
+
+                        Artifact artifact = new Artifact(uuid, hash);
+                        sm.setCurrentArtifact(artifact);
+
+                        if (logger.isDebugEnabled()) {
+                            logger.debug(
+                                "Imported artifact UUID: "+artifact.getId());
+                            logger.debug(
+                                "Imported artifact HASH: "+artifact.getHash());
+                        }
+                    }
+                    catch (ArtifactDatabaseClientException adce) {
+                        logger.error(adce, adce);
+                        request.setAttribute(
+                            CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID,
+                            adce.getMessage());
+
+                        // XXX
+                        return super.getExceptionForward(mapping);
                     }
 
                     return new DescribeUIAction().execute(

http://dive4elements.wald.intevation.org