annotate gnv/src/main/java/de/intevation/gnv/action/LoadAction.java @ 991:33198e55371c

Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection. gnv/trunk@1192 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 10 Jun 2010 15:13:08 +0000
parents 0441e78cd900
children 28a0628b11b0
rev   line source
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.gnv.action;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
683
d49e8695786c Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 673
diff changeset
3 import java.io.IOException;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.io.InputStream;
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
5 import java.util.List;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import javax.servlet.http.HttpServletRequest;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import javax.servlet.http.HttpServletResponse;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import org.apache.commons.fileupload.FileItemIterator;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import org.apache.commons.fileupload.FileItemStream;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import org.apache.commons.fileupload.servlet.ServletFileUpload;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import org.apache.log4j.Logger;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import org.apache.struts.action.ActionForm;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import org.apache.struts.action.ActionForward;
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
16 import org.apache.struts.action.ActionMapping;
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
17 import org.w3c.dom.Document;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
19 import de.intevation.gnv.action.sessionmodel.SessionModel;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
20 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
21 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
22 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
23 import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
24 import de.intevation.gnv.artifactdatabase.objects.Artifact;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
25 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
26 import de.intevation.gnv.util.ArtifactNamespaceContext;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
27 import de.intevation.gnv.util.XMLUtils;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
30 * This controller is called for reloading projects from xml files. It waits for
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
31 * an xml document named 'document' and feeds the artifact server with this
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
32 * document. After a successful feed, the artifact description is fetched and
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
33 * displayed in the gui.
699
af22fa5567a6 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 690
diff changeset
34 *
684
57fa8019fbdc Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 683
diff changeset
35 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 */
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public class LoadAction extends ArtifactDatabaseActionBase {
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
39 public static final String RESOURCE_UPLOAD_FAILURE = "upload.failure";
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
40 public static final String RESOURCE_INVALID_ARTIFACT = "invalid.artifact";
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
42 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
43 * the logger, used to log exceptions and additonaly information
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
44 */
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 private static Logger logger = Logger.getLogger(LoadAction.class);
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
47 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
48 * Constructor
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
49 */
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50 public LoadAction() {
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 super();
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
54 @Override
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55 public ActionForward execute(
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 ActionMapping mapping,
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 ActionForm form,
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 HttpServletRequest request,
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 HttpServletResponse response)
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 throws Exception
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 {
991
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 963
diff changeset
62 if (isSessionExhausted(request)) {
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 963
diff changeset
63 return sessionExhaustedForward(mapping, form, request, response);
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 963
diff changeset
64 }
33198e55371c Improved session handling in the gui. If a session has timed out, the user gets to the start point - the fis selection.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 963
diff changeset
65
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 logger.info("Import artifact.");
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 ServletFileUpload upload = new ServletFileUpload();
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 Document artifactDocument = null;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
71 try {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
72 FileItemIterator iter = upload.getItemIterator(request);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
73 while (iter.hasNext()) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
74 FileItemStream item = (FileItemStream) iter.next();
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
75 String name = item.getFieldName();
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
77 // the file input field of our form is named 'document'
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
78 if (name.equals("document")) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
79 InputStream stream = item.openStream();
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
80
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
81 if (stream.available() == 0) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
82 logger.error("No artifact document found.");
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
83 request.setAttribute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
84 CommunicationKeys.REQUEST_EXCEPTION_PROJECT,
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
85 RESOURCE_UPLOAD_FAILURE);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
86
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
87 return super.getExceptionForward(mapping);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
88 }
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
89
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
90 artifactDocument = XMLUtils.readDocument(stream);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
91 if (artifactDocument == null) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
92 request.setAttribute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
93 CommunicationKeys.REQUEST_EXCEPTION_PROJECT,
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
94 RESOURCE_INVALID_ARTIFACT);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
95
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
96 return super.getExceptionForward(mapping);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
97 }
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
98
714
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
99 try {
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
100 ArtifactDatabaseClientFactory adcf =
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
101 ArtifactDatabaseClientFactory.getInstance();
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
102 ArtifactDatabaseClient adc =
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
103 adcf.getArtifactDatabaseClient(getLocale(request));
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
104 ArtifactFactory factory = (ArtifactFactory)
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
105 (( List)adc.getArtifactFactories()).get(0);
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
106
714
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
107 SessionModelFactory sf =
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
108 SessionModelFactory.getInstance();
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
109 SessionModel sm = sf.getSessionModel(request);
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
110 sm.selectArtifactFactory(factory.getId());
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
111
714
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
112 Document describe = adc.doImport(
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
113 factory,
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
114 artifactDocument);
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
115
714
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
116 String uuid = XMLUtils.xpathString(
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
117 describe,
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
118 "/art:result/art:uuid/@value",
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
119 ArtifactNamespaceContext.INSTANCE);
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
120 String hash = XMLUtils.xpathString(
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
121 describe,
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
122 "/art:result/art:hash/@value",
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
123 ArtifactNamespaceContext.INSTANCE);
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
124
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
125 Artifact artifact = new Artifact(uuid, hash);
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
126 sm.setCurrentArtifact(artifact);
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
127
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
128 if (logger.isDebugEnabled()) {
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
129 logger.debug(
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
130 "Imported artifact UUID: "+artifact.getId());
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
131 logger.debug(
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
132 "Imported artifact HASH: "+artifact.getHash());
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
133 }
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
134 }
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
135 catch (ArtifactDatabaseClientException adce) {
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
136 logger.error(adce, adce);
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
137 request.setAttribute(
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
138 CommunicationKeys.REQUEST_EXCEPTION_MESSAGE_ID,
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
139 adce.getMessage());
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
140
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
141 // XXX
21735fb8d29b Display an error message if the artifact server is down but the user tried to load an artifat (issue258).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 699
diff changeset
142 return super.getExceptionForward(mapping);
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
143 }
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
144
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
145 return new DescribeUIAction().execute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
146 mapping, form, request, response);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
147 }
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 }
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
150 catch (IOException ioe) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
151 logger.error(ioe, ioe);
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 request.setAttribute(
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 CommunicationKeys.REQUEST_EXCEPTION_PROJECT,
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
154 ioe.getMessage());
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 return super.getExceptionForward(mapping);
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
159 // no document found or not valid
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
160 logger.error("Upload failure: No document found or invalid.");
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
161
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
162 request.setAttribute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
163 CommunicationKeys.REQUEST_EXCEPTION_PROJECT,
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
164 RESOURCE_UPLOAD_FAILURE);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
165
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
166 return super.getExceptionForward(mapping);
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org