Remove embed package
This commit finally removes the embed package in favor of more specific resource packages
This commit is contained in:
parent
91a088a56a
commit
86a4334796
51 changed files with 220 additions and 191 deletions
57
component/triplestore/create-repo.ttl
Normal file
57
component/triplestore/create-repo.ttl
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
# This file is used to initialize a new GraphDB repository.
|
||||
# In this file the variables ${GRAPHDB_REPO} and ${INSTANCE_DOMAIN} will be replaced.
|
||||
# All other variables will be left untouched.
|
||||
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
|
||||
@prefix rep: <http://www.openrdf.org/config/repository#>.
|
||||
@prefix sr: <http://www.openrdf.org/config/repository/sail#>.
|
||||
@prefix sail: <http://www.openrdf.org/config/sail#>.
|
||||
@prefix owlim: <http://www.ontotext.com/trree/owlim#>.
|
||||
|
||||
[] a rep:Repository ;
|
||||
rep:repositoryID "${GRAPHDB_REPO}" ;
|
||||
rdfs:label "${INSTANCE_DOMAIN}" ;
|
||||
rep:repositoryImpl [
|
||||
rep:repositoryType "graphdb:SailRepository" ;
|
||||
sr:sailImpl [
|
||||
sail:sailType "graphdb:Sail" ;
|
||||
|
||||
owlim:owlim-license "" ;
|
||||
|
||||
owlim:base-URL "http://${INSTANCE_DOMAIN}/" ;
|
||||
owlim:defaultNS "" ;
|
||||
owlim:entity-index-size "10000000" ;
|
||||
owlim:entity-id-size "32" ;
|
||||
owlim:imports "" ;
|
||||
owlim:repository-type "file-repository" ;
|
||||
owlim:ruleset "empty" ;
|
||||
owlim:storage-folder "storage" ;
|
||||
|
||||
owlim:enable-context-index "false" ;
|
||||
owlim:cache-memory "80m" ;
|
||||
owlim:tuple-index-memory "80m" ;
|
||||
|
||||
owlim:enablePredicateList "false" ;
|
||||
owlim:predicate-memory "0%" ;
|
||||
|
||||
owlim:fts-memory "0%" ;
|
||||
owlim:ftsIndexPolicy "never" ;
|
||||
owlim:ftsLiteralsOnly "true" ;
|
||||
|
||||
owlim:in-memory-literal-properties "false" ;
|
||||
owlim:enable-literal-index "true" ;
|
||||
owlim:index-compression-ratio "-1" ;
|
||||
|
||||
owlim:check-for-inconsistencies "false" ;
|
||||
owlim:disable-sameAs "false" ;
|
||||
owlim:enable-optimization "true" ;
|
||||
owlim:transaction-mode "safe" ;
|
||||
owlim:transaction-isolation "true" ;
|
||||
owlim:query-timeout "0" ;
|
||||
owlim:query-limit-results "0" ;
|
||||
owlim:throw-QueryEvaluationException-on-timeout "false" ;
|
||||
owlim:useShutdownHooks "true" ;
|
||||
owlim:read-only "false" ;
|
||||
owlim:nonInterpretablePredicates "http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig" ;
|
||||
]
|
||||
].
|
||||
|
|
@ -11,13 +11,9 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/embed"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/fsx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/logging"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/unpack"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wait"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
)
|
||||
|
||||
|
|
@ -99,70 +95,6 @@ func (ts Triplestore) Wait() error {
|
|||
}, ts.PollInterval, ts.PollContext)
|
||||
}
|
||||
|
||||
var errTripleStoreFailedRepository = exit.Error{
|
||||
Message: "Failed to create repository: %s",
|
||||
ExitCode: exit.ExitGeneric,
|
||||
}
|
||||
|
||||
func (ts Triplestore) Provision(name, domain, user, password string) error {
|
||||
if err := ts.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// prepare the create repo request
|
||||
// TODO: Move this into a seperate file
|
||||
createRepo, _, err := unpack.UnpackTemplate(
|
||||
map[string]string{
|
||||
"GRAPHDB_REPO": name,
|
||||
"INSTANCE_DOMAIN": domain,
|
||||
},
|
||||
fsx.OpenFS(filepath.Join("resources", "templates", "repository", "graphdb-repo.ttl"), embed.ResourceEmbed),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// do the create!
|
||||
{
|
||||
res, err := ts.OpenRaw("POST", "/rest/repositories", createRepo, "config", "")
|
||||
if err != nil {
|
||||
return errTripleStoreFailedRepository.WithMessageF(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusCreated {
|
||||
return errTripleStoreFailedRepository.WithMessageF("Repo create did not return status code 201")
|
||||
}
|
||||
}
|
||||
|
||||
// create the user and grant them access
|
||||
{
|
||||
res, err := ts.OpenRaw("POST", "/rest/security/users/"+user, TriplestoreUserPayload{
|
||||
Password: password,
|
||||
AppSettings: TriplestoreUserAppSettings{
|
||||
DefaultInference: true,
|
||||
DefaultVisGraphSchema: true,
|
||||
DefaultSameas: true,
|
||||
IgnoreSharedQueries: false,
|
||||
ExecuteCount: true,
|
||||
},
|
||||
GrantedAuthorities: []string{
|
||||
"ROLE_USER",
|
||||
"READ_REPO_" + name,
|
||||
"WRITE_REPO_" + name,
|
||||
},
|
||||
}, "", "")
|
||||
if err != nil {
|
||||
return errTripleStoreFailedRepository.WithMessageF(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusCreated {
|
||||
return errTripleStoreFailedRepository.WithMessageF("User create did not return status code 201")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TriplestorePurgeUser deletes the specified user from the triplestore
|
||||
func (ts Triplestore) PurgeUser(user string) error {
|
||||
res, err := ts.OpenRaw("DELETE", "/rest/security/users/"+user, nil, "", "")
|
||||
|
|
|
|||
75
component/triplestore/provision.go
Normal file
75
component/triplestore/provision.go
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
package triplestore
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/unpack"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
)
|
||||
|
||||
var errTripleStoreFailedRepository = exit.Error{
|
||||
Message: "Failed to create repository: %s",
|
||||
ExitCode: exit.ExitGeneric,
|
||||
}
|
||||
|
||||
//go:embed create-repo.ttl
|
||||
var createRepoTTL []byte
|
||||
|
||||
func (ts Triplestore) Provision(name, domain, user, password string) error {
|
||||
if err := ts.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// prepare the create repo request
|
||||
var createRepo bytes.Buffer
|
||||
err := unpack.WriteTemplate(&createRepo, map[string]string{
|
||||
"GRAPHDB_REPO": name,
|
||||
"INSTANCE_DOMAIN": domain,
|
||||
}, bytes.NewReader(createRepoTTL))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// do the create!
|
||||
{
|
||||
res, err := ts.OpenRaw("POST", "/rest/repositories", createRepo.Bytes(), "config", "")
|
||||
if err != nil {
|
||||
return errTripleStoreFailedRepository.WithMessageF(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusCreated {
|
||||
return errTripleStoreFailedRepository.WithMessageF("Repo create did not return status code 201")
|
||||
}
|
||||
}
|
||||
|
||||
// create the user and grant them access
|
||||
{
|
||||
res, err := ts.OpenRaw("POST", "/rest/security/users/"+user, TriplestoreUserPayload{
|
||||
Password: password,
|
||||
AppSettings: TriplestoreUserAppSettings{
|
||||
DefaultInference: true,
|
||||
DefaultVisGraphSchema: true,
|
||||
DefaultSameas: true,
|
||||
IgnoreSharedQueries: false,
|
||||
ExecuteCount: true,
|
||||
},
|
||||
GrantedAuthorities: []string{
|
||||
"ROLE_USER",
|
||||
"READ_REPO_" + name,
|
||||
"WRITE_REPO_" + name,
|
||||
},
|
||||
}, "", "")
|
||||
if err != nil {
|
||||
return errTripleStoreFailedRepository.WithMessageF(err)
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusCreated {
|
||||
return errTripleStoreFailedRepository.WithMessageF("User create did not return status code 201")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue