Skip to content

Instantly share code, notes, and snippets.

@joachimvh
Created August 25, 2021 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joachimvh/da75e1239fb026db0b3375ded505b21f to your computer and use it in GitHub Desktop.
Save joachimvh/da75e1239fb026db0b3375ded505b21f to your computer and use it in GitHub Desktop.
Send internal storage to the file system and everything else to the sparql store
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
"import": [
"files-scs:config/app/main/default.json",
"files-scs:config/app/init/default.json",
"files-scs:config/http/handler/default.json",
"files-scs:config/http/middleware/websockets.json",
"files-scs:config/http/server-factory/websockets.json",
"files-scs:config/http/static/default.json",
"files-scs:config/identity/email/default.json",
"files-scs:config/identity/handler/default.json",
"files-scs:config/identity/ownership/token.json",
"files-scs:config/identity/pod/static.json",
"files-scs:config/identity/registration/enabled.json",
"files-scs:config/ldp/authentication/dpop-bearer.json",
"files-scs:config/ldp/authorization/webacl.json",
"files-scs:config/ldp/handler/default.json",
"files-scs:config/ldp/metadata-parser/default.json",
"files-scs:config/ldp/metadata-writer/default.json",
"files-scs:config/ldp/permissions/acl.json",
"files-scs:config/storage/key-value/resource-store.json",
"files-scs:config/storage/middleware/default.json",
"files-scs:config/util/auxiliary/acl.json",
"files-scs:config/util/identifiers/suffix.json",
"files-scs:config/util/index/default.json",
"files-scs:config/util/logging/winston.json",
"files-scs:config/util/representation-conversion/default.json",
"files-scs:config/util/resource-locker/memory.json",
"files-scs:config/util/variables/default.json",
"files-scs:config/storage/backend/data-accessors/file.json",
"files-scs:config/storage/backend/data-accessors/sparql-endpoint.json"
],
"@graph": [
{
"comment": [
"Differences from default sparql-endpoint.json:",
" Using config/storage/middleware/default.json,",
" Removed config/storage/backend/sparql.json import to replace with our own below.",
" Add imports for specific DataAccessors.",
" Config below is based on config/storage/backend/regex.json."
]
},
{
"comment": "A more complex example with 3 different stores being routed to.",
"@id": "urn:solid-server:default:ResourceStore_Backend",
"@type": "RoutingResourceStore",
"rule": { "@id": "urn:solid-server:default:RouterRule" }
},
{
"comment": [
"Configure routing to send internal data to file system and all other data to sparql store.",
"Paths based on those found in config/storage/middleware/default.json"
],
"@id": "urn:solid-server:default:RouterRule",
"@type": "RegexRouterRule",
"base": { "@id": "urn:solid-server:default:variable:baseUrl" },
"storeMap": [
{
"comment": "Internal storage for locks",
"RegexRouterRule:_storeMap_key": "^/locks/",
"RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:FileResourceStore" }
},
{
"comment": "Internal storage for IDP data",
"RegexRouterRule:_storeMap_key": "^/idp/",
"RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:FileResourceStore" }
},
{
"comment": "Send everything else to the SPARQL store.",
"RegexRouterRule:_storeMap_key": "^/(?!idp/|locks/).*",
"RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:SparqlResourceStore" }
}
]
},
{
"@id": "urn:solid-server:default:FileResourceStore",
"@type": "DataAccessorBasedStore",
"identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" },
"auxiliaryStrategy": { "@id": "urn:solid-server:default:AuxiliaryStrategy" },
"accessor": { "@id": "urn:solid-server:default:FileDataAccessor" }
},
{
"@id": "urn:solid-server:default:SparqlResourceStore",
"@type": "DataAccessorBasedStore",
"identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" },
"auxiliaryStrategy": { "@id": "urn:solid-server:default:AuxiliaryStrategy" },
"accessor": { "@id": "urn:solid-server:default:SparqlDataAccessor" }
}
]
}
@nickform
Copy link

There seems to be some problem with initialisation. I got the following output from CSS:

