annotate gnv/src/main/java/de/intevation/gnv/action/LoadAction.java @ 1022:28a0628b11b0

Added license file and license header. gnv/trunk@1258 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 02 Nov 2010 17:15:08 +0000
parents 33198e55371c
children
rev   line source
1022
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
1 /*
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
3 *
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
5 * Read the file LGPL.txt coming with the software for details
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
7 */
28a0628b11b0 Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 991
diff changeset
8
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 package de.intevation.gnv.action;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10
683
d49e8695786c Ordered imports. Removed needless imports. Removed empty headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 673
diff changeset
11 import java.io.IOException;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 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
13 import java.util.List;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 import javax.servlet.http.HttpServletRequest;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 import javax.servlet.http.HttpServletResponse;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import org.apache.commons.fileupload.FileItemIterator;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import org.apache.commons.fileupload.FileItemStream;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import org.apache.commons.fileupload.servlet.ServletFileUpload;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import org.apache.log4j.Logger;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import org.apache.struts.action.ActionForm;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 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
24 import org.apache.struts.action.ActionMapping;
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
25 import org.w3c.dom.Document;
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
27 import de.intevation.gnv.action.sessionmodel.SessionModel;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
28 import de.intevation.gnv.action.sessionmodel.SessionModelFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
29 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClient;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
30 import de.intevation.gnv.artifactdatabase.client.ArtifactDatabaseClientFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
31 import de.intevation.gnv.artifactdatabase.client.exception.ArtifactDatabaseClientException;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
32 import de.intevation.gnv.artifactdatabase.objects.Artifact;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
33 import de.intevation.gnv.artifactdatabase.objects.ArtifactFactory;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
34 import de.intevation.gnv.util.ArtifactNamespaceContext;
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
35 import de.intevation.gnv.util.XMLUtils;
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 /**
690
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
38 * 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
39 * 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
40 * document. After a successful feed, the artifact description is fetched and
254f062e334b Added JavaDoc.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 684
diff changeset
41 * displayed in the gui.
699
af22fa5567a6 Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 690
diff changeset
42 *
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
43 * @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
44 */
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 public class LoadAction extends ArtifactDatabaseActionBase {
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
47 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
48 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
49
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
50 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
51 * the logger, used to log exceptions and additonaly information
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
52 */
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 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
54
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
55 /**
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
56 * Constructor
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
57 */
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 public LoadAction() {
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 super();
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61
963
0441e78cd900 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 714
diff changeset
62 @Override
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 public ActionForward execute(
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64 ActionMapping mapping,
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 ActionForm form,
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 HttpServletRequest request,
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67 HttpServletResponse response)
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 throws Exception
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 {
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
70 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
71 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
72 }
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
73
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 logger.info("Import artifact.");
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 ServletFileUpload upload = new ServletFileUpload();
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 Document artifactDocument = null;
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
79 try {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
80 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
81 while (iter.hasNext()) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
82 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
83 String name = item.getFieldName();
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
85 // 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
86 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
87 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
88
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
89 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
90 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
91 request.setAttribute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
92 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
93 RESOURCE_UPLOAD_FAILURE);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
94
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
95 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
96 }
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 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
99 if (artifactDocument == null) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
100 request.setAttribute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
101 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
102 RESOURCE_INVALID_ARTIFACT);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
103
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
104 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
105 }
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 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
108 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
109 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
110 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
111 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
112 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
113 (( 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
114
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
115 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
116 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
117 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
118 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
119
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
120 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
121 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
122 artifactDocument);
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
123
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
124 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
125 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
126 "/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
127 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
128 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
129 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
130 "/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
131 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
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 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
134 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
135
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 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
137 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
138 "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
139 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
140 "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
141 }
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 }
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
143 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
144 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
145 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
146 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
147 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
148
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
149 // 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
150 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
151 }
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
152
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
153 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
154 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
155 }
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 }
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
158 catch (IOException ioe) {
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
159 logger.error(ioe, ioe);
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 request.setAttribute(
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 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
162 ioe.getMessage());
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 return super.getExceptionForward(mapping);
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
673
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
167 // 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
168 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
169
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
170 request.setAttribute(
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
171 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
172 RESOURCE_UPLOAD_FAILURE);
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
173
93b4dedc4e37 Implemented a mechanism to import artifacts from xml structured documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 670
diff changeset
174 return super.getExceptionForward(mapping);
670
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176 }
b89b31293772 Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org