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" }
}
]
}
@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