From bf792bde3589518db260e7fa14cd34b4a8397aec Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sun, 27 Sep 2015 15:56:43 +1000 Subject: [PATCH 01/41] Fix paths in jsonldplayground script --- jsonldplayground | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jsonldplayground b/jsonldplayground index a838ff3..fb6a6cc 100755 --- a/jsonldplayground +++ b/jsonldplayground @@ -6,9 +6,9 @@ # # run ./jsonldplayground for the usage -if [ ! -d "tools/target/appassembler/bin" ]; then +if [ ! -d "target/appassembler/bin" ]; then mvn -quiet clean install -DskipTests fi -chmod u+x tools/target/appassembler/bin/* -tools/target/appassembler/bin/jsonldplayground "$@" +chmod u+x target/appassembler/bin/* +target/appassembler/bin/jsonldplayground "$@" From 487503c2bce50a2b05d1a69bf1ac18a63c618bbb Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 30 Sep 2015 13:19:35 +1000 Subject: [PATCH 02/41] release 0.7.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 559c944..b99a310 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.7.0-SNAPSHOT + 0.7.0 4.0.0 jsonld-java-tools From 3f4b75ae5d6c1c75069ac3391e0122b5cab0a9ed Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 30 Sep 2015 13:22:58 +1000 Subject: [PATCH 03/41] bump to next development version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b99a310..b19735a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.7.0 + 0.7.1-SNAPSHOT 4.0.0 jsonld-java-tools From f42dedd3a29239a49fd6975afe37624579816743 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 19 Nov 2015 10:12:59 +1100 Subject: [PATCH 04/41] Bump to 0.8.0-SNAPSHOT --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b19735a..785742b 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.7.1-SNAPSHOT + 0.8.0-SNAPSHOT 4.0.0 jsonld-java-tools From abe3966b351cda7f92d7a250f25509271bcde5a1 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sun, 27 Dec 2015 13:18:12 +1100 Subject: [PATCH 05/41] Use new program.id instead of program.name --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 785742b..12c30a5 100644 --- a/pom.xml +++ b/pom.xml @@ -114,7 +114,7 @@ com.github.jsonldjava.tools.Playground - jsonldplayground + jsonldplayground From d72b4a859f1f10c95d44f84d5b1d7ff7820ac644 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Tue, 9 Feb 2016 17:42:11 -0500 Subject: [PATCH 06/41] release 0.8.0 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 12c30a5..0500982 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.0-SNAPSHOT + 0.8.0 4.0.0 jsonld-java-tools @@ -13,7 +13,7 @@ jar - 2.8.5 + 2.8.9 From f6c5a8c9e614979c5d799896a971b8b89003a70e Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Tue, 9 Feb 2016 18:01:17 -0500 Subject: [PATCH 07/41] bump to next development version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0500982..14388a7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.0 + 0.8.1-SNAPSHOT 4.0.0 jsonld-java-tools From 34b84829d5f99c13874b8706e2e63ccbb97a0cee Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 17 Feb 2016 17:37:09 -0500 Subject: [PATCH 08/41] Release 0.8.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 14388a7..f987b49 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.1-SNAPSHOT + 0.8.1 4.0.0 jsonld-java-tools @@ -35,7 +35,7 @@ net.sf.jopt-simple jopt-simple - 4.8 + 4.9 org.openrdf.sesame From 533375b7a8ceee0bdd3a37fdd2b45779c06117a9 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 17 Feb 2016 17:52:30 -0500 Subject: [PATCH 09/41] Bump to next development version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f987b49..effcce5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.1 + 0.9.0-SNAPSHOT 4.0.0 jsonld-java-tools From 18e7424854735ad1f59b7455913da607c9d0e8ef Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 17 Feb 2016 18:25:19 -0500 Subject: [PATCH 10/41] Release 0.8.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index effcce5..3a9a911 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.9.0-SNAPSHOT + 0.8.2 4.0.0 jsonld-java-tools From b70cf862b5d3f0aec19f661a2a79e57483fa14c2 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 17 Feb 2016 18:34:32 -0500 Subject: [PATCH 11/41] bump to next development version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a9a911..aa2937e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.2 + 0.8.3-SNAPSHOT 4.0.0 jsonld-java-tools From 4b672608874d74efac6e5108b87bbb9d43695414 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 18 May 2016 18:59:37 -0400 Subject: [PATCH 12/41] Release 0.8.3 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index aa2937e..c801c56 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.3-SNAPSHOT + 0.8.3 4.0.0 jsonld-java-tools @@ -13,7 +13,7 @@ jar - 2.8.9 + 2.8.11 From de5ef1258431e1f9c910c3b89741d0dd1178e906 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 18 May 2016 19:04:37 -0400 Subject: [PATCH 13/41] Bump to next snapshot --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c801c56..3b172f0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.3 + 0.8.4-SNAPSHOT 4.0.0 jsonld-java-tools From 0cd346bd167795ce2d694cb7fbc8daba3809caeb Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 18 May 2016 19:22:10 -0400 Subject: [PATCH 14/41] Only test with Java-8 --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ee0939..312621f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: java jdk: - - openjdk7 - - oraclejdk7 - oraclejdk8 notifications: email: From 685e56c6274662305fad5c0458a07d7efaf57bb3 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 18 May 2016 19:27:36 -0400 Subject: [PATCH 15/41] Cache maven files on Travis --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 312621f..f39b742 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,8 @@ language: java +sudo: false +cache: + directories: + - $HOME/.m2 jdk: - oraclejdk8 notifications: From 2f6f511a3e9dfcef2a8c93a07257875eb684b93d Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Fri, 23 Dec 2016 06:29:08 +1100 Subject: [PATCH 16/41] Bump to 0.9.0-SNAPSHOT Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3b172f0..c536109 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.8.4-SNAPSHOT + 0.9.0-SNAPSHOT 4.0.0 jsonld-java-tools From 2a32660b9c8644c1c38dea2f8dec61e25f5625bc Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Fri, 23 Dec 2016 06:37:29 +1100 Subject: [PATCH 17/41] Release 0.9.0 Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c536109..cf0f20c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.9.0-SNAPSHOT + 0.9.0 4.0.0 jsonld-java-tools From 59ac8819b89a658312b0a6e82997452911e62136 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Fri, 23 Dec 2016 06:48:24 +1100 Subject: [PATCH 18/41] Bump to next development version Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index cf0f20c..1a57508 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.9.0 + 0.9.1-SNAPSHOT 4.0.0 jsonld-java-tools From b980750a7cf40b3d61a6ee8f3a718347e5a34cce Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 16 Feb 2017 15:11:35 +1100 Subject: [PATCH 19/41] Convert to use RDF4J Signed-off-by: Peter Ansell --- README.md | 2 +- pom.xml | 78 ++++++----- .../github/jsonldjava/tools/Playground.java | 124 +++++++++--------- ...FParser.java => RDF4JJSONLDRDFParser.java} | 52 ++++---- ...ck.java => RDF4JJSONLDTripleCallback.java} | 67 +++++----- 5 files changed, 165 insertions(+), 158 deletions(-) rename src/main/java/com/github/jsonldjava/tools/{SesameJSONLDRDFParser.java => RDF4JJSONLDRDFParser.java} (65%) rename src/main/java/com/github/jsonldjava/tools/{SesameJSONLDTripleCallback.java => RDF4JJSONLDTripleCallback.java} (75%) diff --git a/README.md b/README.md index 93ba528..5f74eec 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Tools for using JSONLD-Java ### Dependencies -* Java-1.6+ +* Java-1.8+ * Maven-3 Playground diff --git a/pom.xml b/pom.xml index 1a57508..736a4a2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.9.1-SNAPSHOT + 0.10.0-SNAPSHOT 4.0.0 jsonld-java-tools @@ -13,7 +13,11 @@ jar - 2.8.11 + 2.2 + 1.8 + 1.8 + 1.8 + 1.8 @@ -35,70 +39,71 @@ net.sf.jopt-simple jopt-simple - 4.9 + 5.0.3 - org.openrdf.sesame - sesame-model - ${sesame.version} + org.eclipse.rdf4j + rdf4j-model + ${rdf4j.version} - org.openrdf.sesame - sesame-rio-api - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-api + ${rdf4j.version} - org.openrdf.sesame - sesame-rio-jsonld - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-jsonld + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-nquads - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-nquads + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-turtle - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-turtle + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-rdfxml - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-rdfxml + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-rdfjson - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-rdfjson + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-ntriples - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-ntriples + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-trig - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-trig + ${rdf4j.version} runtime - org.openrdf.sesame - sesame-rio-trix - ${sesame.version} + org.eclipse.rdf4j + rdf4j-rio-trix + ${rdf4j.version} runtime + org.codehaus.mojo appassembler-maven-plugin @@ -122,6 +127,13 @@ org.codehaus.mojo animal-sniffer-maven-plugin + + + org.codehaus.mojo.signature + java18 + 1.0 + + diff --git a/src/main/java/com/github/jsonldjava/tools/Playground.java b/src/main/java/com/github/jsonldjava/tools/Playground.java index ae2b8a0..45f70f1 100644 --- a/src/main/java/com/github/jsonldjava/tools/Playground.java +++ b/src/main/java/com/github/jsonldjava/tools/Playground.java @@ -19,10 +19,10 @@ import joptsimple.ValueConversionException; import joptsimple.ValueConverter; -import org.openrdf.model.Model; -import org.openrdf.rio.RDFFormat; -import org.openrdf.rio.RDFParserRegistry; -import org.openrdf.rio.Rio; +import org.eclipse.rdf4j.model.Model; +import org.eclipse.rdf4j.rio.RDFFormat; +import org.eclipse.rdf4j.rio.RDFParserRegistry; +import org.eclipse.rdf4j.rio.Rio; import com.github.jsonldjava.core.JsonLdOptions; import com.github.jsonldjava.core.JsonLdProcessor; @@ -43,8 +43,8 @@ private static Map getOutputFormats() { final Map outputFormats = new HashMap(); for (final RDFFormat format : RDFParserRegistry.getInstance().getKeys()) { - outputFormats.put(format.getName().replaceAll("-", "").replaceAll("/", "") - .toLowerCase(), format); + outputFormats.put( + format.getName().replaceAll("-", "").replaceAll("/", "").toLowerCase(), format); } return outputFormats; @@ -53,8 +53,8 @@ private static Map getOutputFormats() { public static void main(String[] args) throws Exception { final Map formats = getOutputFormats(); - final Set outputForms = new LinkedHashSet(Arrays.asList("compacted", - "expanded", "flattened")); + final Set outputForms = new LinkedHashSet( + Arrays.asList("compacted", "expanded", "flattened")); final OptionParser parser = new OptionParser(); @@ -69,11 +69,8 @@ public static void main(String[] args) throws Exception { final OptionSpec context = parser.accepts("context").withRequiredArg() .ofType(File.class).describedAs("The context"); - final OptionSpec outputFormat = parser - .accepts("format") - .withOptionalArg() - .ofType(String.class) - .withValuesConvertedBy(new ValueConverter() { + final OptionSpec outputFormat = parser.accepts("format").withOptionalArg() + .ofType(String.class).withValuesConvertedBy(new ValueConverter() { @Override public RDFFormat convert(String arg0) { // Normalise the name to provide alternatives @@ -95,17 +92,12 @@ public String valuePattern() { public Class valueType() { return RDFFormat.class; } - }) - .defaultsTo(RDFFormat.NQUADS) - .describedAs( - "The output file format to use. Defaults to nquads. Valid values are: " - + formats.keySet()); - - final OptionSpec processingOption = parser - .accepts("process") - .withRequiredArg() - .ofType(String.class) - .required() + }).defaultsTo(RDFFormat.NQUADS) + .describedAs("The output file format to use. Defaults to nquads. Valid values are: " + + formats.keySet()); + + final OptionSpec processingOption = parser.accepts("process").withRequiredArg() + .ofType(String.class).required() .withValuesConvertedBy(new ValueConverter() { @Override public String convert(String value) { @@ -125,16 +117,11 @@ public Class valueType() { public String valuePattern() { return null; } - }) - .describedAs( - "The processing to perform. Valid values are: " - + getProcessingOptions().toString()); - - final OptionSpec outputForm = parser - .accepts("outputForm") - .withOptionalArg() - .ofType(String.class) - .defaultsTo("expanded") + }).describedAs("The processing to perform. Valid values are: " + + getProcessingOptions().toString()); + + final OptionSpec outputForm = parser.accepts("outputForm").withOptionalArg() + .ofType(String.class).defaultsTo("expanded") .withValuesConvertedBy(new ValueConverter() { @Override public String convert(String value) { @@ -154,8 +141,7 @@ public String valuePattern() { public Class valueType() { return String.class; } - }) - .describedAs( + }).describedAs( "The way to output the results from fromRDF. Defaults to expanded. Valid values are: " + outputForms); @@ -180,17 +166,18 @@ public Class valueType() { opts.setBase(options.valueOf(base)); opts.outputForm = options.valueOf(outputForm); - opts.format = options.has(outputFormat) ? options.valueOf(outputFormat) - .getDefaultMIMEType() : "application/nquads"; + opts.format = options.has(outputFormat) ? options.valueOf(outputFormat).getDefaultMIMEType() + : "application/nquads"; final RDFFormat sesameOutputFormat = options.valueOf(outputFormat); - final RDFFormat sesameInputFormat = Rio.getParserFormatForFileName( - options.valueOf(inputFile).getName(), RDFFormat.JSONLD); + final RDFFormat sesameInputFormat = Rio + .getParserFormatForFileName(options.valueOf(inputFile).getName()) + .orElse(RDFFormat.JSONLD); final String processingOptionValue = options.valueOf(processingOption); if (!options.valueOf(inputFile).exists()) { - System.out.println("Error: input file \"" + options.valueOf(inputFile) - + "\" doesn't exist"); + System.out.println( + "Error: input file \"" + options.valueOf(inputFile) + "\" doesn't exist"); parser.printHelpOn(System.out); return; } @@ -207,8 +194,8 @@ public Class valueType() { if (hasContext(processingOptionValue) && options.has(context)) { if (!options.valueOf(context).exists()) { - System.out.println("Error: context file \"" + options.valueOf(context) - + "\" doesn't exist"); + System.out.println( + "Error: context file \"" + options.valueOf(context) + "\" doesn't exist"); parser.printHelpOn(System.out); return; } @@ -220,13 +207,12 @@ public Class valueType() { final Model inModel = Rio.parse(new StringReader((String) inobj), opts.getBase(), sesameInputFormat); - outobj = JsonLdProcessor.fromRDF(inModel, opts, new SesameJSONLDRDFParser()); + outobj = JsonLdProcessor.fromRDF(inModel, opts, new RDF4JJSONLDRDFParser()); } else if ("tordf".equals(processingOptionValue)) { opts.useNamespaces = true; - outobj = JsonLdProcessor - .toRDF(inobj, - new SesameJSONLDTripleCallback(Rio.createWriter(sesameOutputFormat, - System.out)), opts); + outobj = JsonLdProcessor.toRDF(inobj, + new RDF4JJSONLDTripleCallback(Rio.createWriter(sesameOutputFormat, System.out)), + opts); } else if ("expand".equals(processingOptionValue)) { outobj = JsonLdProcessor.expand(inobj, opts); } else if ("compact".equals(processingOptionValue)) { @@ -240,8 +226,8 @@ public Class valueType() { outobj = JsonLdProcessor.normalize(inobj, opts); } else if ("frame".equals(processingOptionValue)) { if (ctxobj != null && !(ctxobj instanceof Map)) { - System.out - .println("Invalid JSON-LD syntax; a JSON-LD frame must be a single object."); + System.out.println( + "Invalid JSON-LD syntax; a JSON-LD frame must be a single object."); parser.printHelpOn(System.out); return; } @@ -265,8 +251,8 @@ public Class valueType() { } private static String readFile(File in) throws IOException { - final BufferedReader buf = new BufferedReader(new InputStreamReader( - new FileInputStream(in), "UTF-8")); + final BufferedReader buf = new BufferedReader( + new InputStreamReader(new FileInputStream(in), "UTF-8")); String inobj = ""; try { String line; @@ -282,27 +268,37 @@ private static String readFile(File in) throws IOException { // private static void usage() { // System.out.println("Usage: jsonldplayground "); - // System.out.println("\tinput: a filename or JsonLdUrl to the rdf input (in rdfxml or n3)"); + // System.out.println("\tinput: a filename or JsonLdUrl to the rdf input (in + // rdfxml or n3)"); // System.out.println("\toptions:"); // System.out - // .println("\t\t--ignorekeys : a (space separated) list of keys to ignore (e.g. @geojson)"); + // .println("\t\t--ignorekeys : a (space separated) list of + // keys to ignore (e.g. @geojson)"); // System.out.println("\t\t--base : base URI"); - // System.out.println("\t\t--debug: Print out stack traces when errors occur"); - // System.out.println("\t\t--expand : expand the input JSON-LD"); + // System.out.println("\t\t--debug: Print out stack traces when errors + // occur"); + // System.out.println("\t\t--expand : expand the input JSON-LD"); // System.out - // .println("\t\t--compact : compact the input JSON-LD applying the optional context file"); + // .println("\t\t--compact : compact the input JSON-LD + // applying the optional context file"); // System.out - // .println("\t\t--normalize : normalize the input JSON-LD outputting as format (defaults to nquads)"); + // .println("\t\t--normalize : normalize the input JSON-LD + // outputting as format (defaults to nquads)"); // System.out - // .println("\t\t--frame : frame the input JSON-LD with the optional frame file"); + // .println("\t\t--frame : frame the input JSON-LD with the + // optional frame file"); // System.out - // .println("\t\t--flatten : flatten the input JSON-LD applying the optional context file"); + // .println("\t\t--flatten : flatten the input JSON-LD + // applying the optional context file"); // System.out - // .println("\t\t--fromRDF : generate JSON-LD from the input rdf (format defaults to nquads)"); + // .println("\t\t--fromRDF : generate JSON-LD from the + // input rdf (format defaults to nquads)"); // System.out - // .println("\t\t--toRDF : generate RDF from the input JSON-LD (format defaults to nquads)"); + // .println("\t\t--toRDF : generate RDF from the input + // JSON-LD (format defaults to nquads)"); // System.out - // .println("\t\t--outputForm [compacted|expanded|flattened] : the way to output the results from fromRDF (defaults to expanded)"); + // .println("\t\t--outputForm [compacted|expanded|flattened] : the way to + // output the results from fromRDF (defaults to expanded)"); // System.out.println("\t\t--simplify : simplify the input JSON-LD"); // System.exit(1); // } diff --git a/src/main/java/com/github/jsonldjava/tools/SesameJSONLDRDFParser.java b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java similarity index 65% rename from src/main/java/com/github/jsonldjava/tools/SesameJSONLDRDFParser.java rename to src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java index 1645e1a..2296070 100644 --- a/src/main/java/com/github/jsonldjava/tools/SesameJSONLDRDFParser.java +++ b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java @@ -1,28 +1,28 @@ package com.github.jsonldjava.tools; +import java.util.Optional; import java.util.Set; -import org.openrdf.model.BNode; -import org.openrdf.model.Graph; -import org.openrdf.model.Literal; -import org.openrdf.model.Model; -import org.openrdf.model.Namespace; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.vocabulary.RDF; -import org.openrdf.model.vocabulary.XMLSchema; +import org.eclipse.rdf4j.model.BNode; +import org.eclipse.rdf4j.model.Literal; +import org.eclipse.rdf4j.model.Model; +import org.eclipse.rdf4j.model.Namespace; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.vocabulary.RDF; +import org.eclipse.rdf4j.model.vocabulary.XMLSchema; import com.github.jsonldjava.core.JsonLdError; import com.github.jsonldjava.core.RDFDataset; /** - * Implementation of RDFParser for Sesame-2.8. + * Implementation of RDFParser for RDF4J-2.2. * * @author Peter Ansell */ -class SesameJSONLDRDFParser implements com.github.jsonldjava.core.RDFParser { +class RDF4JJSONLDRDFParser implements com.github.jsonldjava.core.RDFParser { public void setPrefix(RDFDataset result, String fullUri, String prefix) { result.setNamespace(fullUri, prefix); @@ -41,23 +41,23 @@ public void handleStatement(RDFDataset result, Statement nextStatement) { if (object instanceof Literal) { final Literal literal = (Literal) object; final String value = literal.getLabel(); - final String language = literal.getLanguage(); + final Optional language = literal.getLanguage(); String datatype = getResourceValue(literal.getDatatype()); // In RDF-1.1, Language Literals internally have the datatype // rdf:langString - if (language != null && datatype == null) { + if (language.isPresent() && datatype == null) { datatype = RDF.LANGSTRING.stringValue(); } // In RDF-1.1, RDF-1.0 Plain Literals are now Typed Literals with // type xsd:String - if (language == null && datatype == null) { + if (!language.isPresent() && datatype == null) { datatype = XMLSchema.STRING.stringValue(); } - result.addQuad(subject, predicate, value, datatype, language, graphName); + result.addQuad(subject, predicate, value, datatype, language.orElse(null), graphName); } else { result.addQuad(subject, predicate, getResourceValue((Resource) object), graphName); @@ -67,14 +67,14 @@ public void handleStatement(RDFDataset result, Statement nextStatement) { private String getResourceValue(Resource subject) { if (subject == null) { return null; - } else if (subject instanceof URI) { + } else if (subject instanceof IRI) { return subject.stringValue(); } else if (subject instanceof BNode) { return "_:" + subject.stringValue(); } - throw new IllegalStateException("Did not recognise resource type: " - + subject.getClass().getName()); + throw new IllegalStateException( + "Did not recognise resource type: " + subject.getClass().getName()); } @Override @@ -82,15 +82,13 @@ public RDFDataset parse(Object input) throws JsonLdError { final RDFDataset result = new RDFDataset(); if (input instanceof Statement) { handleStatement(result, (Statement) input); - } else if (input instanceof Graph) { - if (input instanceof Model) { - final Set namespaces = ((Model) input).getNamespaces(); - for (final Namespace nextNs : namespaces) { - result.setNamespace(nextNs.getName(), nextNs.getPrefix()); - } + } else if (input instanceof Model) { + final Set namespaces = ((Model) input).getNamespaces(); + for (final Namespace nextNs : namespaces) { + result.setNamespace(nextNs.getName(), nextNs.getPrefix()); } - for (final Statement nextStatement : (Graph) input) { + for (final Statement nextStatement : (Model) input) { handleStatement(result, nextStatement); } } diff --git a/src/main/java/com/github/jsonldjava/tools/SesameJSONLDTripleCallback.java b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java similarity index 75% rename from src/main/java/com/github/jsonldjava/tools/SesameJSONLDTripleCallback.java rename to src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java index 0029da5..20dafde 100644 --- a/src/main/java/com/github/jsonldjava/tools/SesameJSONLDTripleCallback.java +++ b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java @@ -3,31 +3,31 @@ import java.util.List; import java.util.Map.Entry; -import org.openrdf.model.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.ValueFactory; -import org.openrdf.model.impl.LinkedHashModel; -import org.openrdf.model.impl.ValueFactoryImpl; -import org.openrdf.rio.ParseErrorListener; -import org.openrdf.rio.ParserConfig; -import org.openrdf.rio.RDFHandler; -import org.openrdf.rio.RDFHandlerException; -import org.openrdf.rio.RDFParseException; -import org.openrdf.rio.helpers.ParseErrorLogger; -import org.openrdf.rio.helpers.RDFParserHelper; -import org.openrdf.rio.helpers.StatementCollector; +import org.eclipse.rdf4j.model.Resource; +import org.eclipse.rdf4j.model.Statement; +import org.eclipse.rdf4j.model.IRI; +import org.eclipse.rdf4j.model.Value; +import org.eclipse.rdf4j.model.ValueFactory; +import org.eclipse.rdf4j.model.impl.LinkedHashModel; +import org.eclipse.rdf4j.model.impl.SimpleValueFactory; +import org.eclipse.rdf4j.rio.ParseErrorListener; +import org.eclipse.rdf4j.rio.ParserConfig; +import org.eclipse.rdf4j.rio.RDFHandler; +import org.eclipse.rdf4j.rio.RDFHandlerException; +import org.eclipse.rdf4j.rio.RDFParseException; +import org.eclipse.rdf4j.rio.helpers.ParseErrorLogger; +import org.eclipse.rdf4j.rio.helpers.RDFParserHelper; +import org.eclipse.rdf4j.rio.helpers.StatementCollector; import com.github.jsonldjava.core.JsonLdTripleCallback; import com.github.jsonldjava.core.RDFDataset; /** - * Implementation of JsonLdTripleCallback for Sesame-2.8. + * Implementation of JsonLdTripleCallback for RDF4J-2.2. * * @author Peter Ansell */ -class SesameJSONLDTripleCallback implements JsonLdTripleCallback { +class RDF4JJSONLDTripleCallback implements JsonLdTripleCallback { private ValueFactory vf; @@ -37,19 +37,19 @@ class SesameJSONLDTripleCallback implements JsonLdTripleCallback { private final ParseErrorListener parseErrorListener; - public SesameJSONLDTripleCallback() { + public RDF4JJSONLDTripleCallback() { this(new StatementCollector(new LinkedHashModel())); } - public SesameJSONLDTripleCallback(RDFHandler nextHandler) { - this(nextHandler, ValueFactoryImpl.getInstance()); + public RDF4JJSONLDTripleCallback(RDFHandler nextHandler) { + this(nextHandler, SimpleValueFactory.getInstance()); } - public SesameJSONLDTripleCallback(RDFHandler nextHandler, ValueFactory vf) { + public RDF4JJSONLDTripleCallback(RDFHandler nextHandler, ValueFactory vf) { this(nextHandler, vf, new ParserConfig(), new ParseErrorLogger()); } - public SesameJSONLDTripleCallback(RDFHandler nextHandler, ValueFactory vf, + public RDF4JJSONLDTripleCallback(RDFHandler nextHandler, ValueFactory vf, ParserConfig parserConfig, ParseErrorListener parseErrorListener) { this.handler = nextHandler; this.vf = vf; @@ -67,9 +67,9 @@ private void triple(String s, String p, String o, String graph) { // This method is always called with three Resources as subject // predicate and object if (graph == null) { - result = vf.createStatement(createResource(s), vf.createURI(p), createResource(o)); + result = vf.createStatement(createResource(s), vf.createIRI(p), createResource(o)); } else { - result = vf.createStatement(createResource(s), vf.createURI(p), createResource(o), + result = vf.createStatement(createResource(s), vf.createIRI(p), createResource(o), createResource(graph)); } @@ -89,7 +89,7 @@ private Resource createResource(String resource) { } else if (resource.startsWith("_:")) { return vf.createBNode(resource.substring(2)); } else { - return vf.createURI(resource); + return vf.createIRI(resource); } } @@ -103,8 +103,8 @@ private void triple(String s, String p, String value, String datatype, String la final Resource subject = createResource(s); - final URI predicate = vf.createURI(p); - final URI datatypeURI = datatype == null ? null : vf.createURI(datatype); + final IRI predicate = vf.createIRI(p); + final IRI datatypeURI = datatype == null ? null : vf.createIRI(datatype); Value object; try { @@ -184,7 +184,8 @@ public Object call(final RDFDataset dataset) { if (handler != null) { try { handler.startRDF(); - for (final Entry nextNamespace : dataset.getNamespaces().entrySet()) { + for (final Entry nextNamespace : dataset.getNamespaces() + .entrySet()) { handler.handleNamespace(nextNamespace.getKey(), nextNamespace.getValue()); } } catch (final RDFHandlerException e) { @@ -198,12 +199,12 @@ public Object call(final RDFDataset dataset) { } for (final RDFDataset.Quad quad : quads) { if (quad.getObject().isLiteral()) { - triple(quad.getSubject().getValue(), quad.getPredicate().getValue(), quad - .getObject().getValue(), quad.getObject().getDatatype(), quad - .getObject().getLanguage(), graphName); + triple(quad.getSubject().getValue(), quad.getPredicate().getValue(), + quad.getObject().getValue(), quad.getObject().getDatatype(), + quad.getObject().getLanguage(), graphName); } else { - triple(quad.getSubject().getValue(), quad.getPredicate().getValue(), quad - .getObject().getValue(), graphName); + triple(quad.getSubject().getValue(), quad.getPredicate().getValue(), + quad.getObject().getValue(), graphName); } } } From ae9744f1453c2101f9978292285805b156ab9f20 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 16 Feb 2017 15:48:18 +1100 Subject: [PATCH 20/41] Release 0.10.0 Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 736a4a2..fc3abe4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.10.0-SNAPSHOT + 0.10.0 4.0.0 jsonld-java-tools From a5295d36f7f7b19c6d313860f9cee1f9878aa8b5 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 16 Feb 2017 15:52:05 +1100 Subject: [PATCH 21/41] Bump to next development version Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index fc3abe4..5a315ba 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.10.0 + 0.10.1-SNAPSHOT 4.0.0 jsonld-java-tools From 4d66ffc6c1b536513e0cff7d7ff5521e43b51c2f Mon Sep 17 00:00:00 2001 From: Nicolas F Rouquette Date: Sun, 12 Mar 2017 19:03:03 -0700 Subject: [PATCH 22/41] Added support for secure & insecure basic authentication --- README.md | 13 ++ jsonldplayground | 10 +- .../github/jsonldjava/tools/Playground.java | 178 +++++++++++++++++- 3 files changed, 194 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f74eec..d632ba3 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,16 @@ run the following to get usage details: ./jsonldplayground --help +### Support for basic authentication + +Authentication involves 5 options: + +| Option | Description | +|-----------------------|-----------------------------------| +| `--username ` | username for basic authentication | +| `[--password ]` | password for basic authentication, defaults to the value of the `PASSWORD` environment variable, if any, or the empty string. | +| `[--authHost ]` | host scope of the authentication, defaults to 'localhost' | +| `[--authPort ]` | port scope of the authentication, defaults to '443' | +| `[--isecure]` | Similar to `curl -k` or `curl --insecure`: if unspecified, all SSL connections are secure by default; if specified, trust everything (do not use for production!) | + + diff --git a/jsonldplayground b/jsonldplayground index fb6a6cc..1edf4db 100755 --- a/jsonldplayground +++ b/jsonldplayground @@ -6,9 +6,11 @@ # # run ./jsonldplayground for the usage -if [ ! -d "target/appassembler/bin" ]; then - mvn -quiet clean install -DskipTests +TOP=$(dirname $0) + +if [ ! -d "${TOP}/target/appassembler/bin" ]; then + (cd "${TOP}"; mvn -quiet clean install -DskipTests) fi -chmod u+x target/appassembler/bin/* -target/appassembler/bin/jsonldplayground "$@" +chmod u+x "${TOP}/target/appassembler/bin"/* +"${TOP}/target/appassembler/bin/jsonldplayground" "$@" diff --git a/src/main/java/com/github/jsonldjava/tools/Playground.java b/src/main/java/com/github/jsonldjava/tools/Playground.java index 45f70f1..b5588ab 100644 --- a/src/main/java/com/github/jsonldjava/tools/Playground.java +++ b/src/main/java/com/github/jsonldjava/tools/Playground.java @@ -6,12 +6,23 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; +import java.net.Socket; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLEngine; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509ExtendedTrustManager; +import javax.net.ssl.X509TrustManager; + import joptsimple.OptionException; import joptsimple.OptionParser; import joptsimple.OptionSet; @@ -19,13 +30,27 @@ import joptsimple.ValueConversionException; import joptsimple.ValueConverter; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.UsernamePasswordCredentials; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.cache.BasicHttpCacheStorage; +import org.apache.http.impl.client.cache.CacheConfig; +import org.apache.http.impl.client.cache.CachingHttpClientBuilder; import org.eclipse.rdf4j.model.Model; import org.eclipse.rdf4j.rio.RDFFormat; import org.eclipse.rdf4j.rio.RDFParserRegistry; import org.eclipse.rdf4j.rio.Rio; +import com.github.jsonldjava.core.DocumentLoader; +import com.github.jsonldjava.core.JsonLdConsts; +import com.github.jsonldjava.core.JsonLdApi; import com.github.jsonldjava.core.JsonLdOptions; import com.github.jsonldjava.core.JsonLdProcessor; +import com.github.jsonldjava.core.RDFDataset; +import com.github.jsonldjava.utils.JarCacheStorage; import com.github.jsonldjava.utils.JsonUtils; public class Playground { @@ -50,6 +75,37 @@ private static Map getOutputFormats() { return outputFormats; } + private static class InsecureX509TrustManager extends X509ExtendedTrustManager implements X509TrustManager { + + public void checkClientTrusted(X509Certificate[] xcs, String string) { + } + + @Override + public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { + } + + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { + } + + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { + } + } + public static void main(String[] args) throws Exception { final Map formats = getOutputFormats(); @@ -145,6 +201,22 @@ public Class valueType() { "The way to output the results from fromRDF. Defaults to expanded. Valid values are: " + outputForms); + final OptionSpec usernameOption = parser.accepts("username").withOptionalArg() + .ofType(String.class).describedAs("username for basic authentication credentials"); + + final OptionSpec passwordOption = parser.accepts("password").withOptionalArg() + .ofType(String.class).describedAs("password for basic authentication credentials (defaults to value of 'PASSWORD' environment property, if set, or empty string otherwise)"); + + final OptionSpec authHostOption = parser.accepts("authHost").withOptionalArg() + .ofType(String.class).defaultsTo("localhost") + .describedAs("host authentication scope"); + + final OptionSpec authPortOption = parser.accepts("authPort").withOptionalArg() + .ofType(Integer.class).defaultsTo(443) + .describedAs("host port authentication scope"); + + final OptionSpec authInsecureOption = parser.accepts("insecure","Similar to `curl -k` or `curl --insecure`: if unspecified, all SSL connections are secure by default; if specified, trust everything (do not use for production!)"); + OptionSet options = null; try { @@ -167,7 +239,7 @@ public Class valueType() { opts.setBase(options.valueOf(base)); opts.outputForm = options.valueOf(outputForm); opts.format = options.has(outputFormat) ? options.valueOf(outputFormat).getDefaultMIMEType() - : "application/nquads"; + : JsonLdConsts.APPLICATION_NQUADS; final RDFFormat sesameOutputFormat = options.valueOf(outputFormat); final RDFFormat sesameInputFormat = Rio .getParserFormatForFileName(options.valueOf(inputFile).getName()) @@ -186,6 +258,85 @@ public Class valueType() { opts.setBase(options.valueOf(inputFile).toURI().toASCIIString()); } + if (options.hasArgument(usernameOption)) { + final String username = options.valueOf(usernameOption); + final String envPassword = System.getenv("PASSWORD"); + final String password = options.hasArgument(passwordOption) + ? options.valueOf(passwordOption) + : (null != envPassword) ? envPassword : ""; + final String authHost = options.valueOf(authHostOption); + final Integer authPort = options.valueOf(authPortOption); + + final DocumentLoader documentLoader = new DocumentLoader(); + + final CredentialsProvider credsProvider = new BasicCredentialsProvider(); + credsProvider.setCredentials( + new AuthScope(authHost, authPort), + new UsernamePasswordCredentials(username, password)); + + final CacheConfig cacheConfig = CacheConfig.custom() + .setMaxCacheEntries(1000) + .setMaxObjectSize(1024 * 128).build(); + + if (options.has(authInsecureOption)) { + + final SSLContext ctx = SSLContext.getInstance("TLS"); + final X509TrustManager tm = new InsecureX509TrustManager(); + ctx.init(null, new TrustManager[] { tm }, null); + + final HostnameVerifier v = new HostnameVerifier() { + + @Override + public boolean verify(String s, SSLSession sslSession) { + return true; + } + }; + + final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(ctx, v); + + final CloseableHttpClient httpClient = CachingHttpClientBuilder + .create() + // allow caching + .setCacheConfig(cacheConfig) + // Wrap the local JarCacheStorage around a BasicHttpCacheStorage + .setHttpCacheStorage( + new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage( + cacheConfig))) + + // Add in the credentials provider + .setDefaultCredentialsProvider(credsProvider) + + // insecure ssl connections + .setSSLSocketFactory(sslsf) + + // When you are finished setting the properties, call build + .build(); + documentLoader.setHttpClient(httpClient); + opts.setDocumentLoader(documentLoader); + + } else { + + final CloseableHttpClient httpClient = CachingHttpClientBuilder + .create() + // allow caching + .setCacheConfig(cacheConfig) + // Wrap the local JarCacheStorage around a BasicHttpCacheStorage + .setHttpCacheStorage( + new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage( + cacheConfig))) + + // Add in the credentials provider + .setDefaultCredentialsProvider(credsProvider) + + // When you are finished setting the properties, call build + .build(); + + documentLoader.setHttpClient(httpClient); + opts.setDocumentLoader(documentLoader); + + } + } + if ("fromrdf".equals(processingOptionValue)) { inobj = readFile(options.valueOf(inputFile)); } else { @@ -223,7 +374,26 @@ public Class valueType() { } outobj = JsonLdProcessor.compact(inobj, ctxobj, opts); } else if ("normalize".equals(processingOptionValue)) { - outobj = JsonLdProcessor.normalize(inobj, opts); + // see https://github.com/jsonld-java/jsonld-java/issues/193 + // outobj = JsonLdProcessor.normalize(inobj, opts); + + // see https://github.com/jsonld-java/jsonld-java/issues/194 + // until this is fixed, it is necessary to clear the format so that JsonLdProcessor won't try to interpret it. + opts.format = null; + + // If an output format is specified, add a callback to show the result. + Object result = JsonLdProcessor.toRDF( + inobj, + options.has(outputFormat) + ? new RDF4JJSONLDTripleCallback(Rio.createWriter(sesameOutputFormat, System.out)) + : null, + opts); + if (RDFDataset.class.isInstance(result)) { + RDFDataset rdfds = RDFDataset.class.cast(result); + outobj = new JsonLdApi(opts).normalize(rdfds); + } else + outobj = result; + } else if ("frame".equals(processingOptionValue)) { if (ctxobj != null && !(ctxobj instanceof Map)) { System.out.println( @@ -244,7 +414,9 @@ public Class valueType() { if ("tordf".equals(processingOptionValue)) { // Already serialised above } else if ("normalize".equals(processingOptionValue)) { - System.out.println((String) outobj); + if (!options.has(outputFormat)) + // if no output format was specified, then show the result. + System.out.println(JsonUtils.toPrettyString(outobj)); } else { System.out.println(JsonUtils.toPrettyString(outobj)); } From 0d3b83ca5e85000bb1010a9c27ccc48d4278d3a2 Mon Sep 17 00:00:00 2001 From: travisfw Date: Fri, 5 May 2017 16:20:55 -0700 Subject: [PATCH 23/41] info message: calling maven, and the dependency on jsonld-java --- jsonldplayground | 1 + 1 file changed, 1 insertion(+) diff --git a/jsonldplayground b/jsonldplayground index fb6a6cc..fb26a6f 100755 --- a/jsonldplayground +++ b/jsonldplayground @@ -7,6 +7,7 @@ # run ./jsonldplayground for the usage if [ ! -d "target/appassembler/bin" ]; then + echo -e "Building with maven... (This could fail if you haven't previously run 'mvn install' on jsonld-java)\n">&2 mvn -quiet clean install -DskipTests fi From e7350841a9a904e995d58527756571ecebd16572 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Aug 2017 10:03:11 +1000 Subject: [PATCH 24/41] Bump dependency versions Signed-off-by: Peter Ansell --- pom.xml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 5a315ba..31354fe 100644 --- a/pom.xml +++ b/pom.xml @@ -4,27 +4,24 @@ jsonld-java-parent com.github.jsonld-java - 0.10.1-SNAPSHOT + 0.11.0 4.0.0 jsonld-java-tools + 0.11.0-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar - 2.2 - 1.8 - 1.8 - 1.8 - 1.8 + 2.2.2 ${project.groupId} jsonld-java - ${project.version} + 0.11.0 junit @@ -39,7 +36,7 @@ net.sf.jopt-simple jopt-simple - 5.0.3 + 5.0.4 org.eclipse.rdf4j From b982d461e3d1990f8b031f914b96ce72843d1b77 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Aug 2017 10:43:51 +1000 Subject: [PATCH 25/41] Cleanup in Playground Signed-off-by: Peter Ansell --- .../github/jsonldjava/tools/Playground.java | 157 +++++++----------- 1 file changed, 61 insertions(+), 96 deletions(-) diff --git a/src/main/java/com/github/jsonldjava/tools/Playground.java b/src/main/java/com/github/jsonldjava/tools/Playground.java index b5588ab..66c8a1b 100644 --- a/src/main/java/com/github/jsonldjava/tools/Playground.java +++ b/src/main/java/com/github/jsonldjava/tools/Playground.java @@ -4,9 +4,10 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStreamReader; import java.io.StringReader; import java.net.Socket; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.Arrays; @@ -53,59 +54,11 @@ import com.github.jsonldjava.utils.JarCacheStorage; import com.github.jsonldjava.utils.JsonUtils; +/** + * A command-line-interface used to load and process JSON-LD and RDF files. + */ public class Playground { - private static Set getProcessingOptions() { - return new LinkedHashSet(Arrays.asList("expand", "compact", "frame", "normalize", - "flatten", "fromrdf", "tordf")); - } - - private static boolean hasContext(String opt) { - return "compact".equals(opt) || "frame".equals(opt) || "flatten".equals(opt); - } - - private static Map getOutputFormats() { - final Map outputFormats = new HashMap(); - - for (final RDFFormat format : RDFParserRegistry.getInstance().getKeys()) { - outputFormats.put( - format.getName().replaceAll("-", "").replaceAll("/", "").toLowerCase(), format); - } - - return outputFormats; - } - - private static class InsecureX509TrustManager extends X509ExtendedTrustManager implements X509TrustManager { - - public void checkClientTrusted(X509Certificate[] xcs, String string) { - } - - @Override - public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { - } - - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return null; - } - - - @Override - public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { - } - - @Override - public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { - } - - @Override - public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { - } - } - public static void main(String[] args) throws Exception { final Map formats = getOutputFormats(); @@ -391,9 +344,9 @@ public boolean verify(String s, SSLSession sslSession) { if (RDFDataset.class.isInstance(result)) { RDFDataset rdfds = RDFDataset.class.cast(result); outobj = new JsonLdApi(opts).normalize(rdfds); - } else + } else { outobj = result; - + } } else if ("frame".equals(processingOptionValue)) { if (ctxobj != null && !(ctxobj instanceof Map)) { System.out.println( @@ -414,64 +367,76 @@ public boolean verify(String s, SSLSession sslSession) { if ("tordf".equals(processingOptionValue)) { // Already serialised above } else if ("normalize".equals(processingOptionValue)) { - if (!options.has(outputFormat)) + if (!options.has(outputFormat)) { // if no output format was specified, then show the result. System.out.println(JsonUtils.toPrettyString(outobj)); + } } else { System.out.println(JsonUtils.toPrettyString(outobj)); } } + private static Set getProcessingOptions() { + return new LinkedHashSet(Arrays.asList("expand", "compact", "frame", "normalize", + "flatten", "fromrdf", "tordf")); + } + + private static boolean hasContext(String opt) { + return "compact".equals(opt) || "frame".equals(opt) || "flatten".equals(opt); + } + + private static Map getOutputFormats() { + final Map outputFormats = new HashMap(); + + for (final RDFFormat format : RDFParserRegistry.getInstance().getKeys()) { + outputFormats.put( + format.getName().replaceAll("-", "").replaceAll("/", "").toLowerCase(), format); + } + + return outputFormats; + } + private static String readFile(File in) throws IOException { - final BufferedReader buf = new BufferedReader( - new InputStreamReader(new FileInputStream(in), "UTF-8")); String inobj = ""; - try { + try (BufferedReader buf = Files.newBufferedReader(in.toPath(), StandardCharsets.UTF_8)){ String line; while ((line = buf.readLine()) != null) { line = line.trim(); inobj = (inobj) + line + "\n"; } - } finally { - buf.close(); } return inobj; } - // private static void usage() { - // System.out.println("Usage: jsonldplayground "); - // System.out.println("\tinput: a filename or JsonLdUrl to the rdf input (in - // rdfxml or n3)"); - // System.out.println("\toptions:"); - // System.out - // .println("\t\t--ignorekeys : a (space separated) list of - // keys to ignore (e.g. @geojson)"); - // System.out.println("\t\t--base : base URI"); - // System.out.println("\t\t--debug: Print out stack traces when errors - // occur"); - // System.out.println("\t\t--expand : expand the input JSON-LD"); - // System.out - // .println("\t\t--compact : compact the input JSON-LD - // applying the optional context file"); - // System.out - // .println("\t\t--normalize : normalize the input JSON-LD - // outputting as format (defaults to nquads)"); - // System.out - // .println("\t\t--frame : frame the input JSON-LD with the - // optional frame file"); - // System.out - // .println("\t\t--flatten : flatten the input JSON-LD - // applying the optional context file"); - // System.out - // .println("\t\t--fromRDF : generate JSON-LD from the - // input rdf (format defaults to nquads)"); - // System.out - // .println("\t\t--toRDF : generate RDF from the input - // JSON-LD (format defaults to nquads)"); - // System.out - // .println("\t\t--outputForm [compacted|expanded|flattened] : the way to - // output the results from fromRDF (defaults to expanded)"); - // System.out.println("\t\t--simplify : simplify the input JSON-LD"); - // System.exit(1); - // } + private static class InsecureX509TrustManager extends X509ExtendedTrustManager implements X509TrustManager { + + public void checkClientTrusted(X509Certificate[] xcs, String string) { + } + + @Override + public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { + } + + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return null; + } + + + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { + } + + @Override + public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { + } + + @Override + public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { + } + } + } From da704401b3ef12c52206540df320dd4a9a5d4320 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Aug 2017 10:46:44 +1000 Subject: [PATCH 26/41] Fix CLI option typo Signed-off-by: Peter Ansell --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d632ba3..4f6972d 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,6 @@ Authentication involves 5 options: | `[--password ]` | password for basic authentication, defaults to the value of the `PASSWORD` environment variable, if any, or the empty string. | | `[--authHost ]` | host scope of the authentication, defaults to 'localhost' | | `[--authPort ]` | port scope of the authentication, defaults to '443' | -| `[--isecure]` | Similar to `curl -k` or `curl --insecure`: if unspecified, all SSL connections are secure by default; if specified, trust everything (do not use for production!) | +| `[--insecure]` | Similar to `curl -k` or `curl --insecure`: if unspecified, all SSL connections are secure by default; if specified, trust everything (do not use for production!) | From e33e7cc58657bcb8ba64bfc3835c370510355fa5 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Aug 2017 10:52:09 +1000 Subject: [PATCH 27/41] Release 0.11.0 Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 31354fe..978394c 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 jsonld-java-tools - 0.11.0-SNAPSHOT + 0.11.0 JSONLD Java :: Tools JSON-LD Java tools jar From 3a085bd5e618cea96ef7bbe1cebd51c790e34566 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Aug 2017 11:07:49 +1000 Subject: [PATCH 28/41] Bump to next development version Note, the parent is being left as a static reference so it can be resolved from Maven Central, however, the library itself will be resolved from the latest snapshot Signed-off-by: Peter Ansell --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 978394c..18164b7 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 jsonld-java-tools - 0.11.0 + 0.11.1-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar @@ -21,7 +21,7 @@ ${project.groupId} jsonld-java - 0.11.0 + 0.11.1-SNAPSHOT junit From 5631eb10a6886e152854ce788baa321684a0fa2c Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sun, 8 Apr 2018 15:01:38 +1000 Subject: [PATCH 29/41] Release 0.12.0 Signed-off-by: Peter Ansell --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 18164b7..dcf727a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,24 +4,24 @@ jsonld-java-parent com.github.jsonld-java - 0.11.0 + 0.12.0 4.0.0 jsonld-java-tools - 0.11.1-SNAPSHOT + 0.12.0 JSONLD Java :: Tools JSON-LD Java tools jar - 2.2.2 + 2.3.0 ${project.groupId} jsonld-java - 0.11.1-SNAPSHOT + 0.12.0 junit From f9738cd4054966ba8aa1b163ed16d516cca60824 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sun, 8 Apr 2018 15:17:39 +1000 Subject: [PATCH 30/41] Bump to next development snapshot Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dcf727a..d28136b 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 jsonld-java-tools - 0.12.0 + 0.12.1-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar From 354d497f6cd5242d902b3f6b36ebacee0af8eebe Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Fri, 7 Sep 2018 14:25:56 +1000 Subject: [PATCH 31/41] Release 0.12.1 Signed-off-by: Peter Ansell --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index d28136b..0a72046 100644 --- a/pom.xml +++ b/pom.xml @@ -4,24 +4,24 @@ jsonld-java-parent com.github.jsonld-java - 0.12.0 + 0.12.1 4.0.0 jsonld-java-tools - 0.12.1-SNAPSHOT + 0.12.1 JSONLD Java :: Tools JSON-LD Java tools jar - 2.3.0 + 2.3.2 ${project.groupId} jsonld-java - 0.12.0 + 0.12.1 junit From 55974d4e45aef4e658836d11806bc77e676c7c6b Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Fri, 7 Sep 2018 14:36:36 +1000 Subject: [PATCH 32/41] Bump to development version Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0a72046..7ab9579 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 jsonld-java-tools - 0.12.1 + 0.12.2-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar From 5174f1f2e31a75c1cca0b538adedd87aca59040e Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Fri, 7 Sep 2018 14:43:23 +1000 Subject: [PATCH 33/41] Remove emails from travis config Signed-off-by: Peter Ansell --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f39b742..b9cc140 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,5 @@ cache: - $HOME/.m2 jdk: - oraclejdk8 -notifications: - email: - - ansell.peter@gmail.com - - tristan.king@gmail.com after_success: - mvn clean test jacoco:report coveralls:report From 222d00b3f46e186baeb2d2cacb242b1d7314344b Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 3 Nov 2018 08:43:07 +1100 Subject: [PATCH 34/41] Cleanup Signed-off-by: Peter Ansell --- pom.xml | 4 +- .../github/jsonldjava/tools/Playground.java | 142 ++++++++---------- .../tools/RDF4JJSONLDRDFParser.java | 4 +- .../tools/RDF4JJSONLDTripleCallback.java | 4 +- 4 files changed, 66 insertions(+), 88 deletions(-) diff --git a/pom.xml b/pom.xml index 7ab9579..a8e939a 100644 --- a/pom.xml +++ b/pom.xml @@ -14,14 +14,14 @@ jar - 2.3.2 + 2.4.1 ${project.groupId} jsonld-java - 0.12.1 + 0.12.2-SNAPSHOT junit diff --git a/src/main/java/com/github/jsonldjava/tools/Playground.java b/src/main/java/com/github/jsonldjava/tools/Playground.java index 66c8a1b..59316d0 100644 --- a/src/main/java/com/github/jsonldjava/tools/Playground.java +++ b/src/main/java/com/github/jsonldjava/tools/Playground.java @@ -24,19 +24,12 @@ import javax.net.ssl.X509ExtendedTrustManager; import javax.net.ssl.X509TrustManager; -import joptsimple.OptionException; -import joptsimple.OptionParser; -import joptsimple.OptionSet; -import joptsimple.OptionSpec; -import joptsimple.ValueConversionException; -import joptsimple.ValueConverter; - import org.apache.http.auth.AuthScope; import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.cache.BasicHttpCacheStorage; import org.apache.http.impl.client.cache.CacheConfig; import org.apache.http.impl.client.cache.CachingHttpClientBuilder; @@ -46,14 +39,21 @@ import org.eclipse.rdf4j.rio.Rio; import com.github.jsonldjava.core.DocumentLoader; -import com.github.jsonldjava.core.JsonLdConsts; import com.github.jsonldjava.core.JsonLdApi; +import com.github.jsonldjava.core.JsonLdConsts; import com.github.jsonldjava.core.JsonLdOptions; import com.github.jsonldjava.core.JsonLdProcessor; import com.github.jsonldjava.core.RDFDataset; import com.github.jsonldjava.utils.JarCacheStorage; import com.github.jsonldjava.utils.JsonUtils; +import joptsimple.OptionException; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; +import joptsimple.ValueConversionException; +import joptsimple.ValueConverter; + /** * A command-line-interface used to load and process JSON-LD and RDF files. */ @@ -81,14 +81,14 @@ public static void main(String[] args) throws Exception { final OptionSpec outputFormat = parser.accepts("format").withOptionalArg() .ofType(String.class).withValuesConvertedBy(new ValueConverter() { @Override - public RDFFormat convert(String arg0) { + public RDFFormat convert(String inputFormat) { // Normalise the name to provide alternatives - final String formatName = arg0.replaceAll("-", "").replaceAll("/", "") - .toLowerCase(); + final String formatName = inputFormat.replaceAll("-", "") + .replaceAll("/", "").toLowerCase(); if (formats.containsKey(formatName)) { return formats.get(formatName); } - throw new ValueConversionException("Format was not known: " + arg0 + throw new ValueConversionException("Format was not known: " + inputFormat + " (Valid values are: " + formats.keySet() + ")"); } @@ -158,7 +158,8 @@ public Class valueType() { .ofType(String.class).describedAs("username for basic authentication credentials"); final OptionSpec passwordOption = parser.accepts("password").withOptionalArg() - .ofType(String.class).describedAs("password for basic authentication credentials (defaults to value of 'PASSWORD' environment property, if set, or empty string otherwise)"); + .ofType(String.class).describedAs( + "password for basic authentication credentials (defaults to value of 'PASSWORD' environment property, if set, or empty string otherwise)"); final OptionSpec authHostOption = parser.accepts("authHost").withOptionalArg() .ofType(String.class).defaultsTo("localhost") @@ -168,7 +169,8 @@ public Class valueType() { .ofType(Integer.class).defaultsTo(443) .describedAs("host port authentication scope"); - final OptionSpec authInsecureOption = parser.accepts("insecure","Similar to `curl -k` or `curl --insecure`: if unspecified, all SSL connections are secure by default; if specified, trust everything (do not use for production!)"); + final OptionSpec authInsecureOption = parser.accepts("insecure", + "Similar to `curl -k` or `curl --insecure`: if unspecified, all SSL connections are secure by default; if specified, trust everything (do not use for production!)"); OptionSet options = null; @@ -223,22 +225,25 @@ public Class valueType() { final DocumentLoader documentLoader = new DocumentLoader(); final CredentialsProvider credsProvider = new BasicCredentialsProvider(); - credsProvider.setCredentials( - new AuthScope(authHost, authPort), + credsProvider.setCredentials(new AuthScope(authHost, authPort), new UsernamePasswordCredentials(username, password)); - final CacheConfig cacheConfig = CacheConfig.custom() - .setMaxCacheEntries(1000) + final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000) .setMaxObjectSize(1024 * 128).build(); - if (options.has(authInsecureOption)) { + HttpClientBuilder builder = CachingHttpClientBuilder.create() + // allow caching + .setCacheConfig(cacheConfig) + // Wrap the local JarCacheStorage around a + // BasicHttpCacheStorage + .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, + new BasicHttpCacheStorage(cacheConfig))) + .setDefaultCredentialsProvider(credsProvider); + if (options.has(authInsecureOption)) { final SSLContext ctx = SSLContext.getInstance("TLS"); - final X509TrustManager tm = new InsecureX509TrustManager(); - ctx.init(null, new TrustManager[] { tm }, null); - + ctx.init(null, new TrustManager[] { new InsecureX509TrustManager() }, null); final HostnameVerifier v = new HostnameVerifier() { - @Override public boolean verify(String s, SSLSession sslSession) { return true; @@ -246,48 +251,12 @@ public boolean verify(String s, SSLSession sslSession) { }; final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(ctx, v); - - final CloseableHttpClient httpClient = CachingHttpClientBuilder - .create() - // allow caching - .setCacheConfig(cacheConfig) - // Wrap the local JarCacheStorage around a BasicHttpCacheStorage - .setHttpCacheStorage( - new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage( - cacheConfig))) - - // Add in the credentials provider - .setDefaultCredentialsProvider(credsProvider) - - // insecure ssl connections - .setSSLSocketFactory(sslsf) - - // When you are finished setting the properties, call build - .build(); - documentLoader.setHttpClient(httpClient); - opts.setDocumentLoader(documentLoader); - - } else { - - final CloseableHttpClient httpClient = CachingHttpClientBuilder - .create() - // allow caching - .setCacheConfig(cacheConfig) - // Wrap the local JarCacheStorage around a BasicHttpCacheStorage - .setHttpCacheStorage( - new JarCacheStorage(null, cacheConfig, new BasicHttpCacheStorage( - cacheConfig))) - - // Add in the credentials provider - .setDefaultCredentialsProvider(credsProvider) - - // When you are finished setting the properties, call build - .build(); - - documentLoader.setHttpClient(httpClient); - opts.setDocumentLoader(documentLoader); - + // insecure ssl connections + builder = builder.setSSLSocketFactory(sslsf); } + + documentLoader.setHttpClient(builder.build()); + opts.setDocumentLoader(documentLoader); } if ("fromrdf".equals(processingOptionValue)) { @@ -331,18 +300,20 @@ public boolean verify(String s, SSLSession sslSession) { // outobj = JsonLdProcessor.normalize(inobj, opts); // see https://github.com/jsonld-java/jsonld-java/issues/194 - // until this is fixed, it is necessary to clear the format so that JsonLdProcessor won't try to interpret it. + // until this is fixed, it is necessary to clear the format so that + // JsonLdProcessor won't try to interpret it. opts.format = null; - // If an output format is specified, add a callback to show the result. - Object result = JsonLdProcessor.toRDF( - inobj, + // If an output format is specified, add a callback to show the + // result. + final Object result = JsonLdProcessor.toRDF(inobj, options.has(outputFormat) - ? new RDF4JJSONLDTripleCallback(Rio.createWriter(sesameOutputFormat, System.out)) + ? new RDF4JJSONLDTripleCallback( + Rio.createWriter(sesameOutputFormat, System.out)) : null, opts); if (RDFDataset.class.isInstance(result)) { - RDFDataset rdfds = RDFDataset.class.cast(result); + final RDFDataset rdfds = RDFDataset.class.cast(result); outobj = new JsonLdApi(opts).normalize(rdfds); } else { outobj = result; @@ -397,45 +368,52 @@ private static Map getOutputFormats() { } private static String readFile(File in) throws IOException { - String inobj = ""; - try (BufferedReader buf = Files.newBufferedReader(in.toPath(), StandardCharsets.UTF_8)){ + final StringBuilder inobj = new StringBuilder(1024); + try (BufferedReader buf = Files.newBufferedReader(in.toPath(), StandardCharsets.UTF_8)) { String line; while ((line = buf.readLine()) != null) { line = line.trim(); - inobj = (inobj) + line + "\n"; + inobj.append(line).append('\n'); } } - return inobj; + return inobj.toString(); } - private static class InsecureX509TrustManager extends X509ExtendedTrustManager implements X509TrustManager { + private static class InsecureX509TrustManager extends X509ExtendedTrustManager + implements X509TrustManager { + @Override public void checkClientTrusted(X509Certificate[] xcs, String string) { } @Override - public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { + public void checkServerTrusted(X509Certificate[] xcs, String string) + throws CertificateException { } + @Override public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } - @Override - public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { + public void checkClientTrusted(X509Certificate[] x509Certificates, String s, Socket socket) + throws CertificateException { } @Override - public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) throws CertificateException { + public void checkServerTrusted(X509Certificate[] x509Certificates, String s, Socket socket) + throws CertificateException { } @Override - public void checkClientTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { + public void checkClientTrusted(X509Certificate[] x509Certificates, String s, + SSLEngine sslEngine) throws CertificateException { } @Override - public void checkServerTrusted(X509Certificate[] x509Certificates, String s, SSLEngine sslEngine) throws CertificateException { + public void checkServerTrusted(X509Certificate[] x509Certificates, String s, + SSLEngine sslEngine) throws CertificateException { } } diff --git a/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java index 2296070..41af3ea 100644 --- a/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java +++ b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDRDFParser.java @@ -4,12 +4,12 @@ import java.util.Set; import org.eclipse.rdf4j.model.BNode; +import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Literal; import org.eclipse.rdf4j.model.Model; import org.eclipse.rdf4j.model.Namespace; import org.eclipse.rdf4j.model.Resource; import org.eclipse.rdf4j.model.Statement; -import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Value; import org.eclipse.rdf4j.model.vocabulary.RDF; import org.eclipse.rdf4j.model.vocabulary.XMLSchema; @@ -18,7 +18,7 @@ import com.github.jsonldjava.core.RDFDataset; /** - * Implementation of RDFParser for RDF4J-2.2. + * Implementation of RDFParser for RDF4J-2. * * @author Peter Ansell */ diff --git a/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java index 20dafde..497d83c 100644 --- a/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java +++ b/src/main/java/com/github/jsonldjava/tools/RDF4JJSONLDTripleCallback.java @@ -3,9 +3,9 @@ import java.util.List; import java.util.Map.Entry; +import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Resource; import org.eclipse.rdf4j.model.Statement; -import org.eclipse.rdf4j.model.IRI; import org.eclipse.rdf4j.model.Value; import org.eclipse.rdf4j.model.ValueFactory; import org.eclipse.rdf4j.model.impl.LinkedHashModel; @@ -23,7 +23,7 @@ import com.github.jsonldjava.core.RDFDataset; /** - * Implementation of JsonLdTripleCallback for RDF4J-2.2. + * Implementation of JsonLdTripleCallback for RDF4J-2. * * @author Peter Ansell */ From 0050e55e2f826b8a2461052a177e8cd947d3b97d Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 3 Nov 2018 10:41:41 +1100 Subject: [PATCH 35/41] Release 0.12.2 Signed-off-by: Peter Ansell --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a8e939a..d1f5137 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ jsonld-java-parent com.github.jsonld-java - 0.12.1 + 0.12.2 4.0.0 jsonld-java-tools - 0.12.2-SNAPSHOT + 0.12.2 JSONLD Java :: Tools JSON-LD Java tools jar @@ -21,7 +21,7 @@ ${project.groupId} jsonld-java - 0.12.2-SNAPSHOT + 0.12.2 junit From dbb68a08d087413c384b4decc80b5d71d26a2cfc Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 3 Nov 2018 10:52:15 +1100 Subject: [PATCH 36/41] Bump to next development version Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d1f5137..518536c 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 jsonld-java-tools - 0.12.2 + 0.12.3-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar From eaa222f867a267ecd5b459f4be4d8f7ab791a71e Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 20 Apr 2019 07:15:53 +1000 Subject: [PATCH 37/41] Update rdf4j to latest Signed-off-by: Peter Ansell --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 518536c..b772dbc 100644 --- a/pom.xml +++ b/pom.xml @@ -4,24 +4,24 @@ jsonld-java-parent com.github.jsonld-java - 0.12.2 + 0.12.4-SNAPSHOT 4.0.0 jsonld-java-tools - 0.12.3-SNAPSHOT + 0.12.4-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar - 2.4.1 + 2.5.1 ${project.groupId} jsonld-java - 0.12.2 + 0.12.4-SNAPSHOT junit From 123ad8d51ca5c9321e351d66f399d38d6eab0e3d Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 20 Apr 2019 07:30:15 +1000 Subject: [PATCH 38/41] Release 0.12.4 Signed-off-by: Peter Ansell --- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b772dbc..1f1b907 100644 --- a/pom.xml +++ b/pom.xml @@ -4,11 +4,11 @@ jsonld-java-parent com.github.jsonld-java - 0.12.4-SNAPSHOT + 0.12.4 4.0.0 jsonld-java-tools - 0.12.4-SNAPSHOT + 0.12.4 JSONLD Java :: Tools JSON-LD Java tools jar @@ -21,7 +21,7 @@ ${project.groupId} jsonld-java - 0.12.4-SNAPSHOT + 0.12.4 junit From 354afd74b088524efa7ed6f34ffb82684fec1904 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 20 Apr 2019 07:38:52 +1000 Subject: [PATCH 39/41] Bump to next snapshot Signed-off-by: Peter Ansell --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1f1b907..00f5098 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ 4.0.0 jsonld-java-tools - 0.12.4 + 0.12.5-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar From 1fef3e5072271a1b10895314d79938d55511b712 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 20 Apr 2019 07:50:37 +1000 Subject: [PATCH 40/41] Add openjdk11 to travis Signed-off-by: Peter Ansell --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index b9cc140..6c8bfa2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,5 +5,11 @@ cache: - $HOME/.m2 jdk: - oraclejdk8 +matrix: + include: + - jdk: openjdk11 + before_install: + - rm "${JAVA_HOME}/lib/security/cacerts" + - ln -s /etc/ssl/certs/java/cacerts "${JAVA_HOME}/lib/security/cacerts" after_success: - mvn clean test jacoco:report coveralls:report From d3400b1698b47e8a7ad0af6404441cb4d305ad53 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 5 Feb 2020 08:52:17 +1100 Subject: [PATCH 41/41] Bump to recent rdf4j Signed-off-by: Peter Ansell --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 00f5098..64a90ca 100644 --- a/pom.xml +++ b/pom.xml @@ -4,24 +4,24 @@ jsonld-java-parent com.github.jsonld-java - 0.12.4 + 0.13.0 4.0.0 jsonld-java-tools - 0.12.5-SNAPSHOT + 0.13.0-SNAPSHOT JSONLD Java :: Tools JSON-LD Java tools jar - 2.5.1 + 3.0.4 ${project.groupId} jsonld-java - 0.12.4 + 0.13.0 junit