annotate gnv/src/main/java/de/intevation/gnv/util/XMLUtils.java @ 964:3549253ecd7b

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

http://dive4elements.wald.intevation.org