Skip to content

Commit

Permalink
#38, convert gstore to dstore
Browse files Browse the repository at this point in the history
  • Loading branch information
manonthegithub committed Jun 19, 2024
1 parent 7121ca3 commit defc710
Show file tree
Hide file tree
Showing 15 changed files with 649 additions and 351 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ ENV GIT_LOCAL_DIR=""
ENV LOGS_FOLDER=/gstore/logs/
ENV GSTORE_LOG_LEVEL=INFO

ENV DEFAULT_JSONLD_LOCALHOST_CONTEXT=http://localhost:3000/res/context.jsonld
ENV DEFAULT_JSONLDLOCALHOST_CONTEXT_LOCATION=https://databus.dbpedia.org/res/context.jsonld

RUN apk update
RUN apk upgrade
RUN apk add bash

COPY --from=build /gstore/target/scala-2.12/gstore-assembly-0.2.0-SNAPSHOT.jar /app/app.jar

SHELL ["/bin/bash", "-c"]
CMD java -DrestrictEditsToLocalhost=$RESTRICT_EDITS_TO_LOCALHOST -Dgstore.log.level=$GSTORE_LOG_LEVEL -DstorageDbName=$STORAGE_DB_NAME -DstorageClass=$STORAGE_CLIENT_CLASS -DstorageSparqlEndpointUri=$STORAGE_SPARQL_ENDPOINT_URI -DstorageJdbcPort=$STORAGE_JDBC_PORT -DstorageUser=$STORAGE_USER -DstoragePass=$STORAGE_PASS -DgitLocalDir=$GIT_LOCAL_DIR -DlogsFolder=$LOGS_FOLDER -jar /app/app.jar
CMD java -DdefaultJsonldLocalhostContext=$DEFAULT_JSONLD_LOCALHOST_CONTEXT -DdefaultJsonldLocalhostContextLocation=$DEFAULT_JSONLDLOCALHOST_CONTEXT_LOCATION -DrestrictEditsToLocalhost=$RESTRICT_EDITS_TO_LOCALHOST -Dgstore.log.level=$GSTORE_LOG_LEVEL -DstorageDbName=$STORAGE_DB_NAME -DstorageClass=$STORAGE_CLIENT_CLASS -DstorageSparqlEndpointUri=$STORAGE_SPARQL_ENDPOINT_URI -DstorageJdbcPort=$STORAGE_JDBC_PORT -DstorageUser=$STORAGE_USER -DstoragePass=$STORAGE_PASS -DgitLocalDir=$GIT_LOCAL_DIR -DlogsFolder=$LOGS_FOLDER -jar /app/app.jar
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# G(it|raph) Store

A web service for retrieving, validating and storing rdf data (jsonld) in
A web service for retrieving, validating and storing documents with rdf data (jsonld) in
1. a SPARQL endpoint using filepath as graph
2. a git-enabled storage.

Expand Down
7 changes: 4 additions & 3 deletions documentation/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ After the containers are up, the following services will be available:
* SPARQL endpoint http://localhost:3002/sparql
* GSTORE http://localhost:3002/ with swagger documentation
* GET /graph/read
* DELETE /graph/delete
* POST /graph/save
* DELETE /document/delete
* POST /document/save
* GET /document/read
* POST /dataid/tractate
* POST /shacl/validate

### Example: Saving a file
```
curl -X 'POST' 'http://localhost:3002/file/save?repo=kurzum&path=example.jsonld' -H 'accept: application/json' -H 'Content-Type: application/ld+json' -d '{
curl -X 'POST' 'http://localhost:3002/document/save?repo=kurzum&path=example.jsonld' -H 'accept: application/json' -H 'Content-Type: application/ld+json' -d '{
"@context": "http://schema.org/",
"@type": "Person",
"name": "Jane Doe",
Expand Down
10 changes: 8 additions & 2 deletions project/scalatra/databusBodyParamOperation.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{{#isBodyParam}}
{{!val paramName = parsedBody.extract[dataType] }}
val {{paramName}} = request.body
{{#isByteArray}}
val {{paramName}} =
if(!request.getInputStream.isFinished) request.getInputStream.readAllBytes else request.body.getBytes

{{/isByteArray}}
{{^isByteArray}}
val paramName = parsedBody.extract[dataType]
{{/isByteArray}}
{{/isBodyParam}}
10 changes: 10 additions & 0 deletions project/scalatra/databusFormParam.mustache
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
{{#isFormParam}}
{{#isByteArray}}
val {{paramName}} = Try(fileMultiParams("{{baseName}}").head).toOption
.map(a => a.get())
.orElse(multiParams("{{baseName}}").headOption.map(_.getBytes))
{{#required}}
.getOrElse(halt(400, "Form parameter {{baseName}} not specified."))
{{/required}}
{{/isByteArray}}
{{^isByteArray}}
val {{paramName}} = Try(fileMultiParams("{{baseName}}").head).toOption
.map(a => new String(a.get()))
.orElse(multiParams("{{baseName}}").headOption)
{{#required}}
.getOrElse(halt(400, "Form parameter {{baseName}} not specified."))
{{/required}}
{{/isByteArray}}
{{/isFormParam}}
9 changes: 5 additions & 4 deletions project/scalatra/databus_api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class {{classname}}(implicit val swagger: Swagger, apiImpl: DatabusApi) extends
{{httpMethod}}("{{{vendorExtensions.x-scalatra-path}}}",operation({{nickname}}Operation)) {
{{#allParams}}
{{#isFile}}val {{paramName}} = fileParams("{{paramName}}"){{/isFile}}
{{^isFile}}{{#isPathParam}}
val {{paramName}} = params.getOrElse("{{paramName}}", halt(400)){{/isPathParam}}
{{>databusQueryParam}}{{>headerParamOperation}}{{>databusFormParam}}{{>databusBodyParamOperation}}
{{^isFile}}
{{>databusBodyParamOperation}}
{{#isPathParam}}val {{paramName}} = params.getOrElse("{{paramName}}", halt(400)){{/isPathParam}}
{{>databusQueryParam}}{{>headerParamOperation}}{{>databusFormParam}}
{{/isFile}}
{{/allParams}}
val resp = apiImpl.{{nickname}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})(request)
Expand Down Expand Up @@ -81,7 +82,7 @@ trait DatabusApi {
{{#operations}}
{{#operation}}
{{newline}}
def {{nickname}}({{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}Option[{{dataType}}]{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})(request: HttpServletRequest): Try[{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]
def {{nickname}}({{#allParams}}{{paramName}}: {{#required}}{{#isByteArray}}Array[Byte]{{/isByteArray}}{{^isByteArray}}{{dataType}}{{/isByteArray}}{{/required}}{{^required}}{{#isByteArray}}Option[Array[Byte]]{{/isByteArray}}{{^isByteArray}}Option[{{dataType}}]{{/isByteArray}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})(request: HttpServletRequest): Try[{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]

{{#responses}}
{{^isDefault}}
Expand Down
Loading

0 comments on commit defc710

Please sign in to comment.