diff --git a/build.gradle b/build.gradle index 3685b3c..877bb0e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,17 +4,15 @@ plugins { id "org.xbib.gradle.plugin.jbake" version "1.2.1" } - ext { versions = [ 'jackson' : '2.8.4' ] } -allprojects { +apply plugin: 'build-dashboard' - group = 'org.xbib' - version = '1.0.6' +allprojects { apply plugin: 'java' apply plugin: 'maven' @@ -42,7 +40,7 @@ allprojects { [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:all" << "-profile" << "compact2" + options.compilerArgs << "-Xlint:all" << "-profile" << "compact1" } test { diff --git a/content-core/src/main/java/org/xbib/content/XContentBuilder.java b/content-core/src/main/java/org/xbib/content/XContentBuilder.java index a83f0ca..42a360a 100644 --- a/content-core/src/main/java/org/xbib/content/XContentBuilder.java +++ b/content-core/src/main/java/org/xbib/content/XContentBuilder.java @@ -766,6 +766,15 @@ public final class XContentBuilder implements ToXContent, Flushable, Closeable { return this; } + + public XContentBuilder flatMap(Map map) throws IOException { + if (map == null) { + return nullValue(); + } + writeFlatMap(map); + return this; + } + public XContentBuilder value(Iterable value) throws IOException { if (value == null) { return nullValue(); @@ -825,6 +834,20 @@ public final class XContentBuilder implements ToXContent, Flushable, Closeable { generator.writeEndObject(); } + private void writeFlatMap(Map map) throws IOException { + generator.writeStartObject(); + for (Map.Entry entry : map.entrySet()) { + field(entry.getKey()); + Object value = entry.getValue(); + if (value == null) { + generator.writeNull(); + } else { + writeValue(value); + } + } + generator.writeEndObject(); + } + @SuppressWarnings("unchecked") private void writeValue(Object value) throws IOException { if (value == null) { diff --git a/content-core/src/main/java/org/xbib/content/io/BytesStreamOutput.java b/content-core/src/main/java/org/xbib/content/io/BytesStreamOutput.java index 4a50eab..3caaf2d 100644 --- a/content-core/src/main/java/org/xbib/content/io/BytesStreamOutput.java +++ b/content-core/src/main/java/org/xbib/content/io/BytesStreamOutput.java @@ -96,7 +96,7 @@ public class BytesStreamOutput extends OutputStream { if (length == 0) { return; } - if ((long)count + length > Integer.MAX_VALUE) { + if ((long) count + length > Integer.MAX_VALUE) { throw new IllegalArgumentException("overflow, stream output larger than " + Integer.MAX_VALUE); } int newcount = count + length; diff --git a/content-core/src/main/java/org/xbib/content/settings/PlaceholderResolver.java b/content-core/src/main/java/org/xbib/content/settings/PlaceholderResolver.java index aed8c71..372857d 100644 --- a/content-core/src/main/java/org/xbib/content/settings/PlaceholderResolver.java +++ b/content-core/src/main/java/org/xbib/content/settings/PlaceholderResolver.java @@ -13,4 +13,4 @@ public interface PlaceholderResolver { * @return the replacement value or null if no replacement is to be made. */ String resolvePlaceholder(String placeholderName); -} \ No newline at end of file +} diff --git a/content-core/src/main/java/org/xbib/content/settings/PropertyPlaceholder.java b/content-core/src/main/java/org/xbib/content/settings/PropertyPlaceholder.java index 0a2a219..77ca815 100644 --- a/content-core/src/main/java/org/xbib/content/settings/PropertyPlaceholder.java +++ b/content-core/src/main/java/org/xbib/content/settings/PropertyPlaceholder.java @@ -117,4 +117,4 @@ public class PropertyPlaceholder { } return true; } -} \ No newline at end of file +} diff --git a/content-core/src/test/java/org/xbib/content/settings/SettingsTest.java b/content-core/src/test/java/org/xbib/content/settings/SettingsTest.java index 0c9b42f..422b95b 100644 --- a/content-core/src/test/java/org/xbib/content/settings/SettingsTest.java +++ b/content-core/src/test/java/org/xbib/content/settings/SettingsTest.java @@ -3,9 +3,13 @@ package org.xbib.content.settings; import org.junit.Assert; import org.junit.Test; +import org.xbib.content.XContentBuilder; import org.xbib.content.XContentHelper; +import org.xbib.content.json.JsonSettingsLoader; +import org.xbib.content.json.JsonXContent; import java.io.ByteArrayInputStream; +import java.io.IOException; import java.io.StringReader; import java.nio.charset.StandardCharsets; import java.util.Arrays; @@ -102,4 +106,21 @@ public class SettingsTest extends Assert { .build(); assertEquals("{a.b=c}", settings.getAsMap().toString()); } + + @Test + public void testFlatLoader() throws IOException { + String s = "{\"a\":{\"b\":\"c\"}}"; + JsonSettingsLoader loader = new JsonSettingsLoader(); + Map flatMap = loader.load(s); + assertEquals("{a.b=c}", flatMap.toString()); + } + + @Test + public void testFlatLoaderToJsonString() throws IOException { + String s = "{\"a\":{\"b\":\"c\"}}"; + JsonSettingsLoader loader = new JsonSettingsLoader(); + String result = JsonXContent.contentBuilder().flatMap(loader.load(s)).string(); + assertEquals("{\"a.b\":\"c\"}", result); + } + } diff --git a/content-rdf/build.gradle b/content-rdf/build.gradle index f11f23c..38ad54b 100644 --- a/content-rdf/build.gradle +++ b/content-rdf/build.gradle @@ -1,3 +1,7 @@ dependencies { compile project(':content-xml') } + +tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:all" << "-profile" << "compact2" +} \ No newline at end of file diff --git a/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentParser.java b/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentParser.java index 830e4e0..10acc52 100644 --- a/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentParser.java +++ b/content-rdf/src/main/java/org/xbib/content/rdf/RdfContentParser.java @@ -4,6 +4,7 @@ import java.io.IOException; /** * + * @param parameter type */ public interface RdfContentParser { diff --git a/content-resource/build.gradle b/content-resource/build.gradle new file mode 100644 index 0000000..cb6526b --- /dev/null +++ b/content-resource/build.gradle @@ -0,0 +1,4 @@ + +tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:all" << "-profile" << "compact2" +} \ No newline at end of file diff --git a/content-xml/build.gradle b/content-xml/build.gradle index ded0a1a..475a405 100644 --- a/content-xml/build.gradle +++ b/content-xml/build.gradle @@ -3,3 +3,8 @@ dependencies { compile project(':content-resource') compile "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:${versions.jackson}" } + + +tasks.withType(JavaCompile) { + options.compilerArgs << "-Xlint:all" << "-profile" << "compact2" +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..0a02f90 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,3 @@ +group = org.xbib +name = content +version = 1.0.7 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 6ffa237..51288f9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0139d7a..62408a4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Oct 03 00:03:03 CEST 2016 +#Sat Dec 03 23:47:13 CET 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-all.zip diff --git a/gradlew b/gradlew index 9aa616c..4453cce 100755 --- a/gradlew +++ b/gradlew @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh ############################################################################## ## @@ -154,16 +154,19 @@ if $cygwin ; then esac fi -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") +# Escape application args +save ( ) { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " } -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then cd "$(dirname "$0")" fi -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" +exec "$JAVACMD" "$@" diff --git a/settings.gradle b/settings.gradle index ad3c569..22a4669 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ -rootProject.name = 'content' +rootProject.name = name include 'content-core' include 'content-resource' include 'content-language'