css_1                          | 2021-08-25T09:29:04.088Z [Components.js] info: Initiating component discovery from /community-server/
css_1                          | 2021-08-25T09:29:04.427Z [Components.js] info: Discovered 130 component packages within 1362 packages
css_1                          | 2021-08-25T09:29:04.428Z [Components.js] info: Initiating component loading
css_1                          | 2021-08-25T09:29:05.721Z [Components.js] info: Registered 408 components
css_1                          | 2021-08-25T09:29:05.721Z [Components.js] info: Loaded configs
css_1                          | 2021-08-25T09:29:06.381Z [SparqlDataAccessor] info: Sending SPARQL CONSTRUCT query to http://my-sparql-endpoint/sparql: CONSTRUCT { ?s ?p ?o. }
css_1                          | WHERE { GRAPH <meta:http://localhost:3000/> { ?s ?p ?o. } }
css_1                          | 2021-08-25T09:29:07.181Z [RootInitializer] info: Root container not found; initializing it.
css_1                          | 2021-08-25T09:29:07.185Z [RootInitializer] warn: Failed to create resource http://localhost:3000/: Only Quad data is supported.
css_1                          | 2021-08-25T09:29:07.185Z [RootInitializer] warn: Failed to create resource http://localhost:3000/.acl: Only Quad data is supported.
css_1                          | 2021-08-25T09:29:07.186Z [RootInitializer] warn: Failed to create resource http://localhost:3000/index.html: Only Quad data is supported.
css_1                          | 2021-08-25T09:29:07.186Z [RootInitializer] info: Initialized root container with 0 resources.
css_1                          | 2021-08-25T09:29:07.186Z [BaseHttpServerFactory] info: Starting server at http://localhost:3000/
css_1                          | 2021-08-25T09:29:32.455Z [BaseHttpServerFactory] info: Received GET request for /
css_1                          | 2021-08-25T09:29:32.465Z [SparqlDataAccessor] info: Sending SPARQL CONSTRUCT query to http://my-sparql-endpoint/sparql: CONSTRUCT { ?s ?p ?o. }
css_1                          | WHERE { GRAPH <meta:http://localhost:3000/.acl> { ?s ?p ?o. } }
css_1                          | 2021-08-25T09:29:32.469Z [WebAclAuthorizer] error: No ACL document found for root container http://localhost:3000/
css_1                          | 2021-08-25T09:29:32.549Z [BaseHttpServerFactory] info: Received GET request for /.well_known/css/styles/main.css
css_1                          | 2021-08-25T09:29:32.553Z [BaseHttpServerFactory] info: Received GET request for /.well_known/css/images/solid.svg
css_1                          | 2021-08-25T09:29:32.678Z [BaseHttpServerFactory] info: Received GET request for /.well_known/css/fonts/raleway.woff2
css_1                          | 2021-08-25T09:29:32.735Z [BaseHttpServerFactory] info: Received GET request for /favicon.ico
css_1                          | 2021-08-25T09:29:45.786Z [BaseHttpServerFactory] info: Received GET request for /
css_1                          | 2021-08-25T09:29:45.793Z [SparqlDataAccessor] info: Sending SPARQL CONSTRUCT query to http://my-sparql-endpoint/sparql: CONSTRUCT { ?s ?p ?o. }
css_1                          | WHERE { GRAPH <meta:http://localhost:3000/.acl> { ?s ?p ?o. } }
css_1                          | 2021-08-25T09:29:45.797Z [WebAclAuthorizer] error: No ACL document found for root container http://localhost:3000/
css_1                          | 2021-08-25T09:29:45.854Z [BaseHttpServerFactory] info: Received GET request for /.well_known/css/styles/main.css
css_1                          | 2021-08-25T09:29:45.863Z [BaseHttpServerFactory] info: Received GET request for /.well_known/css/images/solid.svg
css_1                          | 2021-08-25T09:29:45.883Z [BaseHttpServerFactory] info: Received GET request for /favicon.ico
css_1                          | 2021-08-25T09:29:45.887Z [BaseHttpServerFactory] info: Received GET request for /.well_known/css/fonts/raleway.woff2

Is this addressable in config too or would it need code changes?

@joachimvh
Copy link
Author

I tested with a memory store instead of a SPARQL one since I didn't have an endpoint set up so that's on me for not checking. Problem is that the sparql store needs incoming data to be converted into quads (the sparql.json store config has an extra part for this). But we don't want this to happen for things that go to the file store (since the initial problem is that those json objects can't be converted). So this makes the solution a bit more complex: we want to add a new store that converts to quads AFTER the regex rules. I'll just copy the entire new config with this solution (only the end is changed):

{
  "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^1.0.0/components/context.jsonld",
  "import": [
    "files-scs:config/app/main/default.json",
    "files-scs:config/app/init/default.json",
    "files-scs:config/http/handler/default.json",
    "files-scs:config/http/middleware/websockets.json",
    "files-scs:config/http/server-factory/websockets.json",
    "files-scs:config/http/static/default.json",
    "files-scs:config/identity/email/default.json",
    "files-scs:config/identity/handler/default.json",
    "files-scs:config/identity/ownership/token.json",
    "files-scs:config/identity/pod/static.json",
    "files-scs:config/identity/registration/enabled.json",
    "files-scs:config/ldp/authentication/dpop-bearer.json",
    "files-scs:config/ldp/authorization/webacl.json",
    "files-scs:config/ldp/handler/default.json",
    "files-scs:config/ldp/metadata-parser/default.json",
    "files-scs:config/ldp/metadata-writer/default.json",
    "files-scs:config/ldp/permissions/acl.json",

    "files-scs:config/storage/key-value/resource-store.json",
    "files-scs:config/storage/middleware/default.json",
    "files-scs:config/util/auxiliary/acl.json",
    "files-scs:config/util/identifiers/suffix.json",
    "files-scs:config/util/index/default.json",
    "files-scs:config/util/logging/winston.json",
    "files-scs:config/util/representation-conversion/default.json",
    "files-scs:config/util/resource-locker/memory.json",
    "files-scs:config/util/variables/default.json",

    "files-scs:config/storage/backend/data-accessors/file.json",
    "files-scs:config/storage/backend/data-accessors/sparql-endpoint.json"
  ],
  "@graph": [
    {
      "comment": [
        "Differences from default sparql-endpoint.json:",
        " Using config/storage/middleware/default.json,",
        " Removed config/storage/backend/sparql.json import to replace with our own below.",
        " Add imports for specific DataAccessors.",
        " Config below is based on config/storage/backend/regex.json."
      ]
    },

    {
      "comment": "A more complex example with 3 different stores being routed to.",
      "@id": "urn:solid-server:default:ResourceStore_Backend",
      "@type": "RoutingResourceStore",
      "rule": { "@id": "urn:solid-server:default:RouterRule" }
    },

    {
      "comment": [
        "Configure routing to send internal data to file system and all other data to sparql store.",
        "Paths based on those found in config/storage/middleware/default.json"
      ],
      "@id": "urn:solid-server:default:RouterRule",
      "@type": "RegexRouterRule",
      "base": { "@id": "urn:solid-server:default:variable:baseUrl" },
      "storeMap": [
        {
          "comment": "Internal storage for locks",
          "RegexRouterRule:_storeMap_key": "^/locks/",
          "RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:FileResourceStore" }
        },
        {
          "comment": "Internal storage for IDP data",
          "RegexRouterRule:_storeMap_key": "^/idp/",
          "RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:FileResourceStore" }
        },
        {
          "comment": "Send everything else to the SPARQL store.",
          "RegexRouterRule:_storeMap_key": "^/(?!idp/|locks/).*",
          "RegexRouterRule:_storeMap_value": { "@id": "urn:solid-server:default:SparqlResourceStore" }
        }
      ]
    },

    {
      "@id": "urn:solid-server:default:FileResourceStore",
      "@type": "DataAccessorBasedStore",
      "identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" },
      "auxiliaryStrategy": { "@id": "urn:solid-server:default:AuxiliaryStrategy" },
      "accessor": { "@id": "urn:solid-server:default:FileDataAccessor" }
    },
    {
      "@id": "urn:solid-server:default:SparqlResourceStore",
      "@type": "RepresentationConvertingStore",
      "options_inConverter": { "@id": "urn:solid-server:default:RepresentationConverter" },
      "options_inType": "internal/quads",
      "source": {
        "@type": "DataAccessorBasedStore",
        "identifierStrategy": { "@id": "urn:solid-server:default:IdentifierStrategy" },
        "auxiliaryStrategy": { "@id": "urn:solid-server:default:AuxiliaryStrategy" },
        "accessor": { "@id": "urn:solid-server:default:SparqlDataAccessor" }
      }
    }
  ]
}

This should fix the issue. Again I didn't test though, so if there's another problem let me know and I'll actually set up a SPARQL endpoint to test locally 😄

@ch1ch0gz
Copy link

Hi,
I have just tested your solution and it does not start the local file system.
I am running:
community-solid-server --baseUrl https://dev.ideniox.com -c @css:config/sparql-endpoint.json -f /var/www/css -s http://dev.ideniox.com:8890/sparql

and it is throwing the below error in the server when trying to log in
"No ACL document found for root container"

I checked on /var/www/css and in fact it exists an .acl file. I also tried to replace this .acl to the one store in templates and it did not work either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment