changeset 207:b2115f484edb

Move Config and XMLUtils totally to commons package. artifacts/trunk@1476 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 15 Mar 2011 15:49:24 +0000
parents 33f58a847fc4
children 8ea4d0824d8f
files ChangeLog artifact-database/src/main/java/de/intevation/artifactdatabase/App.java artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java artifact-database/src/main/java/de/intevation/artifactdatabase/DatabaseCleaner.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultService.java artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultServiceFactory.java artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java artifact-database/src/main/java/de/intevation/artifactdatabase/XMLUtils.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactResource.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/BaseOutResource.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ServicesResource.java artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java
diffstat 21 files changed, 42 insertions(+), 597 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 15 15:25:43 2011 +0000
+++ b/ChangeLog	Tue Mar 15 15:49:24 2011 +0000
@@ -1,3 +1,14 @@
+2011-03-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	!!! THIS BREAKS THE GNV ARTIFACTS. !!! TODO: Adjust the imports there.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/XMLUtils.java,
+	  artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java:
+	  Deleted. The copies from the commons package are use now.
+
+	* artifact-database/src/main/java/de/intevation/artifactdatabase/**/*.java:
+	  Adjusted imports.
+
 2011-03-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* artifacts-common/src/main/java/de/intevation/artifacts/common/utils/Config.java:
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/App.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/App.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import de.intevation.artifactdatabase.rest.Standalone;
 
 import java.io.File;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ArtifactDatabaseImpl.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.XMLUtils;
+
 import de.intevation.artifactdatabase.Backend.PersistentArtifact;
 
 import de.intevation.artifacts.Artifact;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/Config.java	Tue Mar 15 15:25:43 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,276 +0,0 @@
