Commit b45f19f7 authored by Stefan Funk's avatar Stefan Funk
Browse files

Merge branch 'release/3.4.3'

parents 755f20fe 2c9c5a23
......@@ -7,6 +7,6 @@ node {
}
stage('Build') {
sh "'${mvnHome}/bin/mvn' -U clean verify deploy"
sh "'${mvnHome}/bin/mvn' -U clean deploy"
}
}
......@@ -2,3 +2,4 @@
/.settings/
/.classpath
/.project
/bin/
......@@ -7,22 +7,21 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>common</artifactId>
<version>3.3.1</version>
<version>3.4.3</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>cli-tools</artifactId>
<name>TextGrid :: CLI Tools</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<elasticsearch.version>1.4.2</elasticsearch.version>
<textgrid.httpclients.version>2.0.0</textgrid.httpclients.version>
<textgrid.httpclients.version>${project.version}</textgrid.httpclients.version>
<commons-io.version>2.4</commons-io.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -38,48 +37,41 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>${commons-io.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${maven-eclipse-plugin.version}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>info.textgrid.middleware.Dispatcher</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>shaded</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add main class to manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>info.textgrid.middleware.Dispatcher</mainClass>
</transformer>
</transformers>
<!-- without this, the shaded jar is included into itself on second
build ... which is really stupid -->
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
......@@ -2,3 +2,4 @@
/target
/.classpath
/.project
/bin/
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>common</artifactId>
<groupId>info.textgrid.middleware</groupId>
<version>3.3.1</version>
<version>3.4.3</version>
</parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>confclient</artifactId>
<name>TextGrid :: Confclient</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<packaging>bundle</packaging>
<dependencies>
<dependency>
......@@ -26,7 +23,7 @@
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<!-- 1.3 SNAPSHOT is actually patched and locally packaged with maven-bundle-plugin
<!-- 1.3 SNAPSHOT is actually patched and locally packaged with maven-bundle-plugin
2.3.4, to prevent circualar osgi import -->
<version>1.3.3</version>
</dependency>
......
/*
* #%L
* confclient
* %%
* Copyright (C) 2011 TextGrid Consortion
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
* #%L confclient %% Copyright (C) 2011 TextGrid Consortion %% This program is free software: you
* can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
* You should have received a copy of the GNU General Lesser Public License along with this program.
* If not, see <http://www.gnu.org/licenses/lgpl-3.0.html>. #L%
*/
package info.textgrid.middleware.confclient;
......@@ -25,115 +17,116 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.codehaus.jettison.AbstractXMLStreamReader;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.codehaus.jettison.mapped.MappedXMLStreamReader;
/**
* Class for retrieving configuration from confserv, for clientside use (e.g.
* TextGrid-services, TextGridLab). JSON is used for config-retrieval.
* Class for retrieving configuration from confserv, for clientside use (e.g. TextGrid-services,
* TextGridLab). JSON is used for config-retrieval.
*
*/
public class ConfservClient {
private static int DEFAULT_SB_VALUE = 1024;
private String confServUrl;
/**
* Constructor
*
* @param confServUrl
* URL of ConfigService
* @throws AxisFault
*/
public ConfservClient(String confServUrl) {
this.confServUrl = confServUrl;
}
/**
* Get single config value from confserver for a given key. For a list of
* valid keys have a look at {@link ConfservClientConstants}
*
* @param key
* @return value
* @throws IOException
* @throws JSONException
*/
public String getValue(String key) throws IOException, JSONException {
URL url = new URL(confServUrl + "/getValueJ?key=" + key);
InputStream in = url.openStream();
String body = readStringFromStream(in);
JSONObject obj = new JSONObject(body);
return obj.getString("value");
}
/**
* Get all configuration from confserver, returns all entries in a key/value
* hashmap
*
* @return hashmap with key/value entries for configuration
* @throws HttpException
* @throws IOException
* @throws JSONException
* @throws XMLStreamException
*/
public HashMap<String, String> getAll() throws IOException, JSONException,
XMLStreamException {
HashMap<String, String> confMap = new HashMap<String, String>();
URL url = new URL(confServUrl + "/getAllJ");
InputStream in = url.openStream();
String body = readStringFromStream(in);
JSONObject obj = new JSONObject(body);
AbstractXMLStreamReader reader = new MappedXMLStreamReader(obj);
int event;
while (true) {
event = reader.next();
if (event == XMLStreamReader.START_ELEMENT
&& reader.getLocalName().equals("set")) {
reader.next();
String key = reader.getText();
reader.next();
reader.next();
reader.next();
String value = reader.getText();
confMap.put(key, value);
}
if (event == XMLStreamConstants.END_DOCUMENT) {
reader.close();
break;
}
}
return confMap;
}
/*
* from org.apache.cxf.helpers.IOUtils
*/
private static String readStringFromStream(InputStream in)
throws IOException {
StringBuilder sb = new StringBuilder(DEFAULT_SB_VALUE);
for (int i = in.read(); i != -1; i = in.read()) {
sb.append((char) i);
}
in.close();
return sb.toString();
}
private static int DEFAULT_SB_VALUE = 1024;
private String confServUrl;
/**
* Constructor
*
* @param confServUrl URL of ConfigService
* @throws AxisFault
*/
public ConfservClient(String confServUrl) {
this.confServUrl = confServUrl;
}
/**
* Get single config value from confserver for a given key. For a list of valid keys have a look
* at {@link ConfservClientConstants}
*
* @param key
* @return value
* @throws IOException
* @throws JSONException
*/
public String getValue(String key) throws IOException, JSONException {
URL url = new URL(confServUrl + "/getValueJ?key=" + key);
InputStream in = url.openStream();
String body = readStringFromStream(in);
JSONObject obj = new JSONObject(body);
return obj.getString("value");
}
/**
* Get all configuration from confserver, returns all entries in a key/value hashmap
*
* @return hashmap with key/value entries for configuration
* @throws HttpException
* @throws IOException
* @throws JSONException
* @throws XMLStreamException
*/
public HashMap<String, String> getAll() throws IOException, JSONException,
XMLStreamException {
HashMap<String, String> confMap = new HashMap<String, String>();
URL url = new URL(confServUrl + "/getAllJ");
InputStream in = url.openStream();
String body = readStringFromStream(in);
JSONObject obj = new JSONObject(body);
AbstractXMLStreamReader reader = new MappedXMLStreamReader(obj);
int event;
while (true) {
event = reader.next();
if (event == XMLStreamReader.START_ELEMENT
&& reader.getLocalName().equals("set")) {
reader.next();
String key = reader.getText();
reader.next();
reader.next();
reader.next();
String value = reader.getText();
confMap.put(key, value);
}
if (event == XMLStreamConstants.END_DOCUMENT) {
reader.close();
break;
}
}
return confMap;
}
/*
* from org.apache.cxf.helpers.IOUtils
*/
/**
* @param in
* @return
* @throws IOException
*/
private static String readStringFromStream(InputStream in)
throws IOException {
StringBuilder sb = new StringBuilder(DEFAULT_SB_VALUE);
for (int i = in.read(); i != -1; i = in.read()) {
sb.append((char) i);
}
in.close();
return sb.toString();
}
}
......@@ -2,3 +2,4 @@
/target
/.classpath
/.project
/bin/
......@@ -5,16 +5,12 @@
<parent>
<groupId>info.textgrid.middleware</groupId>
<artifactId>common</artifactId>
<version>3.3.1</version>
<version>3.4.3</version>
</parent>
<groupId>info.textgrid.utils</groupId>
<artifactId>esutils</artifactId>
<packaging>jar</packaging>
<name>DARIAHDE :: ElasticSearch Utilities</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
......@@ -22,6 +18,11 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.textgrid.middleware</groupId>
<artifactId>crud-common</artifactId>
<version>${crud-common.version}</version>
</dependency>
<!-- Saxon for XSLT 2.0 -->
<dependency>
<groupId>net.sf.saxon</groupId>
......@@ -51,53 +52,72 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>${commons-io.version}</version>
</dependency>
<dependency>
<groupId>info.textgrid.namespaces</groupId>
<artifactId>metadata-core-jaxb</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>${jena.version}</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>${jena.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>${maven-eclipse-plugin.version}</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>info.textgrid.App</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>shaded</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version>
<executions>
<execution>
<id>do-shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>META-INF/*.SF</exclude>
</excludes>
</filter>
</filters>
<transformers>
<!-- add main class to manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>info.textgrid.middleware.common.elasticsearch.Dispatcher</mainClass>
</transformer>
</transformers>
<!-- without this, the shaded jar is included into itself on second
build ... which is really stupid -->
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
package info.textgrid;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import org.xml.sax.SAXException;
import org.xmlpull.v1.XmlPullParserException;
import info.textgrid.middleware.common.elasticsearch.ESJsonBuilder;
public class App2 {
public static void main(String[] args)
throws TransformerConfigurationException, SAXException,
XmlPullParserException, ParserConfigurationException {
String xml = "<es:elasticSearchMappingSection xmlns:es=\"http://textgrid.info/namespaces/metadata/projectfile/esmapping\" >\n"
+ " <es:mapping \n"
+ " mimetype=\"text/xml\" \n"
+ " namespace=\"http://blumenbach-online.de/blumenbachiana\"\n"
+ " adaptorUri=\"textgrid:1234\" />\n"
+ " <es:mapping \n"
+ " mimetype=\"text/xml\" \n"
+ " namespace=\"http://tei-c.org/bla\" \n"
+ " adaptorUri=\"textgrid:1235\" />\n"
+ " </es:elasticSearchMappingSection>";
ESJsonBuilder esj = new ESJsonBuilder();
System.out.println(esj.xml2json(xml));
}
}
This diff is collapsed.
......@@ -19,7 +19,7 @@ import org.json.simple.parser.ParseException;
import org.xml.sax.SAXException;
import org.xmlpull.v1.XmlPullParserException;
public class App {
public class TGTransform {
private static int SEC = 1000;
......
package info.textgrid.middleware.common.elasticsearch;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import info.textgrid.DHTransform;