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
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
17 import javax.xml.namespace.NamespaceContext;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
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
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
29 import javax.xml.xpath.XPath;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
30 import javax.xml.xpath.XPathConstants;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
31 import javax.xml.xpath.XPathExpressionException;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
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
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
35 import org.w3c.dom.Attr;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
36 import org.w3c.dom.Document;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
37 import org.w3c.dom.Element;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
38 import org.w3c.dom.Node;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
39 import org.w3c.dom.NodeList;
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
43 * 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
44 * XML-stuff.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
45 * @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
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
49
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
50 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
51 * the logger, used to log exceptions and additonaly information
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
55 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
56 * Constructor
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
61 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
62 * Class which could be used to create XML-Elements
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
63 * @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
64 *
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
67
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
68 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
69 * The document the elements should be placed in.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
70 */
2
5e94403971af infrastructur for Communicationg with the ArtifactDatabase added.
Tim Englich <tim.englich@intevation.de>
parents:
diff changeset
71 protected Document document;
962
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
72
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
73 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
74 * The namespace that should be used.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
77
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
78 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
79 * The prefix of the namespace that should be used.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
83 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
84 * Constructor
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
85 * @param document the document the elements should be placed in
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
86 * @param ns the namespace that should be used
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
87 * @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
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
95 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
96 * Creates a new element using the given name.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
97 * @param name the name of the new element.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
98 * @return the new element
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
106 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
107 * Adds a new attribute to the given element.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
108 * @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
109 * @param name the name of the attribute
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
110 * @param value the value of the attribute
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
120 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
121 * Creates a new document.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
122 * @return the new document
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
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 * @return the new <code>XPath</code>-expression
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
142 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
143 * Creates a new <code>XPath</code>-expression
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
144 * @param namespaceContext the namespacecontext that should be used.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
145 * @return the new <code>XPath</code>-expression
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
156 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
157 * 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
158 * using the query.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
159 * @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
160 * @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
161 * @param namespaceContext the namespacecontext that must match to
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
162 * fetch the value.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
163 * @return the value
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
171 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
172 * Fetch the object rom the given resource using the query.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
173 * @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
174 * @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
175 * @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
176 * @param namespaceContext the namespacecontext that must match to
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
177 * fetch the object.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
178 * @return the value
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
4405f31bbc30 CodeCleanUP
Tim Englich <tim.englich@intevation.de>
parents: 11
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
197 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
198 * Fetch the object rom the given resource using the query
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
199 * and the default <code>ArtifactNamespaceContext</code>
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
200 * @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
201 * @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
202 * @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
203 * @return the value
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
209 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
210 * Fetch the object rom the given resource using the query
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
211 * and the default <code>ArtifactNamespaceContext</code>
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
212 * @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
213 * @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
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
216 * fetch the object.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
217 * @return the value
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
225 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
226 * 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
227 * given query.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
228 * @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
229 * @param query the query that should be used,
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
230 * @return the Nodeset fetched from the source
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
236 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
237 * 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
238 * given query.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
239 * @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
240 * @param query the query that should be used,
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
241 * @return the Node fetched from the source
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
247 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
248 * 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
249 * given query.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
250 * @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
251 * @param xpath the query that should be used,
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
252 * @return the String fetched from the source
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
258 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
259 * 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
260 * given query.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
261 * @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
262 * @param query the query that should be used,
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
263 * @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
264 * @return the String fetched from the source
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
271 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
272 * Reads an XML-document from a given <code>InputStream</code>
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
273 * @param inputStream the <code>InputStream</code> where the document
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
274 * should be read from
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
275 * @return the document that could be read.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
295 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
296 * Writes an single <code>XML-Node</code> to a string
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
297 * @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
298 * @return the encoded <code>XML-Node</code>
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
314 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
315 * Reinitialize the doument.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
316 * This is neccessary because the namespace sometimes is invalid
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
317 * 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
318 * @param document the document which should be reinitialize
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
319 * @return the document
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
327 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
328 * Writes the given Document into a String.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
329 * This is very helpful for debugging.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
330 * @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
331 * @return the encoded xml-document.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
348 * Writes a given <code>DOMSource</code> into a String
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
349 * @param source the source that should be written to string
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
368 /**
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
369 * Writes a given Document to an <code>OutputStream</code>
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
370 * @param document the document that should be written
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
371 * @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
372 * @return true if it was successful, false if not.
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
373 */
e7fda0ae8b92 Add more Javadocs
Tim Englich <tim.englich@intevation.de>
parents: 683
diff changeset
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:

http://dive4elements.wald.intevation.org