-/*
- * Copyright (c) 2010 by Intevation GmbH
- *
- * This program is free software under the LGPL (>=v2.1)
- * Read the file LGPL.txt coming with the software for details
- * or visit http://www.gnu.org/licenses/ if it does not exist.
- */
-
-package de.intevation.artifactdatabase;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.xml.namespace.QName;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import javax.xml.xpath.XPathConstants;
-
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import org.xml.sax.SAXException;
-
-/**
- * The central access to the configuration of the artifact database.
- * This class provides some static methods to access the central
- * configuration XML file via XPath.
- *
- * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
- */
-public final class Config
-{
-    private static Logger logger = Logger.getLogger(Config.class);
-
-    /**
-     * System property name where to find the configuration directory.
-     */
-    public static final String CONFIG_DIR = "artifact.database.dir";
-
-    /**
-     * Default path to the configuration directory if none
-     * was specified by the CONFIG_DIR system property.
-     */
-    public static final File CONFIG_DIR_DEFAULT =
-        new File(new File(System.getProperty("user.home",
-            System.getProperty("user.dir", "."))), ".artifactdb");
-
-    /**
-     * Name of the central configuration XML file.
-     */
-    public static final String CONFIG_FILE  = "conf.xml";
-
-    /**
-     * Name of the configuration filename alias to be use
-     * within the configuration. This alias is replaced by
-     * the real path.
-     */
-    public static final String CONFIG_DIR_PLACEHOLDER =
-        "${artifacts.config.dir}";
-
-    private static Document config;
-
-    private Config() {
-    }
-
-    /**
-     * Singleton access to the central XML configuration document.
-     * @return The central XML configuration document.
-     */
-    public static synchronized final Document getConfig() {
-        if (config == null) {
-            config = loadConfig();
-        }
-        return config;
-    }
-
-    /**
-     * Returns the path to the configuartion directory. If a path
-     * was specified via the CONFIG_DIR system property this one
-     * is used. Else it falls back to default configuration path.
-     * @return The path to the configuartion directory.
-     */
-    public static File getConfigDirectory() {
-        String configDirString = System.getProperty(CONFIG_DIR);
-
-        File configDir = configDirString != null
-            ? new File(configDirString)
-            : CONFIG_DIR_DEFAULT;
-
-        if (!configDir.isDirectory()) {
-            logger.warn("'" + configDir + "' is not a directory.");
-            configDir = CONFIG_DIR_DEFAULT;
-        }
-
-        return configDir;
-    }
-
-    /**
-     * Replaces the CONFIG_DIR_PLACEHOLDER alias with the real path
-     * of the configuration directory.
-     * @param path The path containing the CONFIG_DIR_PLACEHOLDER placeholder.
-     * @return The path where the CONFIG_DIR_PLACEHOLDER placeholders are
-     * replaced by the real path name.
-     */
-    public static String replaceConfigDir(String path) {
-        String configDir = getConfigDirectory().getAbsolutePath();
-        return path.replace(CONFIG_DIR_PLACEHOLDER, configDir);
-    }
-
-    private static Document loadConfig() {
-
-        File configDir = getConfigDirectory();
-
-        File file = new File(configDir, CONFIG_FILE);
-
-        if (!file.canRead() && !file.isFile()) {
-            logger.error("Cannot read config file '"
-                + file + "'.");
-            return null;
-        }
-
-        try {
-            DocumentBuilderFactory factory =
-                DocumentBuilderFactory.newInstance();
-            factory.setValidating(false); // XXX: This may change in future.
-            return factory.newDocumentBuilder().parse(file);
-        }
-        catch (SAXException se) {
-            logger.error(se.getLocalizedMessage(), se);
-        }
-        catch (ParserConfigurationException pce) {
-            logger.error(pce.getLocalizedMessage(), pce);
-        }
-        catch (IOException ioe) {
-            logger.error(ioe.getLocalizedMessage());
-        }
-
-        return null;
-    }
-
-    /**
-     * Convenience method to search within a given document tree via XPath.
-     * See {@link XMLUtils#xpath(Object, String, QName) } for details.
-     * @param root The object which is used as the root of the tree to
-     * be searched in.
-     * @param query The XPath query.
-     * @param returnType The type of the result.
-     * @return The result of type 'returnTyp' or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final Object getXPath(
-        Object root, String query, QName returnType
-    ) {
-        return XMLUtils.xpath(root, query, returnType);
-    }
-
-    /**
-     * Convenience method to search within the central configuration via XPath.
-     * See {@link XMLUtils#xpath(Object, String, QName) } for details.
-     * @param query The XPath query.
-     * @param returnType The type of the result.
-     * @return The result of type 'returnTyp' or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final Object getXPath(String query, QName returnType) {
-        return XMLUtils.xpath(getConfig(), query, returnType);
-    }
-
-    /**
-     * Convenience method to search for a node list within the central
-     * configuation document via XPath.
-     * @param query The XPath query.
-     * @return The queried node list or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final NodeList getNodeSetXPath(String query) {
-        return (NodeList)getXPath(query, XPathConstants.NODESET);
-    }
-
-    /**
-     * Convenience method to search for a node within the central
-     * configuation document via XPath.
-     * @param query The XPath query.
-     * @return The queried node or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final Node getNodeXPath(String query) {
-        return (Node)getXPath(query, XPathConstants.NODE);
-    }
-
-    /**
-     * Convenience method to search for a string within the central
-     * configuation document via XPath.
-     * @param xpath The XPath query.
-     * @return The queried string or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final String getStringXPath(String xpath) {
-        return getStringXPath(xpath, null);
-    }
-
-    /**
-     * Convenience method to search for a string within the central
-     * configuation document via XPath.
-     * @param query The XPath query.
-     * @param def The string to be returned if the search has no results.
-     * @return The queried string or the default value if something went
-     * wrong during XPath evaluation.
-     */
-    public static final String getStringXPath(String query, String def) {
-        String s = (String)getXPath(query, XPathConstants.STRING);
-        return s == null || s.length() == 0
-            ? def
-            : s;
-    }
-
-    /**
-     * Convenience method to search for a node list within a given tree
-     * via XPath.
-     * @param root The root of the tree to be searched in.
-     * @param query The XPath query.
-     * @return The queried node list or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final NodeList getNodeSetXPath(Object root, String query) {
-        return (NodeList)getXPath(root, query, XPathConstants.NODESET);
-    }
-
-    /**
-     * Convenience method to search for a node within a given tree
-     * via XPath.
-     * @param root The root of the tree to be searched in.
-     * @param query The XPath query.
-     * @return The queried node or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final Node getNodeXPath(Object root, String query) {
-        return (Node)getXPath(root, query, XPathConstants.NODE);
-    }
-
-    /**
-     * Convenience method to search for a string within a given tree
-     * via XPath.
-     * @param root The root of the tree to be searched in.
-     * @param xpath The XPath query.
-     * @return The queried string or null if something went
-     * wrong during XPath evaluation.
-     */
-    public static final String getStringXPath(Object root, String xpath) {
-        return getStringXPath(root, xpath, null);
-    }
-
-    /**
-     * Convenience method to search for a string within a given tree
-     * via XPath.
-     * @param root The root of the tree to be searched in.
-     * @param query xpath The XPath query.
-     * @param def The string to be returned if the search has no results.
-     * @return The queried string or the default value if something went
-     * wrong during XPath evaluation.
-     */
-    public static final String getStringXPath(
-        Object root, String query, String def
-    ) {
-        String s = (String)getXPath(root, query, XPathConstants.STRING);
-        return s == null || s.length() == 0
-            ? def
-            : s;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DBConnection.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import java.io.File;
 
 import java.sql.SQLException;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DatabaseCleaner.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DatabaseCleaner.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import de.intevation.artifacts.Artifact;
 
 import java.sql.Connection;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifact.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.XMLUtils;
+
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.CallContext;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollection.java	Tue Mar 15 15:49:24 2011 +0000
@@ -9,6 +9,7 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactCollectionFactory.java	Tue Mar 15 15:49:24 2011 +0000
@@ -7,6 +7,8 @@
  */
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Document;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.ArtifactFactory;
 import de.intevation.artifacts.ArtifactSerializer;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultService.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultService.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.XMLUtils;
+
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.Service;
 import de.intevation.artifacts.ServiceFactory;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultServiceFactory.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultServiceFactory.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import de.intevation.artifacts.Service;
 import de.intevation.artifacts.ServiceFactory;
 
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/FactoryBootstrap.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import de.intevation.artifacts.ArtifactCollectionFactory;
 import de.intevation.artifacts.ArtifactContextFactory;
 import de.intevation.artifacts.ArtifactFactory;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/SQL.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,6 +8,8 @@
 
 package de.intevation.artifactdatabase;
 
+import de.intevation.artifacts.common.utils.Config;
+
 import java.io.IOException;
 import java.io.InputStream;
 
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/XMLUtils.java	Tue Mar 15 15:25:43 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
- * Copyright (c) 2010 by Intevation GmbH
- *
- * This program is free software under the LGPL (>=v2.1)
- * Read the file LGPL.txt coming with the software for details
- * or visit http://www.gnu.org/licenses/ if it does not exist.
- */
-
-package de.intevation.artifactdatabase;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-
-import javax.xml.transform.dom.DOMSource;
-
-import javax.xml.transform.stream.StreamResult;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.xml.sax.SAXException;
-
-/**
- * Some helper functions to ease work with XML concering namespaces, XPATH
- * and so on.
- *  @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
- */
-public final class XMLUtils
-{
-    /**
-     * W3C URL of XForms
-     */
-    public static final String XFORM_URL    = "http://www.w3.org/2002/xforms";
-    /**
-     * W3C prefix of XForms
-     */
-    public static final String XFORM_PREFIX = "xform";
-
-    private static Logger logger = Logger.getLogger(XMLUtils.class);
-
-    private XMLUtils() {
-    }
-
-    /**
-     * Helper class to generate elements and attributes with
-     * namespaces.
-     */
-    public static class ElementCreator
-    {
-        /**
-         * owner document of the elements to be created
-         */
-        protected Document document;
-        /**
-         * namespace to be used
-         */
-        protected String   ns;
-        /**
-         * prefix to be used
-         */
-        protected String   prefix;
-
-        /**
-         * Constructor to create an element/attribute creator
-         * with a given namespace and namespace prefix using a
-         * given owner document.
-         * @param document The owning document
-         * @param ns       The namespace
-         * @param prefix   The namespace prefix
-         */
-        public ElementCreator(Document document, String ns, String prefix) {
-            this.document = document;
-            this.ns       = ns;
-            this.prefix   = prefix;
-        }
-
-        /**
-         * Creates a new element using the owning document with
-         * the this creators namespace and namespace prefix.
-         * @param name The name of the element
-         * @return     The new element
-         */
-        public Element create(String name) {
-            Element element = document.createElementNS(ns, name);
-            element.setPrefix(prefix);
-            return element;
-        }
-
-        /**
-         * Adds a new attribute and its value to a given element.
-         * It does not set the namespace prefix.
-         * @param element The element to add the attribute to
-         * @param name    The name of the attribute
-         * @param value   The value of the attribute
-         */
-        public void addAttr(Element element, String name, String value) {
-            addAttr(element, name, value, false);
-        }
-
-        /**
-         * Adds a new attribute and its value to a given element.
-         * If the namespace prefix is used is decided by the 'addPrefix' flag.
-         * @param element The element to add the attribute to
-         * @param name    The name of the attribute
-         * @param value   The value of the attribute
-         * @param addPrefix If true the creators namespace prefix is
-         * set on the attribute.
-         */
-        public void addAttr(
-            Element element,
-            String  name,
-            String  value,
-            boolean addPrefix
-        ) {
-            Attr attr = document.createAttributeNS(ns, name);
-            attr.setValue(value);
-
-            if (addPrefix)
-                attr.setPrefix(prefix);
-
-            element.setAttributeNode(attr);
-        }
-    } // class ElementCreator
-
-    /**
-     * Creates a new XML document
-     * @return the new XML document ot null if something went wrong during
-     * creation.
-     */
-    public static final Document newDocument() {
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-
-        try {
-            return factory.newDocumentBuilder().newDocument();
-        }
-        catch (ParserConfigurationException pce) {
-            logger.error(pce.getLocalizedMessage(), pce);
-        }
-        return null;
-    }
-
-    /**
-     * Loads a XML document namespace aware from a file
-     * @param file The file to load.
-     * @return the XML document or null if something went wrong
-     * during loading.
-     */
-    public static final Document parseDocument(File file) {
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-        factory.setNamespaceAware(true);
-
-        try {
-            return factory.newDocumentBuilder().parse(file);
-        }
-        catch (ParserConfigurationException pce) {
-            logger.error(pce.getLocalizedMessage(), pce);
-        }
-        catch (SAXException se) {
-            logger.error(se.getLocalizedMessage(), se);
-        }
-        catch (IOException ioe) {
-            logger.error(ioe.getLocalizedMessage(), ioe);
-        }
-        return null;
-    }
-
-    /**
-     * Creates a new XPath without a namespace context.
-     * @return the new XPath.
-     */
-    public static final XPath newXPath() {
-        return newXPath(null);
-    }
-
-    /**
-     * Creates a new XPath with a given namespace context.
-     * @param namespaceContext The namespace context to be used or null
-     * if none should be used.
-     * @return The new XPath
-     */
-    public static final XPath newXPath(NamespaceContext namespaceContext) {
-        XPathFactory factory = XPathFactory.newInstance();
-        XPath        xpath   = factory.newXPath();
-        if (namespaceContext != null) {
-            xpath.setNamespaceContext(namespaceContext);
-        }
-        return xpath;
-    }
-
-    /**
-     * Evaluates an XPath query on a given object and returns the result
-     * as a given type. No namespace context is used.
-     * @param root  The object which is used as the root of the tree to
-     * be searched in.
-     * @param query The XPath query
-     * @param returnTyp The type of the result.
-     * @return The result of type 'returnTyp' or null if something
-     * went wrong during XPath evaluation.
-     */
-    public static final Object xpath(
-        Object root,
-        String query,
-        QName  returnTyp
-    ) {
-        return xpath(root, query, returnTyp, null);
-    }
-
-    /**
-     * Evaluates an XPath query on a given object and returns the result
-     * as a string. A given namespace context is used.
-     * @param root  The object which is used as the root of the tree to
-     * be searched in.
-     * @param query The XPath query
-     * @param namespaceContext The namespace context to be used or null
-     * if none should be used.
-     * @return The result of the query or null if something went wrong
-     * during XPath evaluation.
-     */
-    public static final String xpathString(
-        Object root, String query, NamespaceContext namespaceContext
-    ) {
-        return (String)xpath(
-            root, query, XPathConstants.STRING, namespaceContext);
-    }
-
-    /**
-     * Evaluates an XPath query on a given object and returns the result
-     * as a given type. Optionally a namespace context is used.
-     * @param root The object which is used as the root of the tree to
-     * be searched in.
-     * @param query The XPath query
-     * @param returnType The type of the result.
-     * @param namespaceContext The namespace context to be used or null
-     * if none should be used.
-     * @return The result of type 'returnTyp' or null if something
-     * went wrong during XPath evaluation.
-     */
-    public static final Object xpath(
-        Object           root,
-        String           query,
-        QName            returnType,
-        NamespaceContext namespaceContext
-    ) {
-        if (root == null) {
-            return null;
-        }
-
-        try {
-            XPath xpath = newXPath(namespaceContext);
-            if (xpath != null) {
-                return xpath.evaluate(query, root, returnType);
-            }
-        }
-        catch (XPathExpressionException xpee) {
-            logger.error(xpee.getLocalizedMessage(), xpee);
-        }
-
-        return null;
-    }
-
-    /**
-     * Streams out an XML document to a given output stream.
-     * @param document The document to be streamed out.
-     * @param out      The output stream to be used.
-     * @return true if operation succeeded else false.
-     */
-    public static boolean toStream(Document document, OutputStream out) {
-        try {
-            Transformer transformer =
-                TransformerFactory.newInstance().newTransformer();
-            DOMSource    source = new DOMSource(document);
-            StreamResult result = new StreamResult(out);
-            transformer.transform(source, result);
-            return true;
-        }
-        catch (TransformerConfigurationException tce) {
-            logger.error(tce.getLocalizedMessage(), tce);
-        }
-        catch (TransformerFactoryConfigurationError tfce) {
-            logger.error(tfce.getLocalizedMessage(), tfce);
-        }
-        catch (TransformerException te) {
-            logger.error(te.getLocalizedMessage(), te);
-        }
-
-        return false;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactResource.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactResource.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,7 +8,7 @@
 
 package de.intevation.artifactdatabase.rest;
 
-import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.ArtifactDatabase;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/BaseOutResource.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/BaseOutResource.java	Tue Mar 15 15:49:24 2011 +0000
@@ -7,7 +7,7 @@
  */
 package de.intevation.artifactdatabase.rest;
 
-import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.artifacts.ArtifactDatabase;
 import de.intevation.artifacts.ArtifactDatabaseException;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/CreateResource.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,7 +8,7 @@
 
 package de.intevation.artifactdatabase.rest;
 
-import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils;
 
 import de.intevation.artifacts.ArtifactDatabase;
 import de.intevation.artifacts.ArtifactDatabaseException;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/FactoriesResource.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,9 +8,8 @@
 
 package de.intevation.artifactdatabase.rest;
 
-import de.intevation.artifactdatabase.XMLUtils.ElementCreator;
-
-import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
 import de.intevation.artifacts.ArtifactDatabase;
 import de.intevation.artifacts.ArtifactNamespaceContext;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ServicesResource.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ServicesResource.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,9 +8,8 @@
 
 package de.intevation.artifactdatabase.rest;
 
-import de.intevation.artifactdatabase.XMLUtils.ElementCreator;
-
-import de.intevation.artifactdatabase.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
 
 import de.intevation.artifacts.ArtifactDatabase;
 import de.intevation.artifacts.ArtifactNamespaceContext;
--- a/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java	Tue Mar 15 15:25:43 2011 +0000
+++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java	Tue Mar 15 15:49:24 2011 +0000
@@ -8,7 +8,7 @@
 
 package de.intevation.artifactdatabase.rest;
 
-import de.intevation.artifactdatabase.Config;
+import de.intevation.artifacts.common.utils.Config;
 
 import de.intevation.artifacts.ArtifactDatabase;
 

http://dive4elements.wald.intevation.org