From c850eb30e8e94c469a5727b5c3d4c3634ceda51e Mon Sep 17 00:00:00 2001 From: Markus Sabadello Date: Fri, 10 Apr 2020 11:25:11 +0200 Subject: [PATCH 01/50] Shade Guava's internal failureaccess dependency. Signed-off-by: Markus Sabadello --- core/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/pom.xml b/core/pom.xml index c7ca4139..25431acb 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -74,6 +74,7 @@ com.google.guava:guava + com.google.guava:failureaccess @@ -90,6 +91,12 @@ META-INF/maven/** + + com.google.guava:failureaccess + + META-INF/maven/** + + From d310e593c31883ceca373b04706a8396b1072886 Mon Sep 17 00:00:00 2001 From: Emilio Lahr-Vivaz Date: Wed, 8 Jul 2020 11:12:47 -0400 Subject: [PATCH 02/50] Fix jarcache guava loading * Don't minimize guava shading, causes NoClassDefFoundError --- core/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/core/pom.xml b/core/pom.xml index 25431acb..1461c1e1 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -83,7 +83,6 @@ com.github.jsonldjava.shaded.com.google.common - true com.google.guava:guava From 2e1135dafb381fde7d508d055cad2e052dcc253d Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 24 Aug 2020 16:15:35 +0200 Subject: [PATCH 03/50] Follow alternate document location Implements https://www.w3.org/TR/json-ld11/#alternate-document-location. Resolves https://github.com/jsonld-java/jsonld-java/issues/289. --- .../github/jsonldjava/utils/JsonUtils.java | 68 +++++++++++++++---- .../core/MinimalSchemaOrgRegressionTest.java | 34 +++------- 2 files changed, 63 insertions(+), 39 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index f7e0581b..da210958 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -9,14 +9,17 @@ import java.io.StringWriter; import java.io.Writer; import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.net.URL; import java.util.List; import java.util.Map; import org.apache.commons.io.ByteOrderMark; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.BOMInputStream; +import org.apache.http.Header; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; @@ -344,18 +347,7 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) // Accept headers as it's likely to be file: or jar: in = url.openStream(); } else { - final HttpUriRequest request = new HttpGet(url.toExternalForm()); - // We prefer application/ld+json, but fallback to - // application/json - // or whatever is available - request.addHeader("Accept", ACCEPT_HEADER); - - response = httpClient.execute(request); - final int status = response.getStatusLine().getStatusCode(); - if (status != 200 && status != 203) { - throw new IOException("Can't retrieve " + url + ", status code: " + status); - } - in = response.getEntity().getContent(); + in = getJsonLdViaHttpUri(url, httpClient, response); } return fromInputStream(in); } finally { @@ -371,6 +363,56 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) } } + private static InputStream getJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient, + CloseableHttpResponse response) throws IOException { + final HttpUriRequest request = new HttpGet(url.toExternalForm()); + // We prefer application/ld+json, but fallback to application/json + // or whatever is available + request.addHeader("Accept", ACCEPT_HEADER); + response = httpClient.execute(request); + + final int status = response.getStatusLine().getStatusCode(); + if (status != 200 && status != 203) { + throw new IOException("Can't retrieve " + url + ", status code: " + status); + } + // follow alternate document location + // https://www.w3.org/TR/json-ld11/#alternate-document-location + URL alternateLink = alternateLink(url, response); + if (alternateLink != null) { + return getJsonLdViaHttpUri(alternateLink, httpClient, response); + } + return response.getEntity().getContent(); + } + + private static URL alternateLink(URL url, CloseableHttpResponse response) + throws MalformedURLException, IOException { + if (response.getEntity().getContentLength() > 0 + && !response.getEntity().getContentType().getValue().equals("application/ld+json")) { + for (Header header : response.getAllHeaders()) { + if (header.getName().equalsIgnoreCase("link")) { + String alternateLink = ""; + boolean relAlternate = false; + boolean jsonld = false; + for (String value : header.getValue().split(";")) { + if (value.trim().startsWith("<")) { + alternateLink = value.replaceAll("<(.*)>", "$1"); + } + if (value.trim().startsWith("type=\"application/ld+json\"")) { + jsonld = true; + } + if (value.trim().startsWith("rel=\"alternate\"")) { + relAlternate = true; + } + } + if (jsonld && relAlternate && !alternateLink.isEmpty()) { + return new URL(url.getProtocol() + "://" + url.getAuthority() + alternateLink); + } + } + } + } + return null; + } + /** * Fallback method directly using the {@link java.net.HttpURLConnection} * class for cases where servers do not interoperate correctly with Apache @@ -384,7 +426,7 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) * @throws IOException * If there was an IO error during parsing. */ - public static Object fromURLJavaNet(java.net.URL url) throws JsonParseException, IOException { + public static Object fromURLJavaNet(URL url) throws JsonParseException, IOException { final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); urlConn.addRequestProperty("Accept", ACCEPT_HEADER); diff --git a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java index f4c1b88d..03479f76 100644 --- a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java @@ -26,6 +26,7 @@ import org.junit.Test; import com.github.jsonldjava.utils.JarCacheStorage; +import com.github.jsonldjava.utils.JsonUtils; public class MinimalSchemaOrgRegressionTest { @@ -59,10 +60,13 @@ private void verifyInputStream(InputStream directStream) throws IOException { output.flush(); } final String outputString = output.toString(); - // System.out.println(outputString); + checkBasicConditions(outputString); + } + + private void checkBasicConditions(final String outputString) { // Test for some basic conditions without including the JSON/JSON-LD // parsing code here - // assertTrue(outputString, outputString.endsWith("}")); + assertTrue(outputString, outputString.endsWith("}")); assertFalse("Output string should not be empty: " + outputString.length(), outputString.isEmpty()); assertTrue("Unexpected length: " + outputString.length(), outputString.length() > 100000); @@ -90,30 +94,8 @@ public void testApacheHttpClient() throws Exception { // use system defaults for proxy etc. .useSystemProperties().build(); - try { - final HttpUriRequest request = new HttpGet(url.toExternalForm()); - // We prefer application/ld+json, but fallback to application/json - // or whatever is available - request.addHeader("Accept", ACCEPT_HEADER); - - final CloseableHttpResponse response = httpClient.execute(request); - try { - final int status = response.getStatusLine().getStatusCode(); - if (status != 200 && status != 203) { - throw new IOException("Can't retrieve " + url + ", status code: " + status); - } - final InputStream content = response.getEntity().getContent(); - verifyInputStream(content); - } finally { - if (response != null) { - response.close(); - } - } - } finally { - if (httpClient != null) { - httpClient.close(); - } - } + Object content = JsonUtils.fromURL(url, httpClient); + checkBasicConditions(content.toString()); } } From a2e6f8aed492fd6fb50ca920b683067a98c76c94 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 24 Aug 2020 17:59:45 +0200 Subject: [PATCH 04/50] Remove unused imports Complements the last commit. --- .../github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java index 03479f76..fef53b25 100644 --- a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java @@ -12,9 +12,6 @@ import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.protocol.RequestAcceptEncoding; import org.apache.http.client.protocol.ResponseContentEncoding; import org.apache.http.impl.client.CloseableHttpClient; From 2ef090b451af16baccd1b51ee792c52a46231c9d Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 24 Aug 2020 18:18:16 +0200 Subject: [PATCH 05/50] Remove ignored test The ignored test would test an expected behaviour of java.net.URL.HttpURLConnection, i.e. not to automatically follow redirects when this involves a protocol switching (e.g. from HTTP to HTTPS). See #289. --- .../core/MinimalSchemaOrgRegressionTest.java | 84 ++++++------------- 1 file changed, 27 insertions(+), 57 deletions(-) diff --git a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java index fef53b25..4e3c6868 100644 --- a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java @@ -19,7 +19,6 @@ 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.junit.Ignore; import org.junit.Test; import com.github.jsonldjava.utils.JarCacheStorage; @@ -27,37 +26,34 @@ public class MinimalSchemaOrgRegressionTest { - private static final String ACCEPT_HEADER = "application/ld+json, application/json;q=0.9, application/javascript;q=0.5, text/javascript;q=0.5, text/plain;q=0.2, */*;q=0.1"; - - @Ignore("Java API does not have any way of redirecting automatically from HTTP to HTTPS, which breaks schema.org usage with it") + /** + * Tests getting JSON from schema.org with the HTTP Accept header set to + * {@value com.github.jsonldjava.utils.JsonUtils#ACCEPT_HEADER}? . + */ @Test - public void testHttpURLConnection() throws Exception { + public void testApacheHttpClient() throws Exception { final URL url = new URL("http://schema.org/"); - final boolean followRedirectsSetting = HttpURLConnection.getFollowRedirects(); - try { - HttpURLConnection.setFollowRedirects(true); - final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); - urlConn.setInstanceFollowRedirects(true); - urlConn.addRequestProperty("Accept", ACCEPT_HEADER); - - final InputStream directStream = urlConn.getInputStream(); - verifyInputStream(directStream); - } finally { - HttpURLConnection.setFollowRedirects(followRedirectsSetting); - } - } - - private void verifyInputStream(InputStream directStream) throws IOException { - assertNotNull("InputStream was null", directStream); - final StringWriter output = new StringWriter(); - try { - IOUtils.copy(directStream, output, StandardCharsets.UTF_8); - } finally { - directStream.close(); - output.flush(); - } - final String outputString = output.toString(); - checkBasicConditions(outputString); + // Common CacheConfig for both the JarCacheStorage and the underlying + // BasicHttpCacheStorage + final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000) + .setMaxObjectSize(1024 * 128).build(); + + final CloseableHttpClient httpClient = CachingHttpClientBuilder.create() + // allow caching + .setCacheConfig(cacheConfig) + // Wrap the local JarCacheStorage around a BasicHttpCacheStorage + .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, + new BasicHttpCacheStorage(cacheConfig))) + // Support compressed data + // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 + .addInterceptorFirst(new RequestAcceptEncoding()) + .addInterceptorFirst(new ResponseContentEncoding()) + .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) + // use system defaults for proxy etc. + .useSystemProperties().build(); + + Object content = JsonUtils.fromURL(url, httpClient); + checkBasicConditions(content.toString()); } private void checkBasicConditions(final String outputString) { @@ -68,31 +64,5 @@ private void checkBasicConditions(final String outputString) { outputString.isEmpty()); assertTrue("Unexpected length: " + outputString.length(), outputString.length() > 100000); } - - @Test - public void testApacheHttpClient() throws Exception { - final URL url = new URL("http://schema.org/"); - // Common CacheConfig for both the JarCacheStorage and the underlying - // BasicHttpCacheStorage - final CacheConfig cacheConfig = CacheConfig.custom().setMaxCacheEntries(1000) - .setMaxObjectSize(1024 * 128).build(); - - final CloseableHttpClient httpClient = CachingHttpClientBuilder.create() - // allow caching - .setCacheConfig(cacheConfig) - // Wrap the local JarCacheStorage around a BasicHttpCacheStorage - .setHttpCacheStorage(new JarCacheStorage(null, cacheConfig, - new BasicHttpCacheStorage(cacheConfig))) - // Support compressed data - // http://hc.apache.org/httpcomponents-client-ga/tutorial/html/httpagent.html#d5e1238 - .addInterceptorFirst(new RequestAcceptEncoding()) - .addInterceptorFirst(new ResponseContentEncoding()) - .setRedirectStrategy(DefaultRedirectStrategy.INSTANCE) - // use system defaults for proxy etc. - .useSystemProperties().build(); - - Object content = JsonUtils.fromURL(url, httpClient); - checkBasicConditions(content.toString()); - } - + } From a2f3c9f7b15e26b03bc4c3137555eb5b5efd3d07 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Tue, 25 Aug 2020 10:50:42 +0200 Subject: [PATCH 06/50] Reorganize imports - remove unused imports - sorted alphabetically --- .../github/jsonldjava/utils/JsonUtils.java | 24 +++++++++---------- .../core/MinimalSchemaOrgRegressionTest.java | 13 +++------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index da210958..9e1ec875 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -10,12 +10,23 @@ import java.io.Writer; import java.net.HttpURLConnection; import java.net.MalformedURLException; +import java.net.URL; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.net.URL; import java.util.List; import java.util.Map; +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.jsonldjava.core.DocumentLoader; +import com.github.jsonldjava.core.JsonLdApi; +import com.github.jsonldjava.core.JsonLdProcessor; + import org.apache.commons.io.ByteOrderMark; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.BOMInputStream; @@ -32,17 +43,6 @@ import org.apache.http.impl.client.cache.CacheConfig; import org.apache.http.impl.client.cache.CachingHttpClientBuilder; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerationException; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.jsonldjava.core.DocumentLoader; -import com.github.jsonldjava.core.JsonLdApi; -import com.github.jsonldjava.core.JsonLdProcessor; - /** * Functions used to make loading, parsing, and serializing JSON easy using * Jackson. diff --git a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java index 4e3c6868..4694f897 100644 --- a/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/MinimalSchemaOrgRegressionTest.java @@ -1,17 +1,13 @@ package com.github.jsonldjava.core; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.io.IOException; -import java.io.InputStream; -import java.io.StringWriter; -import java.net.HttpURLConnection; import java.net.URL; -import java.nio.charset.StandardCharsets; -import org.apache.commons.io.IOUtils; +import com.github.jsonldjava.utils.JarCacheStorage; +import com.github.jsonldjava.utils.JsonUtils; + import org.apache.http.client.protocol.RequestAcceptEncoding; import org.apache.http.client.protocol.ResponseContentEncoding; import org.apache.http.impl.client.CloseableHttpClient; @@ -21,9 +17,6 @@ import org.apache.http.impl.client.cache.CachingHttpClientBuilder; import org.junit.Test; -import com.github.jsonldjava.utils.JarCacheStorage; -import com.github.jsonldjava.utils.JsonUtils; - public class MinimalSchemaOrgRegressionTest { /** From 776e77dc63612ef294b814e3ad5d25fddf6e8e1e Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Tue, 25 Aug 2020 14:37:27 +0200 Subject: [PATCH 07/50] Try-with on response in the submethod As proposed in https://github.com/jsonld-java/jsonld-java/pull/292#discussion_r475983912 --- .../github/jsonldjava/utils/JsonUtils.java | 57 +++++++------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index 9e1ec875..7ee7b85d 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -338,50 +338,35 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) final String protocol = url.getProtocol(); // We can only use the Apache HTTPClient for HTTP/HTTPS, so use the // native java client for the others - CloseableHttpResponse response = null; - InputStream in = null; - try { - if (!protocol.equalsIgnoreCase("http") && !protocol.equalsIgnoreCase("https")) { - // Can't use the HTTP client for those! - // Fallback to Java's built-in JsonLdUrl handler. No need for - // Accept headers as it's likely to be file: or jar: - in = url.openStream(); - } else { - in = getJsonLdViaHttpUri(url, httpClient, response); - } - return fromInputStream(in); - } finally { - try { - if (in != null) { - in.close(); - } - } finally { - if (response != null) { - response.close(); - } - } + if (!protocol.equalsIgnoreCase("http") && !protocol.equalsIgnoreCase("https")) { + // Can't use the HTTP client for those! + // Fallback to Java's built-in JsonLdUrl handler. No need for + // Accept headers as it's likely to be file: or jar: + return fromInputStream(url.openStream()); + } else { + return fromInputStream(getJsonLdViaHttpUri(url, httpClient)); } } - private static InputStream getJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient, - CloseableHttpResponse response) throws IOException { + private static InputStream getJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient) + throws IOException { final HttpUriRequest request = new HttpGet(url.toExternalForm()); // We prefer application/ld+json, but fallback to application/json // or whatever is available request.addHeader("Accept", ACCEPT_HEADER); - response = httpClient.execute(request); - - final int status = response.getStatusLine().getStatusCode(); - if (status != 200 && status != 203) { - throw new IOException("Can't retrieve " + url + ", status code: " + status); - } - // follow alternate document location - // https://www.w3.org/TR/json-ld11/#alternate-document-location - URL alternateLink = alternateLink(url, response); - if (alternateLink != null) { - return getJsonLdViaHttpUri(alternateLink, httpClient, response); + try (CloseableHttpResponse response = httpClient.execute(request)) { + final int status = response.getStatusLine().getStatusCode(); + if (status != 200 && status != 203) { + throw new IOException("Can't retrieve " + url + ", status code: " + status); + } + // follow alternate document location + // https://www.w3.org/TR/json-ld11/#alternate-document-location + URL alternateLink = alternateLink(url, response); + if (alternateLink != null) { + return getJsonLdViaHttpUri(alternateLink, httpClient); + } + return response.getEntity().getContent(); } - return response.getEntity().getContent(); } private static URL alternateLink(URL url, CloseableHttpResponse response) From 818b118d23180385ad9ab667c8e1a022984e9fa5 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Thu, 27 Aug 2020 14:24:02 +0200 Subject: [PATCH 08/50] Avoid reading from closed stream --- .../main/java/com/github/jsonldjava/utils/JsonUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index 7ee7b85d..89e2d0cb 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -344,11 +344,11 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) // Accept headers as it's likely to be file: or jar: return fromInputStream(url.openStream()); } else { - return fromInputStream(getJsonLdViaHttpUri(url, httpClient)); + return fromJsonLdViaHttpUri(url, httpClient); } } - private static InputStream getJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient) + private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient) throws IOException { final HttpUriRequest request = new HttpGet(url.toExternalForm()); // We prefer application/ld+json, but fallback to application/json @@ -363,9 +363,9 @@ private static InputStream getJsonLdViaHttpUri(final URL url, final CloseableHtt // https://www.w3.org/TR/json-ld11/#alternate-document-location URL alternateLink = alternateLink(url, response); if (alternateLink != null) { - return getJsonLdViaHttpUri(alternateLink, httpClient); + return fromJsonLdViaHttpUri(alternateLink, httpClient); } - return response.getEntity().getContent(); + return fromInputStream(response.getEntity().getContent()); } } From 1d675d7e1e4ccde0545b336d98342439bc73da4e Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 28 Aug 2020 11:44:06 +0200 Subject: [PATCH 09/50] Abort if to many alternate links are followed. This avoids a possible endless loop. See https://github.com/jsonld-java/jsonld-java/pull/292#discussion_r475985782. --- .../com/github/jsonldjava/utils/JsonUtils.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index 89e2d0cb..5d4594e7 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -42,6 +42,8 @@ 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.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Functions used to make loading, parsing, and serializing JSON easy using @@ -69,6 +71,10 @@ public class JsonUtils { private static final JsonFactory JSON_FACTORY = new JsonFactory(JSON_MAPPER); private static volatile CloseableHttpClient DEFAULT_HTTP_CLIENT; + // Avoid possible endless loop when following alternate locations + private static final int MAX_LINKS_FOLLOW = 20; + private static final Logger log = LoggerFactory.getLogger(JsonUtils.class); + static { // Disable default Jackson behaviour to close @@ -344,11 +350,11 @@ public static Object fromURL(java.net.URL url, CloseableHttpClient httpClient) // Accept headers as it's likely to be file: or jar: return fromInputStream(url.openStream()); } else { - return fromJsonLdViaHttpUri(url, httpClient); + return fromJsonLdViaHttpUri(url, httpClient, 0); } } - private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient) + private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpClient httpClient, int linksFollowed) throws IOException { final HttpUriRequest request = new HttpGet(url.toExternalForm()); // We prefer application/ld+json, but fallback to application/json @@ -363,7 +369,13 @@ private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpCli // https://www.w3.org/TR/json-ld11/#alternate-document-location URL alternateLink = alternateLink(url, response); if (alternateLink != null) { - return fromJsonLdViaHttpUri(alternateLink, httpClient); + linksFollowed++; + if (linksFollowed > MAX_LINKS_FOLLOW) { + log.warn("Too many alternate links followed. This may indicate a cycle. Aborting."); + return null; + } + return linksFollowed > MAX_LINKS_FOLLOW ? null + : fromJsonLdViaHttpUri(alternateLink, httpClient, linksFollowed); } return fromInputStream(response.getEntity().getContent()); } From 1229f7353bd1f996aa1f0a6e3e6536f16cb4615b Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 28 Aug 2020 11:48:27 +0200 Subject: [PATCH 10/50] Fix missing trim(); simplify value parsing See https://github.com/jsonld-java/jsonld-java/pull/292#discussion_r475986626 and https://github.com/jsonld-java/jsonld-java/pull/292#discussion_r475987519. --- .../main/java/com/github/jsonldjava/utils/JsonUtils.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index 5d4594e7..78aebb81 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -391,13 +391,14 @@ private static URL alternateLink(URL url, CloseableHttpResponse response) boolean relAlternate = false; boolean jsonld = false; for (String value : header.getValue().split(";")) { - if (value.trim().startsWith("<")) { - alternateLink = value.replaceAll("<(.*)>", "$1"); + value=value.trim(); + if (value.startsWith("<") && value.endsWith(">")) { + alternateLink = value.substring(1, value.length() - 1); } - if (value.trim().startsWith("type=\"application/ld+json\"")) { + if (value.startsWith("type=\"application/ld+json\"")) { jsonld = true; } - if (value.trim().startsWith("rel=\"alternate\"")) { + if (value.startsWith("rel=\"alternate\"")) { relAlternate = true; } } From faddb48a65b53e7541359ab0a1a6840e125c4239 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 28 Aug 2020 13:49:34 +0200 Subject: [PATCH 11/50] Fix testing if object not null It should be checked if an Entity has a contentType, not if an Entity has content. See https://github.com/jsonld-java/jsonld-java/pull/292#discussion_r475989013 and https://github.com/jsonld-java/jsonld-java/pull/292#discussion_r475989860. --- core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index 78aebb81..5fcecb24 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -383,7 +383,7 @@ private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpCli private static URL alternateLink(URL url, CloseableHttpResponse response) throws MalformedURLException, IOException { - if (response.getEntity().getContentLength() > 0 + if (response.getEntity().getContentType() != null && !response.getEntity().getContentType().getValue().equals("application/ld+json")) { for (Header header : response.getAllHeaders()) { if (header.getName().equalsIgnoreCase("link")) { From 9100b1355770734b264edf727d9cb77c1d64dd61 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Tue, 8 Sep 2020 16:21:50 +0200 Subject: [PATCH 12/50] Throw IOException instead of returning null - remove superfluous check (was always false) - remove superfluous IOException - remove logger as it is no more needed See https://github.com/jsonld-java/jsonld-java/pull/292#commitcomment-42055866. --- .../java/com/github/jsonldjava/utils/JsonUtils.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index 5fcecb24..f66cd5fd 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -73,8 +73,6 @@ public class JsonUtils { private static volatile CloseableHttpClient DEFAULT_HTTP_CLIENT; // Avoid possible endless loop when following alternate locations private static final int MAX_LINKS_FOLLOW = 20; - private static final Logger log = LoggerFactory.getLogger(JsonUtils.class); - static { // Disable default Jackson behaviour to close @@ -371,18 +369,16 @@ private static Object fromJsonLdViaHttpUri(final URL url, final CloseableHttpCli if (alternateLink != null) { linksFollowed++; if (linksFollowed > MAX_LINKS_FOLLOW) { - log.warn("Too many alternate links followed. This may indicate a cycle. Aborting."); - return null; + throw new IOException("Too many alternate links followed. This may indicate a cycle. Aborting."); } - return linksFollowed > MAX_LINKS_FOLLOW ? null - : fromJsonLdViaHttpUri(alternateLink, httpClient, linksFollowed); + return fromJsonLdViaHttpUri(alternateLink, httpClient, linksFollowed); } return fromInputStream(response.getEntity().getContent()); } } private static URL alternateLink(URL url, CloseableHttpResponse response) - throws MalformedURLException, IOException { + throws MalformedURLException { if (response.getEntity().getContentType() != null && !response.getEntity().getContentType().getValue().equals("application/ld+json")) { for (Header header : response.getAllHeaders()) { From d5e27615b27efb2f69c5d41b18df8523a503a514 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Tue, 8 Sep 2020 16:55:33 +0200 Subject: [PATCH 13/50] Close InputStream within finally block See https://github.com/jsonld-java/jsonld-java/pull/292#commitcomment-42055925. --- core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java index f66cd5fd..c24c8467 100644 --- a/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java +++ b/core/src/main/java/com/github/jsonldjava/utils/JsonUtils.java @@ -116,6 +116,10 @@ public static Object fromInputStream(InputStream input) throws IOException { } } return fromInputStream(bOMInputStream, charset); + } finally { + if (input != null) { + input.close(); + } } } From 13569221793d6149a9336806a270a2b84084a853 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 9 Sep 2020 15:44:02 +1000 Subject: [PATCH 14/50] Bump dependencies Signed-off-by: Peter Ansell --- pom.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index a1bd056b..286db81c 100755 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,11 @@ UTF-8 UTF-8 - 4.5.10 - 4.4.12 - 2.10.1 - 4.12 - 1.7.29 + 4.5.12 + 4.4.13 + 2.11.2 + 4.13 + 1.7.30 0.11.0 @@ -192,7 +192,7 @@ commons-codec commons-codec - 1.13 + 1.15 org.mockito @@ -202,14 +202,14 @@ commons-io commons-io - 2.6 + 2.7 com.google.guava guava - 28.1-jre + 29.0-jre @@ -267,7 +267,7 @@ org.codehaus.mojo extra-enforcer-rules - 1.2 + 1.3 From 71006f5ca58554ea2d1d4ccf4f589418fa4f021b Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 9 Sep 2020 15:48:46 +1000 Subject: [PATCH 15/50] Release 0.13.1 Signed-off-by: Peter Ansell --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 1461c1e1..eda28511 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.1-SNAPSHOT + 0.13.1 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 286db81c..566a566e 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.1-SNAPSHOT + 0.13.1 JSONLD Java :: Parent Json-LD Java Parent POM pom From 9d000fe0d2b468521596742a694d351dd81c5628 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Wed, 9 Sep 2020 15:53:37 +1000 Subject: [PATCH 16/50] Bump to next development version Signed-off-by: Peter Ansell --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index eda28511..bf42b50c 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.1 + 0.13.2-SNAPSHOT 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 566a566e..da267853 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.1 + 0.13.2-SNAPSHOT JSONLD Java :: Parent Json-LD Java Parent POM pom From bed5196bb66d5a6f500ff50885ce5a0fe8f59da7 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 10 Sep 2020 06:16:03 +1000 Subject: [PATCH 17/50] issue #293 : Add com.google.thirdparty to shading Signed-off-by: Peter Ansell --- core/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/pom.xml b/core/pom.xml index bf42b50c..7317d6dc 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -82,6 +82,10 @@ com.google.common com.github.jsonldjava.shaded.com.google.common + + com.google.thirdparty + com.github.jsonldjava.shaded.com.google.thirdparty + From 47a595a8754e7e36e6d15fcdcab639b12868d221 Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Mon, 14 Sep 2020 19:58:11 +0200 Subject: [PATCH 18/50] Returned context IRI after compaction --- .../jsonldjava/core/JsonLdProcessor.java | 5 +++++ .../core/ContextCompactionTest.java | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java index 00fd3e16..58c01a18 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java @@ -2,9 +2,11 @@ import static com.github.jsonldjava.utils.Obj.newMap; +import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -51,6 +53,9 @@ public static Map compact(Object input, Object context, JsonLdOp if (context instanceof Map && ((Map) context).containsKey(JsonLdConsts.CONTEXT)) { context = ((Map) context).get(JsonLdConsts.CONTEXT); + if(context instanceof String) { + context = new LinkedList<>(Arrays.asList((String) context)); + } } Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context); diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java index 252621e1..b0ddb6ba 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java @@ -1,15 +1,17 @@ package com.github.jsonldjava.core; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; - import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; +import com.github.jsonldjava.utils.JsonUtils; import org.junit.Test; + public class ContextCompactionTest { // @Ignore("Disable until schema.org is fixed") @@ -49,4 +51,22 @@ public void testCompaction() throws Exception { compacted.get("@context") instanceof List); } + @Test + public void testCompactionUriSingleContext() throws Exception { + final String jsonString = "[{\"@type\": [\"http://schema.org/Person\"] } ]"; + final String ctxStr = "{\"@context\": \"http://schema.org/\"}"; + + final Object json = JsonUtils.fromString(jsonString); + final Object ctx = JsonUtils.fromString(ctxStr); + + final JsonLdOptions options = new JsonLdOptions(); + + final Map compacted = JsonLdProcessor.compact(json, ctx, options); + + // System.out.println("\n\nAfter compact:"); + // System.out.println(JsonUtils.toPrettyString(compacted)); + + assertEquals("Wrong compaction context", "http://schema.org/", compacted.get("@context")); + } + } From b784f3f48e4d3a05055e72ddaa696098e72b2f1e Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Tue, 15 Sep 2020 09:01:13 +0200 Subject: [PATCH 19/50] Returned correct @context during framing --- .../jsonldjava/core/JsonLdProcessor.java | 48 +++++++----- .../core/ContextCompactionTest.java | 4 +- .../jsonldjava/core/ContextFramingTest.java | 77 +++++++++++++++++++ 3 files changed, 109 insertions(+), 20 deletions(-) create mode 100644 core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java index 58c01a18..cd4e366b 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java @@ -53,9 +53,6 @@ public static Map compact(Object input, Object context, JsonLdOp if (context instanceof Map && ((Map) context).containsKey(JsonLdConsts.CONTEXT)) { context = ((Map) context).get(JsonLdConsts.CONTEXT); - if(context instanceof String) { - context = new LinkedList<>(Arrays.asList((String) context)); - } } Context activeCtx = new Context(opts); activeCtx = activeCtx.parse(context); @@ -75,19 +72,12 @@ public static Map compact(Object input, Object context, JsonLdOp compacted = tmp; } } - if (compacted != null && context != null) { - // TODO: figure out if we can make "@context" appear at the start of - // the keySet - if ((context instanceof Map && !((Map) context).isEmpty()) - || (context instanceof List && !((List) context).isEmpty())) { - - if (context instanceof List && ((List) context).size() == 1 - && opts.getCompactArrays()) { - ((Map) compacted).put(JsonLdConsts.CONTEXT, - ((List) context).get(0)); - } else { - ((Map) compacted).put(JsonLdConsts.CONTEXT, context); - } + if (compacted != null) { + final Object returnedContext = returnedContext(context, opts); + if(returnedContext != null) { + // TODO: figure out if we can make "@context" appear at the start of + // the keySet + ((Map) compacted).put(JsonLdConsts.CONTEXT, returnedContext); } } @@ -324,14 +314,18 @@ public static Map frame(Object input, Object frame, JsonLdOption // to a new empty // context, otherwise. final JsonLdApi api = new JsonLdApi(expandedInput, opts); - final Context activeCtx = api.context - .parse(((Map) frame).get(JsonLdConsts.CONTEXT)); + final Object context = ((Map) frame).get(JsonLdConsts.CONTEXT); + final Context activeCtx = api.context.parse(context); final List framed = api.frame(expandedInput, expandedFrame); if (opts.getPruneBlankNodeIdentifiers()) { JsonLdUtils.pruneBlankNodes(framed); } Object compacted = api.compact(activeCtx, null, framed, opts.getCompactArrays()); - final Map rval = activeCtx.serialize(); + final Map rval = newMap(); + final Object returnedContext = returnedContext(context, opts); + if(returnedContext != null) { + rval.put(JsonLdConsts.CONTEXT, context); + } final boolean addGraph = ((!(compacted instanceof List)) && !opts.getOmitGraph()); if (addGraph && !(compacted instanceof List)) { final List tmp = new ArrayList(); @@ -348,6 +342,22 @@ public static Map frame(Object input, Object frame, JsonLdOption return rval; } + private static Object returnedContext(Object context, JsonLdOptions opts) { + if (context != null && + ((context instanceof Map && !((Map) context).isEmpty()) + || (context instanceof List && !((List) context).isEmpty()) + || (context instanceof String && !((String) context).isEmpty()))) { + + if (context instanceof List && ((List) context).size() == 1 + && opts.getCompactArrays()) { + return ((List) context).get(0); + } + return context; + } else { + return null; + } + } + /** * A registry for RDF Parsers (in this case, JSONLDSerializers) used by * fromRDF if no specific serializer is specified and options.format is set. diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java index b0ddb6ba..e56dcedb 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java @@ -52,7 +52,7 @@ public void testCompaction() throws Exception { } @Test - public void testCompactionUriSingleContext() throws Exception { + public void testCompactionSingleRemoteContext() throws Exception { final String jsonString = "[{\"@type\": [\"http://schema.org/Person\"] } ]"; final String ctxStr = "{\"@context\": \"http://schema.org/\"}"; @@ -67,6 +67,8 @@ public void testCompactionUriSingleContext() throws Exception { // System.out.println(JsonUtils.toPrettyString(compacted)); assertEquals("Wrong compaction context", "http://schema.org/", compacted.get("@context")); + assertEquals("Wrong framing type", "Person", compacted.get("type")); + assertEquals("Wrong number of Json entries",2, compacted.size()); } } diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java new file mode 100644 index 00000000..e24b9235 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java @@ -0,0 +1,77 @@ +package com.github.jsonldjava.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.Test; + +public class ContextFramingTest { + + // @Ignore("Disable until schema.org is fixed") + @Test + public void testFraming() throws Exception { + + final Map contextAbbrevs = new HashMap(); + contextAbbrevs.put("so", "http://schema.org/"); + + final Map json = new HashMap(); + json.put("@context", contextAbbrevs); + json.put("@id", "http://example.org/my_work"); + + final List types = new LinkedList(); + types.add("so:CreativeWork"); + + json.put("@type", types); + json.put("so:name", "My Work"); + json.put("so:url", "http://example.org/my_work"); + + final JsonLdOptions options = new JsonLdOptions(); + options.setBase("http://schema.org/"); + options.setCompactArrays(true); + options.setOmitGraph(true); + + // System.out.println("Before compact"); + // System.out.println(JsonUtils.toPrettyString(json)); + + final String frameStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; + final Object frame = JsonUtils.fromString(frameStr); + + final Map compacted = JsonLdProcessor.frame(json, frame, options); + + // System.out.println("\n\nAfter compact:"); + // System.out.println(JsonUtils.toPrettyString(compacted)); + + assertTrue("Framing removed the context", compacted.containsKey("@context")); + assertFalse("Framing of context should be a string, not a list", + compacted.get("@context") instanceof List); + } + + @Test + public void testFramingRemoteContext() throws Exception { + final String jsonString = "{\"@id\": \"http://schema.org/myid\", \"@type\": [\"http://schema.org/Person\"]}"; + final String frameStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; + + final Object json = JsonUtils.fromString(jsonString); + final Object frame = JsonUtils.fromString(frameStr); + + final JsonLdOptions options = new JsonLdOptions(); + options.setOmitGraph(true); + + final Map compacted = JsonLdProcessor.frame(json, frame, options); + + // System.out.println("\n\nAfter compact:"); + // System.out.println(JsonUtils.toPrettyString(compacted)); + + assertEquals("Wrong framing context", "http://schema.org/", compacted.get("@context")); + assertEquals("Wrong framing id", "schema:myid", compacted.get("id")); + assertEquals("Wrong framing type", "Person", compacted.get("type")); + assertEquals("Wrong number of Json entries",3, compacted.size()); + } + +} From e953c7cd7e1c254dda952e116545b240afe6a28d Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Tue, 15 Sep 2020 13:55:30 +0200 Subject: [PATCH 20/50] Minor documentation and variable naming changes --- .../jsonldjava/core/JsonLdProcessor.java | 6 ++++ .../jsonldjava/core/ContextFramingTest.java | 32 +++++++++---------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java index cd4e366b..c98106dc 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java @@ -342,6 +342,12 @@ public static Map frame(Object input, Object frame, JsonLdOption return rval; } + /** + * Builds the context to be returned in framing and compaction algorithms. + * In cases where the context is empty or from an unexpected type, it returns null. + * When JsonLdOptions compactArrays is set to true and the context contains a List with a single element, + * the element is returned instead of the list + */ private static Object returnedContext(Object context, JsonLdOptions opts) { if (context != null && ((context instanceof Map && !((Map) context).isEmpty()) diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java index e24b9235..a5e2a59f 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java @@ -17,14 +17,14 @@ public class ContextFramingTest { @Test public void testFraming() throws Exception { - final Map contextAbbrevs = new HashMap(); + final Map contextAbbrevs = new HashMap<>(); contextAbbrevs.put("so", "http://schema.org/"); - final Map json = new HashMap(); + final Map json = new HashMap<>(); json.put("@context", contextAbbrevs); json.put("@id", "http://example.org/my_work"); - final List types = new LinkedList(); + final List types = new LinkedList<>(); types.add("so:CreativeWork"); json.put("@type", types); @@ -36,20 +36,20 @@ public void testFraming() throws Exception { options.setCompactArrays(true); options.setOmitGraph(true); - // System.out.println("Before compact"); + // System.out.println("Before framing"); // System.out.println(JsonUtils.toPrettyString(json)); final String frameStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; final Object frame = JsonUtils.fromString(frameStr); - final Map compacted = JsonLdProcessor.frame(json, frame, options); + final Map framed = JsonLdProcessor.frame(json, frame, options); - // System.out.println("\n\nAfter compact:"); - // System.out.println(JsonUtils.toPrettyString(compacted)); + // System.out.println("\n\nAfter framing:"); + // System.out.println(JsonUtils.toPrettyString(framed)); - assertTrue("Framing removed the context", compacted.containsKey("@context")); + assertTrue("Framing removed the context", framed.containsKey("@context")); assertFalse("Framing of context should be a string, not a list", - compacted.get("@context") instanceof List); + framed.get("@context") instanceof List); } @Test @@ -63,15 +63,15 @@ public void testFramingRemoteContext() throws Exception { final JsonLdOptions options = new JsonLdOptions(); options.setOmitGraph(true); - final Map compacted = JsonLdProcessor.frame(json, frame, options); + final Map framed = JsonLdProcessor.frame(json, frame, options); - // System.out.println("\n\nAfter compact:"); - // System.out.println(JsonUtils.toPrettyString(compacted)); + // System.out.println("\n\nAfter framing:"); + // System.out.println(JsonUtils.toPrettyString(framed)); - assertEquals("Wrong framing context", "http://schema.org/", compacted.get("@context")); - assertEquals("Wrong framing id", "schema:myid", compacted.get("id")); - assertEquals("Wrong framing type", "Person", compacted.get("type")); - assertEquals("Wrong number of Json entries",3, compacted.size()); + assertEquals("Wrong framing context", "http://schema.org/", framed.get("@context")); + assertEquals("Wrong framing id", "schema:myid", framed.get("id")); + assertEquals("Wrong framing type", "Person", framed.get("type")); + assertEquals("Wrong number of Json entries",3, framed.size()); } } From 99f8ae08b7f0b57043c9c32422f3b019760f7b39 Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Tue, 15 Sep 2020 14:38:27 +0200 Subject: [PATCH 21/50] Fixed flattening returned @context --- .../com/github/jsonldjava/core/Context.java | 57 +------------- .../jsonldjava/core/JsonLdProcessor.java | 8 +- .../core/ContextCompactionTest.java | 4 +- .../core/ContextFlatteningTest.java | 78 +++++++++++++++++++ .../jsonldjava/core/ContextFramingTest.java | 6 +- 5 files changed, 90 insertions(+), 63 deletions(-) create mode 100644 core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index 8c149b08..84f5a2c8 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -304,9 +304,7 @@ public Context parse(Object localContext) throws JsonLdError { * * http://json-ld.org/spec/latest/json-ld-api/#create-term-definition * - * @param result * @param context - * @param key * @param defined * @throws JsonLdError */ @@ -572,7 +570,7 @@ else if (relative) { * the IRI to compact. * @param value * the value to check or null. - * @param relativeTo + * @param relativeToVocab * options for how to compact IRIs: vocab: true to split * after @vocab, false not to. * @param reverse @@ -1146,57 +1144,4 @@ else if (this.get(JsonLdConsts.LANGUAGE) != null) { } return rval; } - - public Map serialize() { - final Map ctx = newMap(); - if (this.get(JsonLdConsts.BASE) != null - && !this.get(JsonLdConsts.BASE).equals(options.getBase())) { - ctx.put(JsonLdConsts.BASE, this.get(JsonLdConsts.BASE)); - } - if (this.get(JsonLdConsts.LANGUAGE) != null) { - ctx.put(JsonLdConsts.LANGUAGE, this.get(JsonLdConsts.LANGUAGE)); - } - if (this.get(JsonLdConsts.VOCAB) != null) { - ctx.put(JsonLdConsts.VOCAB, this.get(JsonLdConsts.VOCAB)); - } - for (final String term : termDefinitions.keySet()) { - final Map definition = (Map) termDefinitions.get(term); - if (definition.get(JsonLdConsts.LANGUAGE) == null - && definition.get(JsonLdConsts.CONTAINER) == null - && definition.get(JsonLdConsts.TYPE) == null - && (definition.get(JsonLdConsts.REVERSE) == null - || Boolean.FALSE.equals(definition.get(JsonLdConsts.REVERSE)))) { - final String cid = this.compactIri((String) definition.get(JsonLdConsts.ID)); - ctx.put(term, term.equals(cid) ? definition.get(JsonLdConsts.ID) : cid); - } else { - final Map defn = newMap(); - final String cid = this.compactIri((String) definition.get(JsonLdConsts.ID)); - final Boolean reverseProperty = Boolean.TRUE - .equals(definition.get(JsonLdConsts.REVERSE)); - if (!(term.equals(cid) && !reverseProperty)) { - defn.put(reverseProperty ? JsonLdConsts.REVERSE : JsonLdConsts.ID, cid); - } - final String typeMapping = (String) definition.get(JsonLdConsts.TYPE); - if (typeMapping != null) { - defn.put(JsonLdConsts.TYPE, JsonLdUtils.isKeyword(typeMapping) ? typeMapping - : compactIri(typeMapping, true)); - } - if (definition.get(JsonLdConsts.CONTAINER) != null) { - defn.put(JsonLdConsts.CONTAINER, definition.get(JsonLdConsts.CONTAINER)); - } - final Object lang = definition.get(JsonLdConsts.LANGUAGE); - if (definition.get(JsonLdConsts.LANGUAGE) != null) { - defn.put(JsonLdConsts.LANGUAGE, Boolean.FALSE.equals(lang) ? null : lang); - } - ctx.put(term, defn); - } - } - - final Map rval = newMap(); - if (!(ctx == null || ctx.isEmpty())) { - rval.put(JsonLdConsts.CONTEXT, ctx); - } - return rval; - } - } diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java index c98106dc..aa963199 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java @@ -245,7 +245,11 @@ public static Object flatten(Object input, Object context, JsonLdOptions opts) compacted = tmp; } final String alias = activeCtx.compactIri(JsonLdConsts.GRAPH); - final Map rval = activeCtx.serialize(); + final Map rval = newMap(); + final Object returnedContext = returnedContext(context, opts); + if(returnedContext != null) { + rval.put(JsonLdConsts.CONTEXT, returnedContext); + } rval.put(alias, compacted); return rval; } @@ -343,7 +347,7 @@ public static Map frame(Object input, Object frame, JsonLdOption } /** - * Builds the context to be returned in framing and compaction algorithms. + * Builds the context to be returned in framing, flattening and compaction algorithms. * In cases where the context is empty or from an unexpected type, it returns null. * When JsonLdOptions compactArrays is set to true and the context contains a List with a single element, * the element is returned instead of the list diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java index e56dcedb..120dbae0 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java @@ -66,8 +66,8 @@ public void testCompactionSingleRemoteContext() throws Exception { // System.out.println("\n\nAfter compact:"); // System.out.println(JsonUtils.toPrettyString(compacted)); - assertEquals("Wrong compaction context", "http://schema.org/", compacted.get("@context")); - assertEquals("Wrong framing type", "Person", compacted.get("type")); + assertEquals("Wrong returned context", "http://schema.org/", compacted.get("@context")); + assertEquals("Wrong type", "Person", compacted.get("type")); assertEquals("Wrong number of Json entries",2, compacted.size()); } diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java new file mode 100644 index 00000000..3dd49f90 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java @@ -0,0 +1,78 @@ +package com.github.jsonldjava.core; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.Test; + +public class ContextFlatteningTest { + + @Test + public void testFlatenning() throws Exception { + + final Map contextAbbrevs = new HashMap<>(); + contextAbbrevs.put("so", "http://schema.org/"); + + final Map json = new HashMap<>(); + json.put("@context", contextAbbrevs); + json.put("@id", "http://example.org/my_work"); + + final List types = new LinkedList<>(); + types.add("so:CreativeWork"); + + json.put("@type", types); + json.put("so:name", "My Work"); + json.put("so:url", "http://example.org/my_work"); + + final JsonLdOptions options = new JsonLdOptions(); + options.setBase("http://schema.org/"); + options.setCompactArrays(true); + options.setOmitGraph(true); + + // System.out.println("Before flattening"); + // System.out.println(JsonUtils.toPrettyString(json)); + + final String flattenStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; + final Object flatten = JsonUtils.fromString(flattenStr); + + final Map flattened = ((Map)JsonLdProcessor.flatten(json, flatten, options)); + + // System.out.println("\n\nAfter flattening:"); + // System.out.println(JsonUtils.toPrettyString(flattened)); + + assertTrue("Flattening removed the context", flattened.containsKey("@context")); + assertFalse("Flattening of context should be a string, not a list", + flattened.get("@context") instanceof List); + } + + @Test + public void testFlatteningRemoteContext() throws Exception { + final String jsonString = + "{\"@context\": {\"@vocab\": \"http://schema.org/\"}, \"knows\": [{\"name\": \"a\"}, {\"name\": \"b\"}] }"; + final String flattenStr = "{\"@context\": \"http://schema.org/\"}"; + + final Object json = JsonUtils.fromString(jsonString); + final Object flatten = JsonUtils.fromString(flattenStr); + + // System.out.println("Before flattening"); + // System.out.println(JsonUtils.toPrettyString(json)); + + final JsonLdOptions options = new JsonLdOptions(); + options.setOmitGraph(true); + + final Map flattened = ((Map)JsonLdProcessor.flatten(json, flatten, options)); + + // System.out.println("\n\nAfter flattened:"); + // System.out.println(JsonUtils.toPrettyString(flattened)); + + assertEquals("Wrong returned context", "http://schema.org/", flattened.get("@context")); + assertEquals("Wrong number of Json entries",2, flattened.size()); + } + +} diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java index a5e2a59f..3c8126a0 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java @@ -68,9 +68,9 @@ public void testFramingRemoteContext() throws Exception { // System.out.println("\n\nAfter framing:"); // System.out.println(JsonUtils.toPrettyString(framed)); - assertEquals("Wrong framing context", "http://schema.org/", framed.get("@context")); - assertEquals("Wrong framing id", "schema:myid", framed.get("id")); - assertEquals("Wrong framing type", "Person", framed.get("type")); + assertEquals("Wrong returned context", "http://schema.org/", framed.get("@context")); + assertEquals("Wrong id", "schema:myid", framed.get("id")); + assertEquals("Wrong type", "Person", framed.get("type")); assertEquals("Wrong number of Json entries",3, framed.size()); } From 7c0cbaf0893fdc5eef5e55fa0265196201eeba78 Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Tue, 22 Sep 2020 19:32:29 +0200 Subject: [PATCH 22/50] Addressed feedback --- .../com/github/jsonldjava/core/JsonLdProcessor.java | 4 +--- .../jsonldjava/core/ContextCompactionTest.java | 12 +----------- .../jsonldjava/core/ContextFlatteningTest.java | 12 ------------ .../github/jsonldjava/core/ContextFramingTest.java | 10 ---------- 4 files changed, 2 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java index aa963199..fedff3d2 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdProcessor.java @@ -2,11 +2,9 @@ import static com.github.jsonldjava.utils.Obj.newMap; -import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -328,7 +326,7 @@ public static Map frame(Object input, Object frame, JsonLdOption final Map rval = newMap(); final Object returnedContext = returnedContext(context, opts); if(returnedContext != null) { - rval.put(JsonLdConsts.CONTEXT, context); + rval.put(JsonLdConsts.CONTEXT, returnedContext); } final boolean addGraph = ((!(compacted instanceof List)) && !opts.getOmitGraph()); if (addGraph && !(compacted instanceof List)) { diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java index 120dbae0..31bfc3ef 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextCompactionTest.java @@ -14,9 +14,8 @@ public class ContextCompactionTest { - // @Ignore("Disable until schema.org is fixed") @Test - public void testCompaction() throws Exception { + public void testCompaction() { final Map contextAbbrevs = new HashMap(); contextAbbrevs.put("so", "http://schema.org/"); @@ -36,16 +35,10 @@ public void testCompaction() throws Exception { options.setBase("http://schema.org/"); options.setCompactArrays(true); - // System.out.println("Before compact"); - // System.out.println(JsonUtils.toPrettyString(json)); - final List newContexts = new LinkedList(); newContexts.add("http://schema.org/"); final Map compacted = JsonLdProcessor.compact(json, newContexts, options); - // System.out.println("\n\nAfter compact:"); - // System.out.println(JsonUtils.toPrettyString(compacted)); - assertTrue("Compaction removed the context", compacted.containsKey("@context")); assertFalse("Compaction of context should be a string, not a list", compacted.get("@context") instanceof List); @@ -63,9 +56,6 @@ public void testCompactionSingleRemoteContext() throws Exception { final Map compacted = JsonLdProcessor.compact(json, ctx, options); - // System.out.println("\n\nAfter compact:"); - // System.out.println(JsonUtils.toPrettyString(compacted)); - assertEquals("Wrong returned context", "http://schema.org/", compacted.get("@context")); assertEquals("Wrong type", "Person", compacted.get("type")); assertEquals("Wrong number of Json entries",2, compacted.size()); diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java index 3dd49f90..8e3a1710 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFlatteningTest.java @@ -35,17 +35,11 @@ public void testFlatenning() throws Exception { options.setCompactArrays(true); options.setOmitGraph(true); - // System.out.println("Before flattening"); - // System.out.println(JsonUtils.toPrettyString(json)); - final String flattenStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; final Object flatten = JsonUtils.fromString(flattenStr); final Map flattened = ((Map)JsonLdProcessor.flatten(json, flatten, options)); - // System.out.println("\n\nAfter flattening:"); - // System.out.println(JsonUtils.toPrettyString(flattened)); - assertTrue("Flattening removed the context", flattened.containsKey("@context")); assertFalse("Flattening of context should be a string, not a list", flattened.get("@context") instanceof List); @@ -60,17 +54,11 @@ public void testFlatteningRemoteContext() throws Exception { final Object json = JsonUtils.fromString(jsonString); final Object flatten = JsonUtils.fromString(flattenStr); - // System.out.println("Before flattening"); - // System.out.println(JsonUtils.toPrettyString(json)); - final JsonLdOptions options = new JsonLdOptions(); options.setOmitGraph(true); final Map flattened = ((Map)JsonLdProcessor.flatten(json, flatten, options)); - // System.out.println("\n\nAfter flattened:"); - // System.out.println(JsonUtils.toPrettyString(flattened)); - assertEquals("Wrong returned context", "http://schema.org/", flattened.get("@context")); assertEquals("Wrong number of Json entries",2, flattened.size()); } diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java index 3c8126a0..73116205 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextFramingTest.java @@ -13,7 +13,6 @@ public class ContextFramingTest { - // @Ignore("Disable until schema.org is fixed") @Test public void testFraming() throws Exception { @@ -36,17 +35,11 @@ public void testFraming() throws Exception { options.setCompactArrays(true); options.setOmitGraph(true); - // System.out.println("Before framing"); - // System.out.println(JsonUtils.toPrettyString(json)); - final String frameStr = "{\"@id\": \"http://schema.org/myid\", \"@context\": \"http://schema.org/\"}"; final Object frame = JsonUtils.fromString(frameStr); final Map framed = JsonLdProcessor.frame(json, frame, options); - // System.out.println("\n\nAfter framing:"); - // System.out.println(JsonUtils.toPrettyString(framed)); - assertTrue("Framing removed the context", framed.containsKey("@context")); assertFalse("Framing of context should be a string, not a list", framed.get("@context") instanceof List); @@ -65,9 +58,6 @@ public void testFramingRemoteContext() throws Exception { final Map framed = JsonLdProcessor.frame(json, frame, options); - // System.out.println("\n\nAfter framing:"); - // System.out.println(JsonUtils.toPrettyString(framed)); - assertEquals("Wrong returned context", "http://schema.org/", framed.get("@context")); assertEquals("Wrong id", "schema:myid", framed.get("id")); assertEquals("Wrong type", "Person", framed.get("type")); From 4894387d983dd0e8a68bc8de1e05542b5d0194f9 Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Wed, 23 Sep 2020 19:00:48 +0200 Subject: [PATCH 23/50] Added back Context.serialize() with @Deprecated annotation --- .../com/github/jsonldjava/core/Context.java | 54 +++++++++++++++++++ .../core/ContextSerializationTest.java | 24 +++++++++ .../resources/custom/contexttest-0005.jsonld | 12 +++++ 3 files changed, 90 insertions(+) create mode 100644 core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java create mode 100644 core/src/test/resources/custom/contexttest-0005.jsonld diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index 84f5a2c8..bff79d8c 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -1144,4 +1144,58 @@ else if (this.get(JsonLdConsts.LANGUAGE) != null) { } return rval; } + + @Deprecated + public Map serialize() { + final Map ctx = newMap(); + if (this.get(JsonLdConsts.BASE) != null + && !this.get(JsonLdConsts.BASE).equals(options.getBase())) { + ctx.put(JsonLdConsts.BASE, this.get(JsonLdConsts.BASE)); + } + if (this.get(JsonLdConsts.LANGUAGE) != null) { + ctx.put(JsonLdConsts.LANGUAGE, this.get(JsonLdConsts.LANGUAGE)); + } + if (this.get(JsonLdConsts.VOCAB) != null) { + ctx.put(JsonLdConsts.VOCAB, this.get(JsonLdConsts.VOCAB)); + } + for (final String term : termDefinitions.keySet()) { + final Map definition = (Map) termDefinitions.get(term); + if (definition.get(JsonLdConsts.LANGUAGE) == null + && definition.get(JsonLdConsts.CONTAINER) == null + && definition.get(JsonLdConsts.TYPE) == null + && (definition.get(JsonLdConsts.REVERSE) == null + || Boolean.FALSE.equals(definition.get(JsonLdConsts.REVERSE)))) { + final String cid = this.compactIri((String) definition.get(JsonLdConsts.ID)); + ctx.put(term, term.equals(cid) ? definition.get(JsonLdConsts.ID) : cid); + } else { + final Map defn = newMap(); + final String cid = this.compactIri((String) definition.get(JsonLdConsts.ID)); + final Boolean reverseProperty = Boolean.TRUE + .equals(definition.get(JsonLdConsts.REVERSE)); + if (!(term.equals(cid) && !reverseProperty)) { + defn.put(reverseProperty ? JsonLdConsts.REVERSE : JsonLdConsts.ID, cid); + } + final String typeMapping = (String) definition.get(JsonLdConsts.TYPE); + if (typeMapping != null) { + defn.put(JsonLdConsts.TYPE, JsonLdUtils.isKeyword(typeMapping) ? typeMapping + : compactIri(typeMapping, true)); + } + if (definition.get(JsonLdConsts.CONTAINER) != null) { + defn.put(JsonLdConsts.CONTAINER, definition.get(JsonLdConsts.CONTAINER)); + } + final Object lang = definition.get(JsonLdConsts.LANGUAGE); + if (definition.get(JsonLdConsts.LANGUAGE) != null) { + defn.put(JsonLdConsts.LANGUAGE, Boolean.FALSE.equals(lang) ? null : lang); + } + ctx.put(term, defn); + } + } + + final Map rval = newMap(); + if (!(ctx == null || ctx.isEmpty())) { + rval.put(JsonLdConsts.CONTEXT, ctx); + } + return rval; + } + } diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java new file mode 100644 index 00000000..7077f228 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextSerializationTest.java @@ -0,0 +1,24 @@ +package com.github.jsonldjava.core; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.Test; + +import java.io.IOException; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class ContextSerializationTest { + + @Test + // Added in order to have some coverage on the serialize method since is not used anywhere. + public void serializeTest() throws IOException { + final Map json = (Map)JsonUtils + .fromInputStream(getClass().getResourceAsStream("/custom/contexttest-0005.jsonld")); + + final Map contextValue = (Map)json.get(JsonLdConsts.CONTEXT); + final Map serializedContext = new Context().parse(contextValue).serialize(); + + assertEquals("Wrong serialized context", json, serializedContext); + } +} diff --git a/core/src/test/resources/custom/contexttest-0005.jsonld b/core/src/test/resources/custom/contexttest-0005.jsonld new file mode 100644 index 00000000..f4baa06e --- /dev/null +++ b/core/src/test/resources/custom/contexttest-0005.jsonld @@ -0,0 +1,12 @@ +{ + "@context": { + "@base": "http://ex.com/base/", + "@vocab": "http://ex.com/vocab/", + "xsd": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "integer": { + "@id": "http://example.com/vocab/integer", + "@type": "xsd:integer" + }, + "@language": "en" + } +} \ No newline at end of file From e10d6b09f687b0e45417a6c6c852cf10942d3850 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Sep 2020 06:45:26 +1000 Subject: [PATCH 24/50] Prepare for release Signed-off-by: Peter Ansell --- README.md | 19 ++++++++++++++++--- pom.xml | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2270d45c..d1f5a5cc 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ From Maven com.github.jsonld-java jsonld-java - 0.13.0 + 0.13.2 Code example @@ -323,11 +323,11 @@ Here is the basic outline for what your module's pom.xml should look like com.github.jsonld-java jsonld-java-parent - 0.13.0 + 0.13.2 4.0.0 jsonld-java-{your module} - 0.13.0-SNAPSHOT + 0.13.2-SNAPSHOT JSONLD Java :: {your module name} JSON-LD Java integration module for {RDF Library your module integrates} jar @@ -450,6 +450,19 @@ Alternatively, we can also host your repository in the jsonld-java organisation CHANGELOG ========= +### 2020-09-24 +* Release 0.13.2 +* Fix Guava dependency shading (Reported by @ggrasso) +* Fix @context issues when using a remote context (Patch by @umbreak) +* Deprecate Context.serialize (Patch by @umbreak) + +### 2020-09-09 +* Release 0.13.1 +* Fix java.net.URI resolution (Reported by @ebremer and @afs, Patch by @dr0i) +* Shade Guava failureaccess module (Patch by @peacekeeper) +* Don't minimize Guava class shading (Patch by @elahrvivaz) +* Follow link headers to @context files (Patch by @dr0i and @fsteeg) + ### 2019-11-28 * Release 0.13.0 * Bump Jackson versions to latest for security updates (Patch by @afs) diff --git a/pom.xml b/pom.xml index da267853..d38511c0 100755 --- a/pom.xml +++ b/pom.xml @@ -198,11 +198,12 @@ org.mockito mockito-core 2.28.2 + test commons-io commons-io - 2.7 + 2.8.0 From 69aee572c2b8c7e9bed6ab32869cc36ce17d89d7 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Sep 2020 06:50:25 +1000 Subject: [PATCH 25/50] Release 0.13.2 Signed-off-by: Peter Ansell --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 7317d6dc..ffbfb30a 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.2-SNAPSHOT + 0.13.2 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index d38511c0..6860f6d5 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.2-SNAPSHOT + 0.13.2 JSONLD Java :: Parent Json-LD Java Parent POM pom From 6c1bf5d3daf19595ba506ef6c00dd575351f61b3 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Thu, 24 Sep 2020 06:56:30 +1000 Subject: [PATCH 26/50] Bump to next development version Signed-off-by: Peter Ansell --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index ffbfb30a..b771cbee 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.2 + 0.13.3-SNAPSHOT 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 6860f6d5..5bddbf03 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.2 + 0.13.3-SNAPSHOT JSONLD Java :: Parent Json-LD Java Parent POM pom From 257738f850941f8abf81048b415edd01468e74d0 Mon Sep 17 00:00:00 2001 From: kishorkunal-raj Date: Fri, 6 Nov 2020 07:13:08 +0000 Subject: [PATCH 27/50] Adding ppc64le architecture support on travis-ci --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 29a226e2..df26cdc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,3 +6,6 @@ notifications: email: false after_success: - mvn clean test jacoco:report coveralls:report +arch: + - amd64 + - ppc64le From a9b22ee90e100606c238c513423ef6e3d9fc5956 Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Sat, 12 Dec 2020 14:53:41 +0100 Subject: [PATCH 28/50] Throw RECURSIVE_CONTEXT_INCLUSION only when cyclic dependency exists --- .../com/github/jsonldjava/core/Context.java | 13 ++-- .../jsonldjava/core/ContextRecursionTest.java | 75 +++++++++++++++++++ 2 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index bff79d8c..dafc43ce 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -143,6 +143,9 @@ && getTermDefinition(activeProperty).containsKey(JsonLdConsts.LANGUAGE) */ @SuppressWarnings("unchecked") public Context parse(Object localContext, List remoteContexts) throws JsonLdError { + if (remoteContexts == null) { + remoteContexts = new ArrayList(); + } return parse(localContext, remoteContexts, false); } @@ -163,11 +166,8 @@ public Context parse(Object localContext, List remoteContexts) throws Js * @throws JsonLdError * If there is an error parsing the contexts. */ - private Context parse(Object localContext, List remoteContexts, + private Context parse(Object localContext, final List remoteContexts, boolean parsingARemoteContext) throws JsonLdError { - if (remoteContexts == null) { - remoteContexts = new ArrayList(); - } // 1. Initialize result to the result of cloning active context. Context result = this.clone(); // TODO: clone? // 2) @@ -193,7 +193,8 @@ else if (context instanceof String) { if (remoteContexts.contains(uri)) { throw new JsonLdError(Error.RECURSIVE_CONTEXT_INCLUSION, uri); } - remoteContexts.add(uri); + List nextRemoteContexts = new ArrayList<>(remoteContexts); + nextRemoteContexts.add(uri); // 3.2.3: Dereference context final RemoteDocument rd = this.options.getDocumentLoader().loadDocument(uri); @@ -208,7 +209,7 @@ else if (context instanceof String) { .get(JsonLdConsts.CONTEXT); // 3.2.4 - result = result.parse(tempContext, remoteContexts, true); + result = result.parse(tempContext, nextRemoteContexts, true); // 3.2.5 continue; } else if (!(context instanceof Map)) { diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java new file mode 100644 index 00000000..4e92bd36 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java @@ -0,0 +1,75 @@ +package com.github.jsonldjava.core; + +import com.github.jsonldjava.utils.JsonUtils; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + + +public class ContextRecursionTest { + + @BeforeClass + public static void setup() { + System.setProperty(DocumentLoader.DISALLOW_REMOTE_CONTEXT_LOADING, "true"); + } + + @AfterClass + public static void tearDown() { + System.setProperty(DocumentLoader.DISALLOW_REMOTE_CONTEXT_LOADING, "false"); + } + + @Test + public void testAllowedRecursion() throws IOException { + + final String contextB = "{\"@context\": [\"http://localhost/d\", {\"b\": \"http://localhost/b\"} ] }"; + final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }"; + final String contextD = "{\"@context\": [\"http://localhost/e\", {\"d\": \"http://localhost/d\"} ] }"; + final String contextE = "{\"@context\": {\"e\": \"http://localhost/e\"} }"; + + final DocumentLoader dl = new DocumentLoader(); + dl.addInjectedDoc("http://localhost/b", contextB); + dl.addInjectedDoc("http://localhost/c", contextC); + dl.addInjectedDoc("http://localhost/d", contextD); + dl.addInjectedDoc("http://localhost/e", contextE); + final JsonLdOptions options = new JsonLdOptions(); + options.setDocumentLoader(dl); + + final String jsonString = "{\"@context\": [\"http://localhost/d\", \"http://localhost/b\", \"http://localhost/c\", {\"a\": \"http://localhost/a\"} ], \"a\": \"A\", \"b\": \"B\", \"c\": \"C\", \"d\": \"D\"}"; + final Object json = JsonUtils.fromString(jsonString); + final Object expanded = JsonLdProcessor.expand(json, options); + assertEquals( + "[{http://localhost/a=[{@value=A}], http://localhost/b=[{@value=B}], http://localhost/c=[{@value=C}], http://localhost/d=[{@value=D}]}]", + expanded.toString()); + } + + @Test + public void testCyclicRecursion() throws IOException { + + final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }"; + final String contextD = "{\"@context\": [\"http://localhost/e\", {\"d\": \"http://localhost/d\"} ] }"; + final String contextE = "{\"@context\": [\"http://localhost/c\", {\"e\": \"http://localhost/e\"} ] }"; + + final DocumentLoader dl = new DocumentLoader(); + dl.addInjectedDoc("http://localhost/c", contextC); + dl.addInjectedDoc("http://localhost/d", contextD); + dl.addInjectedDoc("http://localhost/e", contextE); + final JsonLdOptions options = new JsonLdOptions(); + options.setDocumentLoader(dl); + + final String jsonString = "{\"@context\": [\"http://localhost/c\", {\"a\": \"http://localhost/a\"} ]}"; + final Object json = JsonUtils.fromString(jsonString); + try { + JsonLdProcessor.expand(json, options); + fail("it should throw"); + } catch(JsonLdError err) { + assertEquals(err.getType(), JsonLdError.Error.RECURSIVE_CONTEXT_INCLUSION); + assertEquals(err.getMessage(), "recursive context inclusion: http://localhost/c"); + } + } + +} From 45c29428328abb78b7468d8d339b50a9044c9fcd Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Tue, 26 Jan 2021 14:26:20 +0100 Subject: [PATCH 29/50] Ignore @base if remote context is not relative If the remote context is not relative and seems to be a http URI don't prefix the base IRI to it. The remote context is not validated nor tested if it's resolvable. It's just tested if it's not a relative URI - which is totally possible and would, in conjunction with a base IRI, made into valid remote context. See #304. --- .../java/com/github/jsonldjava/core/Context.java | 6 +++++- .../github/jsonldjava/core/DocumentLoaderTest.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index bff79d8c..a5277259 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -187,7 +187,11 @@ private Context parse(Object localContext, List remoteContexts, } // 3.2) else if (context instanceof String) { - String uri = (String) result.get(JsonLdConsts.BASE); + String uri = null; + // @base is ignored when processing remote contexts, https://github.com/jsonld-java/jsonld-java/issues/304 + if (!context.toString().matches("^[hH][tT][tT][pP][sS]?://.*")) { + uri = (String) result.get(JsonLdConsts.BASE); + } uri = JsonLdUrl.resolve(uri, (String) context); // 3.2.2 if (remoteContexts.contains(uri)) { diff --git a/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java b/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java index c16d40b5..57b8f5ce 100644 --- a/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/DocumentLoaderTest.java @@ -381,11 +381,19 @@ public void testDisallowRemoteContexts() throws Exception { } @Test - public void injectContext() throws Exception { + public void testInjectContext() throws Exception { + injectContext(new JsonLdOptions()); + } + + @Test + public void testIssue304_remoteContextAndBaseIri() throws Exception { + injectContext(new JsonLdOptions("testing:baseIri")); + } + + private void injectContext(final JsonLdOptions options) throws Exception { final Object jsonObject = JsonUtils.fromString( "{ \"@context\":\"http://nonexisting.example.com/thing\", \"pony\":5 }"); - final JsonLdOptions options = new JsonLdOptions(); // Verify fails to find context by default try { From b6edd7b3d8b842aeeb6ad2a19fcf6a6c7e0a5d9b Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Tue, 26 Jan 2021 17:53:51 +0100 Subject: [PATCH 30/50] Fix order of assertEquals parameters - rename one test to point to the issue Complements a9b22ee90e100606c238c513423ef6e3d9fc5956. --- .../com/github/jsonldjava/core/ContextRecursionTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java b/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java index 4e92bd36..d6610121 100644 --- a/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/ContextRecursionTest.java @@ -24,7 +24,7 @@ public static void tearDown() { } @Test - public void testAllowedRecursion() throws IOException { + public void testIssue302_allowedRecursion() throws IOException { final String contextB = "{\"@context\": [\"http://localhost/d\", {\"b\": \"http://localhost/b\"} ] }"; final String contextC = "{\"@context\": [\"http://localhost/d\", {\"c\": \"http://localhost/c\"} ] }"; @@ -67,8 +67,8 @@ public void testCyclicRecursion() throws IOException { JsonLdProcessor.expand(json, options); fail("it should throw"); } catch(JsonLdError err) { - assertEquals(err.getType(), JsonLdError.Error.RECURSIVE_CONTEXT_INCLUSION); - assertEquals(err.getMessage(), "recursive context inclusion: http://localhost/c"); + assertEquals(JsonLdError.Error.RECURSIVE_CONTEXT_INCLUSION, err.getType()); + assertEquals("recursive context inclusion: http://localhost/c", err.getMessage()); } } From 9af0572b88a85fcfe5c8f35679d80d640c93e1eb Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Thu, 28 Jan 2021 16:07:09 +0100 Subject: [PATCH 31/50] Use precompiled pattern As proposed by @umbreak in #305. Complements 45c29428328abb78b7468d8d339b50a9044c9fcd. --- core/src/main/java/com/github/jsonldjava/core/Context.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index a5277259..069aaf2f 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -9,6 +9,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.regex.Pattern; import com.github.jsonldjava.core.JsonLdError.Error; import com.github.jsonldjava.utils.JsonLdUrl; @@ -25,6 +26,7 @@ public class Context extends LinkedHashMap { private static final long serialVersionUID = 2894534897574805571L; + private static final Pattern URL_PATTERN = Pattern.compile("^https?://.*$", Pattern.CASE_INSENSITIVE); private JsonLdOptions options; private Map termDefinitions; public Map inverse = null; @@ -189,7 +191,7 @@ private Context parse(Object localContext, List remoteContexts, else if (context instanceof String) { String uri = null; // @base is ignored when processing remote contexts, https://github.com/jsonld-java/jsonld-java/issues/304 - if (!context.toString().matches("^[hH][tT][tT][pP][sS]?://.*")) { + if (!URL_PATTERN.matcher(context.toString()).matches()) { uri = (String) result.get(JsonLdConsts.BASE); } uri = JsonLdUrl.resolve(uri, (String) context); From 0ebe491206fc4165a21a551288f8bd8857118e0e Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Thu, 28 Jan 2021 16:11:48 +0100 Subject: [PATCH 32/50] Remove superflous @SuppressWarnings --- core/src/main/java/com/github/jsonldjava/core/Context.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/java/com/github/jsonldjava/core/Context.java b/core/src/main/java/com/github/jsonldjava/core/Context.java index 069aaf2f..0fad5e63 100644 --- a/core/src/main/java/com/github/jsonldjava/core/Context.java +++ b/core/src/main/java/com/github/jsonldjava/core/Context.java @@ -143,7 +143,6 @@ && getTermDefinition(activeProperty).containsKey(JsonLdConsts.LANGUAGE) * @throws JsonLdError * If there is an error parsing the contexts. */ - @SuppressWarnings("unchecked") public Context parse(Object localContext, List remoteContexts) throws JsonLdError { return parse(localContext, remoteContexts, false); } From 95cbd49e901760e608247292417973cdb7060d76 Mon Sep 17 00:00:00 2001 From: Didac Montero Date: Mon, 1 Feb 2021 11:50:14 +0100 Subject: [PATCH 33/50] rdfToJson edge case when object = subject and predicate = rdf:type --- .../com/github/jsonldjava/core/JsonLdApi.java | 3 +- .../jsonldjava/core/JsonLdToRdfTest.java | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java diff --git a/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java b/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java index 74cea926..2195d09a 100644 --- a/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java +++ b/core/src/main/java/com/github/jsonldjava/core/JsonLdApi.java @@ -2001,7 +2001,8 @@ public List fromRDF(final RDFDataset dataset, boolean noDuplicatesInData // 3.5.4) if (RDF_TYPE.equals(predicate) && (object.isIRI() || object.isBlankNode()) - && !opts.getUseRdfType() && !nodes.containsKey(object.getValue())) { + && !opts.getUseRdfType() && + (!nodes.containsKey(object.getValue()) || subject.equals(object.getValue()))) { JsonLdUtils.mergeValue(node, JsonLdConsts.TYPE, object.getValue()); continue; } diff --git a/core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java b/core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java new file mode 100644 index 00000000..7586c1c6 --- /dev/null +++ b/core/src/test/java/com/github/jsonldjava/core/JsonLdToRdfTest.java @@ -0,0 +1,31 @@ +package com.github.jsonldjava.core; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class JsonLdToRdfTest { + + @Test + public void testIssue301() throws JsonLdError { + final RDFDataset rdf = new RDFDataset(); + rdf.addTriple( + "http://www.w3.org/2002/07/owl#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", + "http://www.w3.org/2002/07/owl#Class"); + final JsonLdOptions opts = new JsonLdOptions(); + opts.setUseRdfType(Boolean.FALSE); + opts.setProcessingMode(JsonLdOptions.JSON_LD_1_0); + + final Object out = new JsonLdApi(opts).fromRDF(rdf, true); + assertEquals("[{@id=http://www.w3.org/2002/07/owl#Class, @type=[http://www.w3.org/2002/07/owl#Class]}]", + out.toString()); + + opts.setUseRdfType(Boolean.TRUE); + + final Object out2 = new JsonLdApi(opts).fromRDF(rdf, true); + assertEquals("[{@id=http://www.w3.org/2002/07/owl#Class, http://www.w3.org/1999/02/22-rdf-syntax-ns#type=[{@id=http://www.w3.org/2002/07/owl#Class}]}]", + out2.toString()); + } + +} From b2a8ac68ae85b5f304ce930d161e8d686780996c Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Sat, 6 Mar 2021 16:23:37 +0100 Subject: [PATCH 34/50] Prepare for release Signed-off-by: Pascal Christoph --- README.md | 11 ++++++++--- pom.xml | 14 +++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d1f5a5cc..c2b90600 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ From Maven com.github.jsonld-java jsonld-java - 0.13.2 + 0.13.3 Code example @@ -323,11 +323,11 @@ Here is the basic outline for what your module's pom.xml should look like com.github.jsonld-java jsonld-java-parent - 0.13.2 + 0.13.3 4.0.0 jsonld-java-{your module} - 0.13.2-SNAPSHOT + 0.13.3-SNAPSHOT JSONLD Java :: {your module name} JSON-LD Java integration module for {RDF Library your module integrates} jar @@ -449,6 +449,11 @@ Alternatively, we can also host your repository in the jsonld-java organisation CHANGELOG ========= +### 2021-03-06 +* Release 0.13.3 +* Fix @type when subject and object are the same (Reported by @barthanssens, Patch by @umbreak) +* Ignore @base if remote context is not relative (Reported by @whikloj, Patch by @dr0i) +* Fix throwing recursive context inclusion (Patch by @umbreak) ### 2020-09-24 * Release 0.13.2 diff --git a/pom.xml b/pom.xml index 5bddbf03..5f701d70 100755 --- a/pom.xml +++ b/pom.xml @@ -39,10 +39,10 @@ UTF-8 UTF-8 - 4.5.12 - 4.4.13 - 2.11.2 - 4.13 + 4.5.13 + 4.4.14 + 2.11.4 + 4.13.2 1.7.30 0.11.0 @@ -351,7 +351,7 @@ org.apache.maven.plugins maven-source-plugin - 3.2.0 + 3.2.1 attach-source @@ -401,7 +401,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.14.2 + 0.14.4 @@ -448,7 +448,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 prepare-agent From 2c54b02de3a8c8fb9717a8befa3318bc6e895bc6 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 5 Apr 2021 17:58:43 +0200 Subject: [PATCH 35/50] Release 0.13.3 Signed-off-by: Pascal Christoph --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index b771cbee..3e57a58c 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.3-SNAPSHOT + 0.13.3 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 5f701d70..db9fd7fa 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.3-SNAPSHOT + 0.13.3 JSONLD Java :: Parent Json-LD Java Parent POM pom From 5edb2463c3361e28a9a80d78689bc428887a1ec7 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Sun, 18 Apr 2021 15:43:39 +0200 Subject: [PATCH 36/50] Bump to next development version Signed-off-by: Pascal Christoph --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 3e57a58c..9a9e32cc 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.3 + 0.13.4-SNAPSHOT 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index db9fd7fa..a6c49e1f 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.3 + 0.13.4-SNAPSHOT JSONLD Java :: Parent Json-LD Java Parent POM pom From 8b970246b2702f234d2527dd756aec7279b373ba Mon Sep 17 00:00:00 2001 From: Chen Zhang <340355960@qq.com> Date: Wed, 18 Aug 2021 21:57:25 +0800 Subject: [PATCH 37/50] Improve Travis CI build Performance --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index df26cdc0..a311838b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,7 @@ after_success: arch: - amd64 - ppc64le + +cache: + directories: + - $HOME/.m2 From 2473693e3f64d17cbdcab6b36510f89d21689477 Mon Sep 17 00:00:00 2001 From: Peter Ansell Date: Sat, 11 Dec 2021 11:34:32 +1100 Subject: [PATCH 38/50] issue #322 : Switch test logging from log4j to logback Signed-off-by: Peter Ansell --- core/pom.xml | 4 ++-- core/src/test/resources/log4j.properties | 5 ----- pom.xml | 9 +++++---- 3 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 core/src/test/resources/log4j.properties diff --git a/core/pom.xml b/core/pom.xml index 9a9e32cc..880e341f 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -53,8 +53,8 @@ test - org.slf4j - slf4j-log4j12 + ch.qos.logback + logback-classic test diff --git a/core/src/test/resources/log4j.properties b/core/src/test/resources/log4j.properties deleted file mode 100644 index 6cebabb1..00000000 --- a/core/src/test/resources/log4j.properties +++ /dev/null @@ -1,5 +0,0 @@ -log4j.rootLogger=INFO, R - -log4j.appender.R=org.apache.log4j.ConsoleAppender -log4j.appender.R.layout=org.apache.log4j.PatternLayout -log4j.appender.R.layout.ConversionPattern=[%d] %-5p (%c:%L) %m%n diff --git a/pom.xml b/pom.xml index a6c49e1f..37d130c8 100755 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,8 @@ 4.4.14 2.11.4 4.13.2 - 1.7.30 + 1.7.32 + 1.2.7 0.11.0 @@ -96,9 +97,9 @@ runtime - org.slf4j - slf4j-log4j12 - ${slf4j.version} + ch.qos.logback + logback-classic + ${logback.version} test From 0c3bac9e61cb51e1784bfe11e15767429d33453c Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 13 Dec 2021 14:38:17 +0100 Subject: [PATCH 39/50] Prepare for release Signed-off-by: christoph@hbz-nrw.de --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c2b90600..647097f8 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ From Maven com.github.jsonld-java jsonld-java - 0.13.3 + 0.13.4 Code example @@ -323,11 +323,11 @@ Here is the basic outline for what your module's pom.xml should look like com.github.jsonld-java jsonld-java-parent - 0.13.3 + 0.13.4 4.0.0 jsonld-java-{your module} - 0.13.3-SNAPSHOT + 0.13.4-SNAPSHOT JSONLD Java :: {your module name} JSON-LD Java integration module for {RDF Library your module integrates} jar @@ -449,6 +449,11 @@ Alternatively, we can also host your repository in the jsonld-java organisation CHANGELOG ========= +### 2021-12-13 +* Release 0.13.4 +* Switch test logging from log4j to logback (Patch by @ansell) +* Improve Travis CI build Performance (Patch by @YunLemon) + ### 2021-03-06 * Release 0.13.3 * Fix @type when subject and object are the same (Reported by @barthanssens, Patch by @umbreak) From 4a6458a684f3126c3579b8b703b5b574f60b41c1 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 13 Dec 2021 15:21:21 +0100 Subject: [PATCH 40/50] Release 0.13.4 Signed-off-by: christoph@hbz-nrw.de --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 880e341f..faac5b82 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.4-SNAPSHOT + 0.13.4 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 37d130c8..4222a722 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.4-SNAPSHOT + 0.13.4 JSONLD Java :: Parent Json-LD Java Parent POM pom From f2f1cf22dc8a9c30c47ab570c7aaa8243101ad02 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 13 Dec 2021 16:23:57 +0100 Subject: [PATCH 41/50] Bump to next development version Signed-off-by: Pascal Christoph --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index faac5b82..04547275 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.4 + 0.13.5-SNAPSHOT 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 4222a722..48f6c851 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.4 + 0.13.5-SNAPSHOT JSONLD Java :: Parent Json-LD Java Parent POM pom From 00f0ca5269ba5754479fcb4969034c6cb7782201 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 3 Nov 2023 11:11:22 +0100 Subject: [PATCH 42/50] Ignore test because context does no more resolve (#175) --- .../test/java/com/github/jsonldjava/core/LocalBaseTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java b/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java index 22093345..e12c9a02 100644 --- a/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java @@ -10,11 +10,13 @@ import java.nio.charset.Charset; import java.util.List; +import org.junit.Ignore; import org.junit.Test; import com.github.jsonldjava.utils.JsonUtils; public class LocalBaseTest { + @Ignore("TODO: context does no more resolve - see https://github.com/jsonld-java/jsonld-java/issues/175") @Test public void testMixedLocalRemoteBaseRemoteContextFirst() throws Exception { @@ -36,6 +38,7 @@ public void testMixedLocalRemoteBaseRemoteContextFirst() throws Exception { assertEquals(expanded, output); } + @Ignore("TODO: context does no more resolve - see https://github.com/jsonld-java/jsonld-java/issues/175") @Test public void testMixedLocalRemoteBaseLocalContextFirst() throws Exception { From 83cc4710a9168c87889b98b4a6bfeaff922ae47f Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 3 Nov 2023 11:13:32 +0100 Subject: [PATCH 43/50] Update dependencies - bump Jackson version to 2.12.7 - bump Guava version to 32.1.3 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 48f6c851..8e59d036 100755 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 4.5.13 4.4.14 - 2.11.4 + 2.12.7 4.13.2 1.7.32 1.2.7 @@ -211,7 +211,7 @@ com.google.guava guava - 29.0-jre + 32.1.3-jre From 25045d2aabd613a598ff09529789bd4e11e56a69 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 3 Nov 2023 11:29:31 +0100 Subject: [PATCH 44/50] Prepare for release Signed-off-by: christoph@hbz-nrw.de --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 647097f8..6e354ba5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ From Maven com.github.jsonld-java jsonld-java - 0.13.4 + 0.13.5 Code example @@ -323,11 +323,11 @@ Here is the basic outline for what your module's pom.xml should look like com.github.jsonld-java jsonld-java-parent - 0.13.4 + 0.13.5 4.0.0 jsonld-java-{your module} - 0.13.4-SNAPSHOT + 0.13.5-SNAPSHOT JSONLD Java :: {your module name} JSON-LD Java integration module for {RDF Library your module integrates} jar @@ -449,6 +449,10 @@ Alternatively, we can also host your repository in the jsonld-java organisation CHANGELOG ========= +### 2023-11-03 +* Release 0.13.5 +* Bump Jackson and Guava versions to latest for security updates + ### 2021-12-13 * Release 0.13.4 * Switch test logging from log4j to logback (Patch by @ansell) From 3ebed87283a39d8d89a5c186a5ecdd314f23a238 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 3 Nov 2023 11:32:38 +0100 Subject: [PATCH 45/50] Release 0.13.5 Signed-off-by: christoph@hbz-nrw.de --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 04547275..79d71594 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.5-SNAPSHOT + 0.13.5 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 8e59d036..7ae6629f 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.5-SNAPSHOT + 0.13.5 JSONLD Java :: Parent Json-LD Java Parent POM pom From 2c5c4108229d4e58b146ec53505136422f8a6fee Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Fri, 3 Nov 2023 13:41:18 +0100 Subject: [PATCH 46/50] Bump to next development version Signed-off-by: Pascal Christoph --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 79d71594..12a00243 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.5 + 0.13.6-SNAPSHOT 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index 7ae6629f..f724db6b 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.5 + 0.13.6-SNAPSHOT JSONLD Java :: Parent Json-LD Java Parent POM pom From 1c984b87cc8a8b8dcbafbbae7ae40337972369cd Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 6 Nov 2023 09:00:55 +0100 Subject: [PATCH 47/50] Reenable test by getting monarch-context (#175) Storing monarch-context into this repo will make the tests more stable. --- .../github/jsonldjava/core/LocalBaseTest.java | 3 - .../test/resources/custom/base-0001-in.jsonld | 7 +- .../test/resources/custom/base-0002-in.jsonld | 7 +- .../resources/custom/monarch-context.jsonld | 149 ++++++++++++++++++ 4 files changed, 157 insertions(+), 9 deletions(-) create mode 100644 core/src/test/resources/custom/monarch-context.jsonld diff --git a/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java b/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java index e12c9a02..22093345 100644 --- a/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java +++ b/core/src/test/java/com/github/jsonldjava/core/LocalBaseTest.java @@ -10,13 +10,11 @@ import java.nio.charset.Charset; import java.util.List; -import org.junit.Ignore; import org.junit.Test; import com.github.jsonldjava.utils.JsonUtils; public class LocalBaseTest { - @Ignore("TODO: context does no more resolve - see https://github.com/jsonld-java/jsonld-java/issues/175") @Test public void testMixedLocalRemoteBaseRemoteContextFirst() throws Exception { @@ -38,7 +36,6 @@ public void testMixedLocalRemoteBaseRemoteContextFirst() throws Exception { assertEquals(expanded, output); } - @Ignore("TODO: context does no more resolve - see https://github.com/jsonld-java/jsonld-java/issues/175") @Test public void testMixedLocalRemoteBaseLocalContextFirst() throws Exception { diff --git a/core/src/test/resources/custom/base-0001-in.jsonld b/core/src/test/resources/custom/base-0001-in.jsonld index f9bd58fd..12a082af 100644 --- a/core/src/test/resources/custom/base-0001-in.jsonld +++ b/core/src/test/resources/custom/base-0001-in.jsonld @@ -1,6 +1,6 @@ { - "@context": [ -"https://raw.githubusercontent.com/monarch-initiative/monarch-app/master/conf/monarch-context.jsonld", + "@context": [ + "https://raw.githubusercontent.com/jsonld-java/jsonld-java/master/core/src/test/resources/custom/monarch-context.jsonld", { "@base": "http://example.org/base/", "ex": "http://example.org/", @@ -13,4 +13,5 @@ "ex:name": "Jim", "ex:friendOf": "1234", "@type": "Person" -} \ No newline at end of file +} + diff --git a/core/src/test/resources/custom/base-0002-in.jsonld b/core/src/test/resources/custom/base-0002-in.jsonld index 4b2e3848..d533f432 100644 --- a/core/src/test/resources/custom/base-0002-in.jsonld +++ b/core/src/test/resources/custom/base-0002-in.jsonld @@ -1,5 +1,5 @@ { - "@context": [ + "@context": [ { "@base": "http://example.org/base/", "ex": "http://example.org/", @@ -7,10 +7,11 @@ "@type": "@id" } }, - "https://raw.githubusercontent.com/monarch-initiative/monarch-app/master/conf/monarch-context.jsonld" + "https://raw.githubusercontent.com/jsonld-java/jsonld-java/master/core/src/test/resources/custom/monarch-context.jsonld" ], "@id": "3456", "ex:name": "Jim", "ex:friendOf": "1234", "@type": "Person" -} \ No newline at end of file +} + diff --git a/core/src/test/resources/custom/monarch-context.jsonld b/core/src/test/resources/custom/monarch-context.jsonld new file mode 100644 index 00000000..472f4153 --- /dev/null +++ b/core/src/test/resources/custom/monarch-context.jsonld @@ -0,0 +1,149 @@ +{ + "@context" : { + "EFO" : "http://purl.obolibrary.org/obo/EFO_", + "obo" : "http://purl.obolibrary.org/obo/", + "inheritance" : "monarch:mode_of_inheritance", + "@base" : "http://monarch-initiative.org/", + "email" : "foaf:mbox", + "BIND" : "http://identifiers.org/bind/bind:", + "morpholino" : "GENO:0000417", + "GENO" : "http://purl.obolibrary.org/obo/GENO_", + "UMLS" : "http://purl.obolibrary.org/obo/UMLS_", + "dcat" : "http://www.w3.org/ns/dcat#", + "PMID" : "http://www.ncbi.nlm.nih.gov/pubmed/", + "MP" : "http://purl.obolibrary.org/obo/MP_", + "ISBN-10" : "http://monarch-initiative.org/publications/ISBN:", + "rdf" : "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "title" : "dc:title", + "Class" : "owl:Class", + "FBbt" : "http://purl.obolibrary.org/obo/FBbt_", + "pathway_associations" : "rdfs:seeAlso", + "FBInternalGT" : "http://monarchinitiative.org/genotype/", + "has_genotype" : "GENO:0000222", + "genotype" : "GENO:0000000", + "void" : "http://rdfs.org/ns/void#", + "has_phenotype" : "RO:0002200", + "reference_locus" : "GENO:0000036", + "dbVar" : "http://identifiers.org/dbVar_", + "AQTLTrait" : "http://purl.obolibrary.org/obo/AQTLTrait_", + "phenotype_associations" : "rdfs:seeAlso", + "ECO" : "http://purl.obolibrary.org/obo/ECO_", + "WB" : "http://identifiers.org/WormBase:", + "rdfs" : "http://www.w3.org/2000/01/rdf-schema#", + "variant_loci" : "GENO:0000027", + "MedGen" : "http://purl.obolibrary.org/obo/MedGen_", + "creator" : { + "@id" : "dc:creator", + "@type" : "@id" + }, + "SIO" : "http://semanticscience.org/resource/SIO_", + "DOID" : "http://purl.obolibrary.org/obo/DOID_", + "Ensembl" : "http://identifiers.org/ensembl:", + "id" : "@id", + "publisher" : "dc:publisher", + "depiction" : { + "@id" : "foaf:depiction", + "@type" : "@id" + }, + "ENSEMBL" : "http://identifiers.org/ensembl:", + "monarch" : "http://monarchinitiative.org/", + "ORPHANET" : "http://purl.obolibrary.org/obo/ORPHANET_", + "owl" : "http://www.w3.org/2002/07/owl#", + "GeneReviews" : "http://www.ncbi.nlm.nih.gov/books/", + "SNOMED_CT" : "http://purl.obolibrary.org/obo/SNOMED_", + "chromosomal_region" : "GENO:0000390", + "EOM" : "http://purl.obolibrary.org/obo/EOM_", + "type" : { + "@id" : "rdf:type", + "@type" : "@id" + }, + "FlyBase" : "http://identifiers.org/flybase:", + "DECIPHER" : "http://purl.obolibrary.org/obo/DECIPHER_", + "faldo" : "http://biohackathon.org/resource/faldo#", + "prov" : "http://www.w3.org/ns/prov#", + "MIM" : "http://purl.obolibrary.org/obo/OMIM_", + "genomic_variation_complement" : "GENO:0000009", + "evidence" : "monarch:evidence", + "BioGRID" : "http://purl.obolibrary.org/BioGRID_", + "dcterms" : "http://purl.org/dc/terms/", + "sequence_alteration" : "SO:0001059", + "RO" : "http://purl.obolibrary.org/obo/RO_", + "created" : { + "@id" : "dc:created", + "@type" : "xsd:dateTime" + }, + "Orphanet" : "http://purl.obolibrary.org/obo/ORPHANET_", + "oa" : "http://www.w3.org/ns/oa#", + "SGD" : "http://identifiers.org/mgd/sgd:", + "Gene" : "http://purl.obolibrary.org/obo/NCBIGene_", + "PomBase" : "http://identifiers.org/PomBase:", + "genotype_associations" : "rdfs:seeAlso", + "xsd" : "http://www.w3.org/2001/XMLSchema#", + "OMIABreed" : "http://purl.obolibrary.org/obo/OMIA_", + "TAIR" : "http://identifiers.org/mgd/tair:", + "oboInOwl" : "http://www.geneontology.org/formats/oboInOwl#", + "description" : "dc:description", + "disease" : "monarch:disease", + "OMIAPub" : "http://purl.obolibrary.org/obo/OMIAPub_", + "foaf" : "http://xmlns.com/foaf/0.1/", + "idot" : "http://identifiers.org/", + "subClassOf" : "owl:subClassOf", + "source" : "dc:source", + "keyword" : "dcat:keyword", + "onset" : "monarch:age_of_onset", + "genomic_background" : "GENO:0000010", + "dictyBase" : "http://identifiers.org/dictyBase:", + "OMIA" : "http://purl.obolibrary.org/obo/OMIA_", + "has_part" : "BFO:0000051", + "ClinVarVariant" : "http://identifiers.org/ClinVarVariant_", + "gene_locus" : "GENO:0000014", + "effective_genotype" : "GENO:0000525", + "VT" : "http://purl.obolibrary.org/obo/VT_", + "Association" : "SIO:000897", + "resource" : "monarch:nif-resource", + "KEGG" : "http://identifiers.org/kegg:", + "Annotation" : "oa:Annotation", + "FBdv" : "http://purl.obolibrary.org/obo/FBdv_", + "GeneID" : "http://purl.obolibrary.org/obo/NCBIGene_", + "has_background" : "GENO:0000010", + "BFO" : "http://purl.obolibrary.org/obo/BFO_", + "FB" : "http://identifiers.org/flybase:", + "frequency" : "monarch:frequency", + "ZP" : "http://purl.obolibrary.org/obo/ZP_", + "OMIM" : "http://purl.obolibrary.org/obo/OMIM_", + "MGI" : "http://identifiers.org/mgd/MGI:", + "dc" : "http://purl.org/dc/terms/", + "MONARCH" : "http://monarchinitiative.org/MONARCH_", + "ClinVarHaplotype" : "http://identifiers.org/ClinVarHaplotype_", + "homepage" : { + "@id" : "foaf:homepage", + "@type" : "@id" + }, + "RGD" : "http://identifiers.org/mgd/rgd:", + "CORIELL" : "http://purl.obolibrary.org/obo/CORIELL_", + "label" : "rdfs:label", + "NCBIGene" : "http://purl.obolibrary.org/obo/NCBIGene_", + "intrinsic_genotype" : "GENO:0000000", + "FBcv" : "http://purl.obolibrary.org/obo/FBcv_", + "WBStrain" : "http://identifiers.org/WormBase:", + "sequence_alteration_collection" : "GENO:0000025", + "reference" : "dc:publication", + "zygosity" : "GENO:0000133", + "chromosome" : "GENO:0000323", + "WormBase" : "http://identifiers.org/WormBase:", + "HPRD" : "http://identifiers.org/hprd/hprd:", + "ClinVar" : "http://purl.obolibrary.org/obo/ClinVar_", + "ISBN-13" : "http://monarch-initiative.org/publications/ISBN:", + "extrinsic_genotype" : "GENO:0000524", + "NCBITaxon" : "http://purl.obolibrary.org/obo/NCBITaxon_", + "environment" : "GENO:0000099", + "variant_locus" : "GENO:0000481", + "comment" : "rdfs:comment", + "SO" : "http://purl.obolibrary.org/obo/SO_", + "phenotype" : "monarch:phenotype", + "ZFIN" : "http://identifiers.org/zfin:", + "HP" : "http://purl.obolibrary.org/obo/HP_", + "MESH" : "http://purl.obolibrary.org/obo/MESH_", + "dbSNP" : "http://identifiers.org/dbSNP_" + } +} From 156ec3e0f3325ed3abaa62e452d3d3610d7e7f53 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 6 Nov 2023 10:03:50 +0100 Subject: [PATCH 48/50] Update dependencies - bump Jackson version to 2.12.7.1 --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f724db6b..f7662a72 100755 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,7 @@ 4.5.13 4.4.14 2.12.7 + 2.12.7.1 4.13.2 1.7.32 1.2.7 @@ -66,7 +67,7 @@ com.fasterxml.jackson.core jackson-databind - ${jackson.version} + ${jackson-databind.version} com.fasterxml.jackson.core From 1cff4ce3093bce405c52b7b52737e0982119b4a0 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 6 Nov 2023 10:08:44 +0100 Subject: [PATCH 49/50] Prepare for release Signed-off-by: christoph@hbz-nrw.de --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6e354ba5..f1102e69 100644 --- a/README.md +++ b/README.md @@ -449,6 +449,10 @@ Alternatively, we can also host your repository in the jsonld-java organisation CHANGELOG ========= +### 2023-11-06 +* Release 0.13.6 +* Bump Jackson-databind version to latest for security update + ### 2023-11-03 * Release 0.13.5 * Bump Jackson and Guava versions to latest for security updates From 01c3086a2bba620bf74ac6440797275cb41cbe86 Mon Sep 17 00:00:00 2001 From: Pascal Christoph Date: Mon, 6 Nov 2023 10:16:20 +0100 Subject: [PATCH 50/50] Release 0.13.6 Signed-off-by: christoph@hbz-nrw.de --- core/pom.xml | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/pom.xml b/core/pom.xml index 12a00243..f14fb287 100755 --- a/core/pom.xml +++ b/core/pom.xml @@ -4,7 +4,7 @@ jsonld-java-parent com.github.jsonld-java - 0.13.6-SNAPSHOT + 0.13.6 4.0.0 jsonld-java diff --git a/pom.xml b/pom.xml index f7662a72..de5316fa 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.jsonld-java jsonld-java-parent - 0.13.6-SNAPSHOT + 0.13.6 JSONLD Java :: Parent Json-LD Java Parent POM pom