ali1k / ld-r

Linked Data Reactor (LD-R)
http://ld-r.org
Other
127 stars 30 forks source link

Add support for GraphDB triplestore #54

Closed mathib closed 6 years ago

mathib commented 6 years ago

Hi Ali,

I've came accross GraphDB triplestore recently, which includes a DBaaS version. I've found it very useful for setting up a small and free SPARQL endpoint on a cloudserver. This could be ideal for #demoing some LD-R applications running on Heroku :)

Some props:

ali1k commented 6 years ago

@mathib looks nice! thanks for sharing. I will have a look to see how their SPARQl API works. Should be quite straightforward .

mathib commented 6 years ago

Great! Finally an easy way to share an LD-R app with some demo triples :)

ali1k commented 6 years ago

Great! Finally an easy way to share an LD-R app with some demo triples :)

yes! I added support for GraphDB there...

mathib commented 6 years ago

Did some quick tests:

I tried with port 443 as it graphdb cloud is served on https, but then I get the following error:

{ RequestError: Error: read ECONNRESET
    at new RequestError (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request-promise-core\lib\errors.js:14:15)
    at Request.plumbing.callback (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request-promise-core\lib\plumbing.js:87:29)
    at Request.RP$callback [as _callback] (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request-promise-core\lib\plumbing.js:46:31)
    at self.callback (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request\request.js:185:22)
    at Request.emit (events.js:180:13)
    at Request.onRequestError (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request\request.js:881:8)
    at ClientRequest.emit (events.js:185:15)
    at Socket.socketErrorListener (_http_client.js:395:9)
    at Socket.emit (events.js:180:13)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at process._tickCallback (internal/process/next_tick.js:178:19)
From previous event:
    at Request.plumbing.init (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request-promise-core\lib\plumbing.js:36:28)
    at Request.RP$initInterceptor [as init] (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request-promise-core\configure\request2.js:41:27)
    at new Request (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request\request.js:127:8)
    at request (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request\index.js:53:10)
    at Function.post (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\request\index.js:61:12)
    at C:/Users/<USER-NAME>/Desktop/ld-r/services/facet.js:280:24
    at C:/Users/<USER-NAME>/Desktop/ld-r/services/utils/Configurator.js:61:13
    at DynamicConfigurator.prepareDynamicDatasetConfig (C:/Users/<USER-NAME>/Desktop/ld-r/plugins/dynamicConfiguration/DynamicConfigurator.js:479:13)
    at Configurator.prepareDatasetConfig (C:/Users/<USER-NAME>/Desktop/ld-r/services/utils/Configurator.js:47:29)
    at C:/Users/<USER-NAME>/Desktop/ld-r/services/facet.js:237:30
    at C:/Users/<USER-NAME>/Desktop/ld-r/services/utils/dynamicHelpers.js:72:13
    at C:/Users/<USER-NAME>/Desktop/ld-r/services/utils/dynamicHelpers.js:49:9
    at DynamicConfigurator.prepareDynamicServerConfig (C:/Users/<USER-NAME>/Desktop/ld-r/plugins/dynamicConfiguration/DynamicConfigurator.js:172:13)
    at prepareDGFunc (C:/Users/<USER-NAME>/Desktop/ld-r/services/utils/dynamicHelpers.js:15:25)
    at getDynamicEndpointParameters (C:/Users/<USER-NAME>/Desktop/ld-r/services/utils/dynamicHelpers.js:54:9)
    at Object.read (C:/Users/<USER-NAME>/Desktop/ld-r/services/facet.js:234:13)
    at Immediate.executeRequest (C:\Users\<USER-NAME>\Desktop\ld-r\node_modules\fetchr\libs\fetcher.js:229:21)
    at runCallback (timers.js:764:11)
    at tryOnImmediate (timers.js:734:5)
    at processImmediate (timers.js:716:5)
  name: 'RequestError',
  message: 'Error: read ECONNRESET',
  cause: { Error: read ECONNRESET
    at TCP.onread (net.js:602:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' },
  error: { Error: read ECONNRESET
    at TCP.onread (net.js:602:25) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' },
  options:
   { uri: 'http://rdf.ontotext.com:443/<DB-number>/<DB-id>/repositories/<repo-id>',
     form:
      { query: '\n        PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n        PREFIX owl: <http://www.w3.org/2002/07/owl#>\n        PREFIX dcterms: <http://purl.org/dc/terms/>\n        PREFIX void: <http://rdfs.org/ns/void#>\n        PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n        PREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n        \n        SELECT (count(DISTINCT ?s) AS ?total) WHERE {\n             \n                 ?s rdf:type ?type . FILTER (?type IN (<https://w3id.org/bot#Site>,<https://w3id.org/bot#Building>,<https://w3id.org/bot#Storey>,<https://w3id.org/bot#Space>,<https://w3id.org/bot#Element>)) \n                \n             \n        }\n        ',
        format: 'application/sparql-results+json' },
     headers: { Accept: 'application/sparql-results+json' },
     timeout: 10000,
     method: 'POST',
     callback: [Function: RP$callback],
     transform: undefined,
     simple: true,
     resolveWithFullResponse: false,
     transform2xxOnly: false },
  response: undefined }
mathib commented 6 years ago

it probably has something to do with authentication?

mathib commented 6 years ago

Some documentation that might come in handy:

mathib commented 6 years ago

@ali1k I've also did some testing with Postman to the graphdb cloud database and I've found out that I need indeed authentication to the SPARQL endpoint for this. I've also found that the request has to be modified in the case of SPARQL update:

Did you by any chance had some time to look into authentication-based access to SPARQL endpoints as mentioned here? If so, is there any documentation on how to use it? Thanks :)

ali1k commented 6 years ago

thanks for the comments. I have already added those changes for GraphDB:

https://github.com/ali1k/ld-r/blob/master/services/utils/helpers.js#L168-L177

you can useusername and password attributes in your server.js file for HTTP-based authentication. Let me know if it works with that

mathib commented 6 years ago

Hi! Great, this works for me :) Think you can then close issue 18? Or does it need more testing on other kind of triplestores with authentication?

I'm no expert in this, but isn't it safer to add username and password as basic auth in the header, instead of adding it to the URL? I've also noted that the attribute reasoning has to be changed to infer in the case of graphdb

ali1k commented 6 years ago

great! I closed the issue #18 I don't think these credentials will be shared anywhere on the client as they are only shared on the server side of LD-R. However, it is still worth to further investigate that.

I also added support for infer when add useReasoning flag in server config.

mathib commented 6 years ago

I don't think these credentials will be shared anywhere on the client as they are only shared on the server side of LD-R

No, I meant that if you add credentials to the URL of the request, it is just plain and open (I think), while if you add it as an attribute in the header it is hashed?

I also added support for infer when add useReasoning flag in server config.

Thanks!

ali1k commented 6 years ago

thanks for the clarification. yes, I will check how I can add them to headers!

lolostar commented 6 years ago

Hi,

I try to configure ld-r but although I indicate graphDB in my config file, I still have ClioPatria in my ldr repository (graphDB) ... I think I got rid of all mention of ClioPatria in the config files.

capture d ecran 2018-10-02 a 15 16 24