[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-13 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/203
  
I've done the upgrade to 0.9.0 on master for you. It's slightly easier to 
separate upgrades from other changes because they need noting in the release 
cycle.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-12 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@afs jsonld-java 0.9.0 solves the issue (and I have been able to run maven 
install on jena-arq with it).

How do you want to handle jsonld-java's version change? Other PR? Shouldn't 
I wait until then before closing JENA-1276?



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-12 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/203
  
`curl -v --header 'Accept: application/ld+json' http://schema.org/` returns 
zeros bytes. 

Is json-ld following redirects?  Where does jsonld-java's httpClient come 
from?

It is a 302 redirect to `http://schema.org/docs/jsonldcontext.json`. Does 
using that work? It does not for me but it's not clear it is the same error. 
(jsonld-java suppresses details).

If you agree this is from jsonld-java, could you close JENA-1276?  The 
jsonld-java developers aren't going to see it.

What about
* https://github.com/jsonld-java/jsonld-java/issues/188
* https://github.com/jsonld-java/jsonld-java/issues/186



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-12 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
>> current jena has a problem reading JSON-LD

> jsonld-java is reporting an error, all Jena does, and can do, is pass 
that error upwards.

reformulating: I have problem with current "jena as a whole, including 
jsonld-java" to read some JSON-LD

and therefore:

> I'd be curious to know whether someone else, who is completely sure about 
its settings, also gets this problem (or not)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-12 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/203
  
> BTW, I didn't see any test about reading JSON-LD. Are there any?

See `TestJsonLDReadWrite`.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-11 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
Hi,

there are very different points in the discussion, all around one test that 
attempts to connect to an external resource.

1) It must first be noted that the test in question actually doesn't have 
anything to do with the functionality that the PR proposes. It can as well be 
removed, and that wouldn't change anything about the object of the PR (the 
functionality that it proposes to add), nor about the completeness of the 
testing of that functionality.

If you want, I can remove it.

2) this test attempts to parse some JSON-LD whose @context contains the URI 
of schema.org - probably the most obvious use-case for reading JSON-LD

- BTW, I didn't see any test about reading JSON-LD. Are there any?

 - If this test cannot connect to schema.org because there are no 
external connection, (or for whatever reason) the test won't fail, because the 
RiotException is catched. Just one line is written to the console (and it is 
not by the test itself, but by the code that it calls). So this test with this 
external connection doesn't really cause trouble to the integration process 
(maybe a few seconds delay - the time for the HTTP client to stop trying to 
connect)

 - it shows me that I'm not able to read such JSON-LD on my machine (I 
get on the console: ```org.apache.jena.riot.RiotException: loading remote 
context failed: http://schema.org/```) - this, in a setting where it should 
work (standard jena 3.1.1, run from eclipse where I can connect to external 
resources from java, for instance using jersey client)

So: as far as I can tell (thanks to this test), current jena has a problem 
reading JSON-LD with @context set to a URI (at least, I have such a problem 
using current jena)

- it is probably possible to write a test that simulates connecting to an 
external resource without connecting to it (cf. "cache" mechanism in JSON-LD 
java), but
- such a test would probably not detect a problem such as the one we 
seem to have here
- it's out of the scope of current PR 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-11 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/203
  
@afs I think the point that @stain and I are making is that there is no 
need for an external resource linkage at all.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-11 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/203
  
External linkages in the tests is, in the long term, not good. At some 
point, the remote resource will be uncontactable. Sometimes people need to run 
the test offline as well. So for the long term robustness of the tests suite, I 
think the level of need for an external resource needs to be quite high. At 
least make the test respond to different errors - uncontactable vs a failure 
with the expected actions after the content is fetched. Even the latter is hard 
- the remote contents may change.

(this is what `StreamManager` is good for).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-11 Thread stain
Github user stain commented on the issue:

https://github.com/apache/jena/pull/203
  
For unit tests you can use a JAR-cached context by using the 
[jarcache.json](https://github.com/jsonld-java/jsonld-java#loading-contexts-from-classpathjar)
 approach and put it together with the JSON schema file in 
`src/test/resources/` - that would override the specified URL.

A similar approach can be used with `src/main/resources` - but then of 
course you would have to keep the schema cache up to date, so that's more for 
the end application to do to avoid external network dependencies.

Note that the actual [schema.org context 
file](http://schema.org/docs/jsonldcontext.json) is [licensed as CC BY 
SA](http://schema.org/docs/terms.html), but you could make a minimal version 
made just for the test which would not infringe copyright.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-10 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/203
  
@fpservant Yep, that's what I meant. I would be looking that as solvable by 
moving the location of the schema to a resource supported on the testing box, 
so it's not being resolved from the network. Note I'm not asking you to do 
that, just to make a note that someone should.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-10 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@ajs6f are you speaking of the "org.apache.jena.riot.RiotException: loading 
remote context failed" thing? 

1) note that in the context of a test, jena doesn't want to depend on a 
connexion to the network (so told me @afs when I was working on JSON-LD writing 
- and getting, BTW, same kind of problem, for reasons which are supposed to 
have been solved since). So the catch Exception must probably stay in the code 
of the test.

2) I'd be curious to know whether someone else, who is completely sure 
about its settings, also gets this problem (problems with http connexions may 
be many different things!) (Other people experiment it, cf. question on 
jena-users that initiated this PR, but are they up-to-date?). So I would be 
happy to get confirmation of the problem from others.

I tried to track it down. It occurs to me at 
```com.github.jsonldjava.core.DocumentLoader.loadDocument(String)``` line 29

where I get:
```org.apache.http.ConnectionClosedException: Premature end of 
Content-Length delimited message body (expected: 124346; received: 0```




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


Re: [GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread François-Paul Servant
the proposal to use a parse method allows to change current code from:

```
ReaderRIOT reader = RDFDataMgr.createReader(Lang.JSONLD);
try (InputStream in = new 
ByteArrayInputStream(jsonld.getBytes(StandardCharsets.UTF_8))) {
reader.read(in, null, null, 
StreamRDFLib.dataset(ds.asDatasetGraph()), jenaCtx);
}
```

to:

```
try (InputStream in = new 
ByteArrayInputStream(jsonld.getBytes(StandardCharsets.UTF_8))) {
RDFDataMgr.parse(StreamRDFLib.dataset(ds.asDatasetGraph()), in, 
null, Lang.JSONLD, jenaCtx);
}
```

That’s indeed one line instead of 2, and one param less in the method used 
(ContentType, here set to null).
Simpler indeed. 
(Not that simple to use the context mechanism in read and write, but OK! ;-))
I do the change

> Le 9 janv. 2017 à 16:54, ajs6f  a écrit :
> 
> Github user ajs6f commented on the issue:
> 
>https://github.com/apache/jena/pull/203
> 
>You're saying use `org.apache.jena.riot.RDFDataMgr.parse(StreamRDF, 
> InputStream, String, Lang, Context)`? That does make sense. I guess I was 
> thinking of the general need to customize parsing behavior, but as long as 
> there is a reasonably concise form, that's all I care about. @fpservant does 
> that work for you?
> 
> 
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
> with INFRA.
> ---



[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/203
  
You're saying use `org.apache.jena.riot.RDFDataMgr.parse(StreamRDF, 
InputStream, String, Lang, Context)`? That does make sense. I guess I was 
thinking of the general need to customize parsing behavior, but as long as 
there is a reasonably concise form, that's all I care about. @fpservant does 
that work for you?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/203
  
@fpservant @afs Yes, exactly. Having a method on `RdfDataMgr` that takes 
`InputStream` _and_ `Context` seems very natural. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@afs I think that @ajs6f refers to code:
```
InputStream in = new 
ByteArrayInputStream(jsonld.getBytes(StandardCharsets.UTF_8));
+Dataset ds = DatasetFactory.create();
+ReaderRIOT reader = RDFDataMgr.createReader(Lang.JSONLD);
(etc)
```
he commented:

> This whole section seems complex. How about 
org.apache.jena.riot.RDFDataMgr.read(Model, StringReader, String, Lang)?

and I replied:

> Hmm, maybe I'm missing something obvious, but I need to pass the Context. 
I didn't find an easier way (all read methods in RDFDataMgr that take the 
Context as arg use the uri param to define what we read).

and:
> I'd be happy to learn about a better way to read data from an 
InputStream, that supports the passing of a Context


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread afs
Github user afs commented on the issue:

https://github.com/apache/jena/pull/203
  
With the changes that have happened, I'm not seeing the comment to which 
you refer.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-09 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/203
  
@fpservant Oh my goodness, you are quite right. There is no appropriate 
method in `RdfDataMgr`! @afs I think we could reasonably add such a method as 
part of this PR-- it would clearly be useful. What say ye?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-08 Thread fpservant
Github user fpservant commented on the issue:

https://github.com/apache/jena/pull/203
  
@ajs6f thanks for the review. I made most (all ?) of the changes that you 
suggested. Remains the problem "loading remote context failed: 
http://schema.org/; - unrelated to this PR per se.

Regarding the section that you find too complex: I'd be happy to learn 
about a better way to read data from an InputStream, that supports the passing 
of a Context


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] jena issue #203: JsonLDReader: possibility to override the @context

2017-01-08 Thread ajs6f
Github user ajs6f commented on the issue:

https://github.com/apache/jena/pull/203
  
This is good stuff-- thanks for taking a problem and turning it into an 
improvement!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---