Mercurial > dive4elements > gnv-client
annotate gnv/src/main/java/de/intevation/gnv/util/XMLUtils.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 | 3549253ecd7b |
children |
rev | line source |
---|---|
1022
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
964
diff
changeset
|
1 /* |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
964
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
964
diff
changeset
|
3 * |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
964
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:
964
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:
964
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:
964
diff
changeset
|
7 */ |
28a0628b11b0
Added license file and license header.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
964
diff
changeset
|
8 |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.gnv.util; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
10 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
11 import java.io.IOException; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
12 import java.io.InputStream; |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
13 import java.io.OutputStream; |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
14 import java.io.StringBufferInputStream; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
15 import java.io.StringWriter; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
16 |
35 | 17 import javax.xml.namespace.NamespaceContext; |
18 import javax.xml.namespace.QName; | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
19 import javax.xml.parsers.DocumentBuilder; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
20 import javax.xml.parsers.DocumentBuilderFactory; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
21 import javax.xml.parsers.ParserConfigurationException; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
22 import javax.xml.transform.Transformer; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
23 import javax.xml.transform.TransformerConfigurationException; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
24 import javax.xml.transform.TransformerException; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
25 import javax.xml.transform.TransformerFactory; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
26 import javax.xml.transform.TransformerFactoryConfigurationError; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
27 import javax.xml.transform.dom.DOMSource; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
28 import javax.xml.transform.stream.StreamResult; |
35 | 29 import javax.xml.xpath.XPath; |
30 import javax.xml.xpath.XPathConstants; | |
31 import javax.xml.xpath.XPathExpressionException; | |
32 import javax.xml.xpath.XPathFactory; | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
33 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
34 import org.apache.log4j.Logger; |
35 | 35 import org.w3c.dom.Attr; |
36 import org.w3c.dom.Document; | |
37 import org.w3c.dom.Element; | |
38 import org.w3c.dom.Node; | |
39 import org.w3c.dom.NodeList; | |
40 import org.xml.sax.SAXException; | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
41 |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
42 /** |
962 | 43 * This class provides many helper-Methods for handling different kinds of |
44 * XML-stuff. | |
45 * @author <a href="mailto:tim.englich@intevation.de">Tim Englich</a> | |
46 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
47 */ |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
48 public class XMLUtils { |
962 | 49 |
50 /** | |
51 * the logger, used to log exceptions and additonaly information | |
52 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
53 private static Logger logger = Logger.getLogger(XMLUtils.class); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
54 |
962 | 55 /** |
56 * Constructor | |
57 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
58 public XMLUtils() { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
59 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
60 |
962 | 61 /** |
62 * Class which could be used to create XML-Elements | |
63 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | |
64 * | |
65 */ | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
66 public static class ElementCreator { |
962 | 67 |
68 /** | |
69 * The document the elements should be placed in. | |
70 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
71 protected Document document; |
962 | 72 |
73 /** | |
74 * The namespace that should be used. | |
75 */ | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
76 protected String ns; |
962 | 77 |
78 /** | |
79 * The prefix of the namespace that should be used. | |
80 */ | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
81 protected String prefix; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
82 |
962 | 83 /** |
84 * Constructor | |
85 * @param document the document the elements should be placed in | |
86 * @param ns the namespace that should be used | |
87 * @param prefix the prefix of the namespace that should be used | |
88 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
89 public ElementCreator(Document document, String ns, String prefix) { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
90 this.document = document; |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
91 this.ns = ns; |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
92 this.prefix = prefix; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
93 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
94 |
962 | 95 /** |
96 * Creates a new element using the given name. | |
97 * @param name the name of the new element. | |
98 * @return the new element | |
99 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
100 public Element create(String name) { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
101 Element element = document.createElementNS(ns, name); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
102 element.setPrefix(prefix); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
103 return element; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
104 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
105 |
962 | 106 /** |
107 * Adds a new attribute to the given element. | |
108 * @param element the element where the attribute should be placed in. | |
109 * @param name the name of the attribute | |
110 * @param value the value of the attribute | |
111 */ | |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
112 public void addAttr(Element element, String name, String value) { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
113 Attr attr = document.createAttributeNS(ns, name); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
114 attr.setValue(value); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
115 attr.setPrefix(prefix); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
116 element.setAttributeNode(attr); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
117 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
118 } // class ElementCreator |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
119 |
962 | 120 /** |
121 * Creates a new document. | |
122 * @return the new document | |
123 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
124 public static Document newDocument() { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
125 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
126 return DocumentBuilderFactory.newInstance().newDocumentBuilder() |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
127 .newDocument(); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
128 } catch (ParserConfigurationException pce) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
129 logger.error(pce.getLocalizedMessage(), pce); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
130 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
131 return null; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
132 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
133 |
962 | 134 /** |
135 * Creates a new <code>XPath</code>-expression | |
136 * @return the new <code>XPath</code>-expression | |
137 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
138 public static XPath newXPath() { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
139 return newXPath(null); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
140 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
141 |
962 | 142 /** |
143 * Creates a new <code>XPath</code>-expression | |
144 * @param namespaceContext the namespacecontext that should be used. | |
145 * @return the new <code>XPath</code>-expression | |
146 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
147 public static XPath newXPath(NamespaceContext namespaceContext) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
148 XPathFactory factory = XPathFactory.newInstance(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
149 XPath xpath = factory.newXPath(); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
150 if (namespaceContext != null) { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
151 xpath.setNamespaceContext(namespaceContext); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
152 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
153 return xpath; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
154 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
155 |
962 | 156 /** |
157 * Fetch the value of an element or attribute from the given resource | |
158 * using the query. | |
159 * @param root the source where the value should be fetch from | |
160 * @param query the query that should be used to fetch the value | |
161 * @param namespaceContext the namespacecontext that must match to | |
162 * fetch the value. | |
163 * @return the value | |
164 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
165 public static final String xpathString(Object root, String query, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
166 NamespaceContext namespaceContext) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
167 return (String) xpath(root, query, XPathConstants.STRING, |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
168 namespaceContext); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
169 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
170 |
962 | 171 /** |
172 * Fetch the object rom the given resource using the query. | |
173 * @param root the source where the value should be fetch from | |
174 * @param query the query that should be used to fetch the object | |
175 * @param returnType the Type that must be used to return the object, | |
176 * @param namespaceContext the namespacecontext that must match to | |
177 * fetch the object. | |
178 * @return the value | |
179 */ | |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
180 public static final Object xpath(Object root, String query, |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
181 QName returnType, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
182 NamespaceContext namespaceContext) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
183 if (root == null) { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
184 return null; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
185 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
186 try { |
962 | 187 XPath xpath = XMLUtils.newXPath(namespaceContext); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
188 if (xpath != null) { |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
189 return xpath.evaluate(query, root, returnType); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
190 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
191 } catch (XPathExpressionException xpee) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
192 logger.error(xpee.getLocalizedMessage(), xpee); |
35 | 193 } |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
194 return null; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
195 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
196 |
962 | 197 /** |
198 * Fetch the object rom the given resource using the query | |
199 * and the default <code>ArtifactNamespaceContext</code> | |
200 * @param root the source where the value should be fetch from | |
201 * @param query the query that should be used to fetch the object | |
202 * @param returnType the Type that must be used to return the object | |
203 * @return the value | |
204 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
205 public static Object getXPath(Object root, String query, QName returnType) { |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
206 return getXPath(root,query,returnType,ArtifactNamespaceContext.INSTANCE); |
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
207 } |
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
208 |
962 | 209 /** |
210 * Fetch the object rom the given resource using the query | |
211 * and the default <code>ArtifactNamespaceContext</code> | |
212 * @param root the source where the value should be fetch from | |
213 * @param query the query that should be used to fetch the object | |
214 * @param returnType the Type that must be used to return the object. | |
964
3549253ecd7b
Fixed some warnings which were displaied during the javadoc-generation
Tim Englich <tim.englich@intevation.de>
parents:
962
diff
changeset
|
215 * @param context the namespacecontext that must match to |
962 | 216 * fetch the object. |
217 * @return the value | |
218 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
219 public static Object getXPath( |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
220 Object root, String query, QName returnType, NamespaceContext context |
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
221 ) { |
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
222 return xpath(root, query, returnType, context); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
223 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
224 |
962 | 225 /** |
226 * Fetch a Nodeset value from a XML-Fragment or XML-Document using the | |
227 * given query. | |
228 * @param root the source where the String should be fetched from | |
229 * @param query the query that should be used, | |
230 * @return the Nodeset fetched from the source | |
231 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
232 public static NodeList getNodeSetXPath(Object root, String query) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
233 return (NodeList) getXPath(root, query, XPathConstants.NODESET); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
234 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
235 |
962 | 236 /** |
237 * Fetch a Node from a XML-Fragment or XML-Document using the | |
238 * given query. | |
239 * @param root the source where the Node should be fetched from | |
240 * @param query the query that should be used, | |
241 * @return the Node fetched from the source | |
242 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
243 public static Node getNodeXPath(Object root, String query) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
244 return (Node) getXPath(root, query, XPathConstants.NODE); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
245 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
246 |
962 | 247 /** |
248 * Fetch a String value from a XML-Fragment or XML-Document using the | |
249 * given query. | |
250 * @param root the source where the String should be fetched from | |
251 * @param xpath the query that should be used, | |
252 * @return the String fetched from the source | |
253 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
254 public static String getStringXPath(Object root, String xpath) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
255 return getStringXPath(root, xpath, null); |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
256 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
257 |
962 | 258 /** |
259 * Fetch a String value from a XML-Fragment or XML-Document using the | |
260 * given query. | |
261 * @param root the source where the String should be fetched from | |
262 * @param query the query that should be used, | |
263 * @param def the default-value that will be returned id no value was found | |
264 * @return the String fetched from the source | |
265 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
266 public static String getStringXPath(Object root, String query, String def) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
267 String s = (String) getXPath(root, query, XPathConstants.STRING); |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
268 return s == null || s.length() == 0 ? def : s; |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
269 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
270 |
962 | 271 /** |
272 * Reads an XML-document from a given <code>InputStream</code> | |
273 * @param inputStream the <code>InputStream</code> where the document | |
274 * should be read from | |
275 * @return the document that could be read. | |
276 */ | |
570
cbd397712ecf
Render an OpenLayers map with the layer even published after triggering shapefile and mapfile creation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
389
diff
changeset
|
277 public static Document readDocument(InputStream inputStream) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
278 Document returnValue = null; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
279 try { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
280 DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
281 .newInstance(); |
389
416ff31f6273
Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
38
diff
changeset
|
282 docBuilderFactory.setNamespaceAware(true); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
283 DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
284 returnValue = docBuilder.parse(inputStream); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
285 } catch (ParserConfigurationException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
286 logger.error(e, e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
287 } catch (SAXException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
288 logger.error(e, e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
289 } catch (IOException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
290 logger.error(e, e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
291 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
292 return returnValue; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
293 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
294 |
962 | 295 /** |
296 * Writes an single <code>XML-Node</code> to a string | |
297 * @param node the <code>XML-Node</code> that should be written | |
298 * @return the encoded <code>XML-Node</code> | |
299 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
300 public static String writeNode2String(Node node) { |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
301 try { |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
302 DOMSource source = new DOMSource(node); |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
303 return writeDOMSource2String(source); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
304 } catch (TransformerConfigurationException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
305 logger.error(e, e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
306 } catch (TransformerFactoryConfigurationError e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
307 logger.error(e, e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
308 } catch (TransformerException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
309 logger.error(e, e); |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
310 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
311 return null; |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
312 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
313 |
962 | 314 /** |
315 * Reinitialize the doument. | |
316 * This is neccessary because the namespace sometimes is invalid | |
317 * using a document which was created and used in the same step. | |
318 * @param document the document which should be reinitialize | |
319 * @return the document | |
320 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
321 public static Document reInitDocument(Document document) { |
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
322 StringBufferInputStream inputStream = new StringBufferInputStream( |
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
323 writeDocument2String(document)); |
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
324 return readDocument(inputStream); |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
325 } |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
326 |
962 | 327 /** |
328 * Writes the given Document into a String. | |
329 * This is very helpful for debugging. | |
330 * @param document the document which should be written to the string. | |
331 * @return the encoded xml-document. | |
332 */ | |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
333 public static String writeDocument2String(Document document) { |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
334 try { |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
335 DOMSource source = new DOMSource(document); |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
336 return writeDOMSource2String(source); |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
337 } catch (TransformerConfigurationException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
338 logger.error(e, e); |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
339 } catch (TransformerFactoryConfigurationError e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
340 logger.error(e, e); |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
341 } catch (TransformerException e) { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
342 logger.error(e, e); |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
343 } |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
344 return null; |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
345 } |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
346 |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
347 /** |
962 | 348 * Writes a given <code>DOMSource</code> into a String |
349 * @param source the source that should be written to string | |
350 * @return the encoded <code>DOMSource</code> | |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
351 * @throws TransformerFactoryConfigurationError |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
352 * @throws TransformerConfigurationException |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
353 * @throws TransformerException |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
354 */ |
585
2e690cb2247c
Show information about MapServer path and layer name after publishing calculated shapefiles as wms. Use MapServer settings configured in conf.xml to feed OpenLayers client.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
570
diff
changeset
|
355 private static String writeDOMSource2String(DOMSource source) |
38
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
356 throws TransformerFactoryConfigurationError, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
357 TransformerConfigurationException, |
fccf90761825
Format Code to max 80 Chars per Row better Formatter choosen
Tim Englich <tim.englich@intevation.de>
parents:
36
diff
changeset
|
358 TransformerException { |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
359 TransformerFactory transformerFactory = TransformerFactory |
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
360 .newInstance(); |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
361 Transformer transformer = transformerFactory.newTransformer(); |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
362 StringWriter sw = new StringWriter(); |
36
ad381cc47217
Format Code to max 80 Chars per Row
Tim Englich <tim.englich@intevation.de>
parents:
35
diff
changeset
|
363 StreamResult result = new StreamResult(sw); |
11
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
364 transformer.transform(source, result); |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
365 return sw.getBuffer().toString(); |
3cb753564552
Integration of the required XSL-Transformation of the Describe-Response of the Artifactdatabase
Tim Englich <tim.englich@intevation.de>
parents:
2
diff
changeset
|
366 } |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
367 |
962 | 368 /** |
369 * Writes a given Document to an <code>OutputStream</code> | |
370 * @param document the document that should be written | |
371 * @param out the stream where the document should be written to, | |
372 * @return true if it was successful, false if not. | |
373 */ | |
374 public static boolean toStream(Document document, OutputStream out) { | |
670
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
375 try { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
376 Transformer transformer = |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
377 TransformerFactory.newInstance().newTransformer(); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
378 DOMSource source = new DOMSource(document); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
379 StreamResult result = new StreamResult(out); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
380 transformer.transform(source, result); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
381 return true; |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
382 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
383 catch (TransformerConfigurationException tce) { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
384 logger.error(tce.getLocalizedMessage(), tce); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
385 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
386 catch (TransformerFactoryConfigurationError tfce) { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
387 logger.error(tfce.getLocalizedMessage(), tfce); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
388 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
389 catch (TransformerException te) { |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
390 logger.error(te.getLocalizedMessage(), te); |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
391 } |
b89b31293772
Implemented first things to store/load projects.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
585
diff
changeset
|
392 return false; |
681
15ac78a91d1b
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
670
diff
changeset
|
393 } |
2
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
394 } |
5e94403971af
infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff
changeset
|
395 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |