Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/action/LoadAction.java @ 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 | af22fa5567a6 |
children | 0441e78cd900 |
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 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
3 import de.intevation.gnv.action.sessionmodel.SessionModel; |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
4 import de.intevation.gnv.action.sessionmodel.SessionModelFactory; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
673
diff
changeset
|
5 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
6 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient; |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
7 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
673
diff
changeset
|
8 |
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
|
9 import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException; |
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
|
10 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
11 import de.intevation.gnv.artifactdatabase.objects.Artifact; |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
12 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
673
diff
changeset
|
13 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
14 import de.intevation.gnv.util.ArtifactNamespaceContext; |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.gnv.util.XMLUtils; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
673
diff
changeset
|
17 import java.io.IOException; |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import java.io.InputStream; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
673
diff
changeset
|
19 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
20 import java.util.List; |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 import javax.servlet.http.HttpServletRequest; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import javax.servlet.http.HttpServletResponse; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import org.apache.commons.fileupload.FileItemIterator; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import org.apache.commons.fileupload.FileItemStream; |
683
d49e8695786c
Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
673
diff
changeset
|
27 |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 import org.apache.commons.fileupload.servlet.ServletFileUpload; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 import org.apache.log4j.Logger; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 import org.apache.struts.action.ActionForm; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 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
|
34 import org.apache.struts.action.ActionMapping; |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 import org.w3c.dom.Document; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 /** |
690
254f062e334b
Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
684
diff
changeset
|
39 * 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
|
40 * 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
|
41 * document. After a successful feed, the artifact description is fetched and |
254f062e334b
Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
684
diff
changeset
|
42 * displayed in the gui. |
699
af22fa5567a6
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
690
diff
changeset
|
43 * |
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
|
44 * @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
|
45 */ |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 public class LoadAction extends ArtifactDatabaseActionBase { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
48 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
|
49 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
|
50 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 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
|
52 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public LoadAction() { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 super(); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 public ActionForward execute( |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 ActionMapping mapping, |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 ActionForm form, |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 HttpServletRequest request, |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 HttpServletResponse response) |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 throws Exception |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 logger.info("Import artifact."); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 ServletFileUpload upload = new ServletFileUpload(); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 Document artifactDocument = null; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
69 try { |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
70 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
|
71 while (iter.hasNext()) { |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
72 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
|
73 String name = item.getFieldName(); |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
75 // 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
|
76 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
|
77 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
|
78 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
79 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
|
80 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
|
81 request.setAttribute( |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
82 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
|
83 RESOURCE_UPLOAD_FAILURE); |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
84 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
85 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
|
86 } |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
87 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
88 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
|
89 if (artifactDocument == null) { |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
90 request.setAttribute( |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
91 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
|
92 RESOURCE_INVALID_ARTIFACT); |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
93 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
94 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
|
95 } |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
96 |
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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 (( 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
|
104 |
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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 |
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
|
110 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
|
111 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
|
112 artifactDocument); |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
113 |
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
|
114 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
|
115 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
|
116 "/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
|
117 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
|
118 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
|
119 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
|
120 "/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
|
121 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
|
122 |
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 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
|
124 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
|
125 |
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 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
|
127 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
|
128 "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
|
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 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
|
131 } |
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 } |
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 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
|
134 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
|
135 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
|
136 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
|
137 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
|
138 |
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 // 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
|
140 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
|
141 } |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
142 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
143 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
|
144 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
|
145 } |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
147 } |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
148 catch (IOException ioe) { |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
149 logger.error(ioe, ioe); |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 request.setAttribute( |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 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
|
152 ioe.getMessage()); |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 return super.getExceptionForward(mapping); |
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 |
673
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
157 // 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
|
158 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
|
159 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
160 request.setAttribute( |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
161 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
|
162 RESOURCE_UPLOAD_FAILURE); |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
163 |
93b4dedc4e37
Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
670
diff
changeset
|
164 return super.getExceptionForward(mapping); |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |