Coverage report: /development/source/library/org/datagraph/spocq-shard/src/spocq-server/resources.lisp

KindCoveredAll%
expression014 0.0
branch00nil
Key
Not instrumented
Conditionalized out
Executed
Not executed
 
Both branches taken
One branch taken
Neither branch taken
1
 ;;; -*- Mode: lisp; Syntax: ansi-common-lisp; Base: 10; Package: org.datagraph.spocq.server.implementation; -*-
2
 ;;;  Copyright 2013 [james anderson](mailto:james.anderson@setf.de) All Rights Reserved
3
 
4
 (in-package :org.datagraph.spocq.server.implementation)
5
 
6
 (:documentation "concrete request resources"
7
 
8
 "There are three distinct realms:
9
 admin :        accounts/:account/repositories/:repository/...
10
 graph store :  :account/:repository/...
11
   with paths for service, sparql, ldp and ldf
12
 sesame :       :account/repositories/:repository/...
13
   these are deprecated.
14
   the paths and respons efunctions remain, but they are reflected here only and
15
   not in the nginx locations.
16
 
17
 
18
 
19
       https://:host
20
         /:account
21
           /protocol            : protocol version (GET)
22
           /:repository         : query evaluation and administration tasks on 
23
                                a repository (GET/POST/DELETE)
24
             /contexts          : context overview (GET)
25
             /namespaces        : overview of namespace definitions (GET/DELETE)
26
               /:prefix         : namespace-prefix definition (GET/PUT/DELETE)
27
             /rdf-graphs        : named graphs overview (GET)
28
               /service         : Graph Store operations on indirectly referenced named graphs 
29
                                  in repository (GET/PUT/POST/DELETE)
30
                                  includes the query argument graph=${STORE_IGRAPH}
31
               /:relativeGraph  : Graph Store operations on directly referenced named graphs 
32
                                  in repository (GET/PUT/POST/DELETE)
33
             /size              : #statements in repository (GET)
34
             /statements        : repository statements (GET/POST/PUT/DELETE)
35
           /:repository?default                                     : the default graph
36
           /:repository?graph=:indirectGraph                        : an arbitrary indirect graph
37
                                graph=urn:dydra:service-description : the repository SPARQL endpoint service description
38
           /:repository/:relativeGraph                              : graph relative to the repository base url
39
           /:repository/ldf                                         : linked data fragment endpoint
40
           /:repository/ldp                                         : linked data platform endpoint
41
           /:repository/service?default                             : graph store endpoint targeting the default graph
42
           /:repository/service?graph=:indirectGraph                : graph store endpoint targeting a specific graph
43
           /:repository/sparql                                      : sparql endpoint
44
           /:repository/:view                                       : view api
45
         /system : this is interposed above accounts to isolate all non-content and to avoid rails' paths
46
           /accounts
47
            /:account
48
              /authorization        : access rights,
49
              /configuration        : namespace, provenance, describe, default data-set and dynamic binding settings
50
                /namespaces         : just prefix bindings
51
              /profile              : name, homepage, email
52
              /repositories
53
                /:repository
54
                  /profile             : name, homepage, summary, description, and license url
55
                  /configuration       : access rights, namespace, provenance, describe, default data-set and dynamic binding settings
56
                  /service_description : the repository SPARQL endpoint service description
57
                  /service_history     : the repository query statistics
58
                  /service_statistics  : the repository query statistics
59
                  /views
60
                    /:view
61
           /users
62
             /:user
63
               /profile             : name, homepage, email
64
 ")
65
 
66
 (defclass :|/| (anonymous-resource) ;; for websocket handshake w/o auth
67
   ())
68
 
69
 (defclass |/ws| (anonymous-resource) ;; for websocket handshake w/o auth
70
   ())
71
 
72
 (defclass |/favicon.ico| (anonymous-resource) 
73
   ((mime:mime-type :initform mime:image/x-icon
74
                    :allocation :class)))
75
 
76
 (defclass |/:account| (account-resource)        ; eventually the account page
77
   ()
78
   (:metaclass spocq.i::persistent-class))
79
 
80
 (defclass |/:account/protocol| (|/:account|)
81
   ()
82
   (:metaclass spocq.i::persistent-class))
83
 
84
 (defclass |/:account/repositories| (|/:account|)
85
   ()
86
   (:metaclass spocq.i::persistent-class))
87
 
88
 (defclass |/:account/repositories/:repository| (query-resource repository-resource)
89
   ()
90
   (:metaclass spocq.i::persistent-class)
91
   (:documentation
92
    "Combine repository-resource slots with query-resource behavior.
93
     In particular the autorization protocol must permit all methods and delay constraints until
94
     the query form is known."))
95
 
96
 (defclass |/:account/repositories/:repository/contexts| (|/:account/repositories/:repository|)
97
   ()
98
   (:metaclass spocq.i::persistent-class))
99
 
100
 (defclass |/:account/repositories/:repository/namespaces| (|/:account/repositories/:repository|)
101
   ()
102
   (:metaclass spocq.i::persistent-class))
103
 
104
 (defclass |/:account/repositories/:repository/namespaces/:prefix| (|/:account/repositories/:repository/namespaces|
105
                                                                    namespace-resource)
106
   ()
107
   (:metaclass spocq.i::persistent-class))
108
 
109
 (defclass |/:account/repositories/:repository/rdf-graphs| (|/:account/repositories/:repository|
110
                                                            graph-resource)
111
   ()
112
   (:metaclass spocq.i::persistent-class))
113
 
114
 (defclass |/:account/repositories/:repository/rdf-graphs/service| (|/:account/repositories/:repository/rdf-graphs|)
115
   ;; inherits from /:account/repositories/:repository/rdf-graphs in order to combine
116
   ;; decoding implementation
117
   ()
118
   (:metaclass spocq.i::persistent-class))
119
 
120
 (defclass |/:account/repositories/:repository/rdf-graphs/:graph| (|/:account/repositories/:repository/rdf-graphs|)
121
   ()
122
   (:metaclass spocq.i::persistent-class))
123
 
124
 (defclass |/:account/repositories/:repository/size| (|/:account/repositories/:repository|)
125
   ()
126
   (:metaclass spocq.i::persistent-class))
127
 
128
 (defclass |/:account/repositories/:repository/statements| (|/:account/repositories/:repository| 
129
                                                            graph-resource)
130
   ()
131
   (:metaclass spocq.i::persistent-class))
132
 
133
 (defclass |/:account/:repository| (query-resource repository-resource)         ; not an account resource
134
   ()
135
   (:metaclass spocq.i::persistent-class)
136
   (:documentation
137
    "Combine repository-resource slots with query-resource behavior.
138
     In particular the autorization protocol must permit all methods and delay constraints until
139
     the query form is known."))
140
 
141
 (defclass |/:account/:repository/sparql| (|/:account/:repository|)
142
   ((mime:mime-type :initform (mime:mime-type "application/sparql-results+json; charset=utf-8")
143
                    :allocation :class))
144
   (:documentation "the sparql endpoint for a given repository")
145
   (:metaclass spocq.i::persistent-class))
146
 
147
 (defclass |/:account/:repository/git/:git-path*| (|/:account/:repository|)
148
   ((git-path
149
     :initarg :path :accessor resource-git-path)
150
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
151
                    :allocation :class))
152
   (:documentation "the git endpoint for a given repository")
153
   (:metaclass spocq.i::persistent-class))
154
 
155
 (defclass |/:account/:repository/ldf| (|/:account/:repository|)
156
   ((mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
157
                    :allocation :class))
158
   (:documentation "the linked data fragment endpoint for a given repository")
159
   (:metaclass spocq.i::persistent-class))
160
 
161
 (defclass |/:account/:repository/tpf| (|/:account/:repository|)
162
   ((mime:mime-type :initform (mime:mime-type "application/n-quads; charset=utf-8")
163
                    :allocation :class))
164
   (:documentation "the linked data fragment endpoint for a given repository")
165
   (:metaclass spocq.i::persistent-class))
166
 
167
 
168
 (defclass |/:account/:repository/service| (graph-store-service-resource |/:account/:repository|)
169
   ((mime:mime-type :initform (mime:mime-type "application/n-quads; charset=utf-8")
170
                    :allocation :class))
171
   (:documentation "the graph store protocol endpoint for a given repository")
172
   (:metaclass spocq.i::persistent-class))
173
 
174
 (defclass |/:account/:repository/ldp| (graph-store-service-resource graph-store-binary-resource |/:account/:repository|)
175
   ((mime:mime-type :initform (mime:mime-type "text/turtle; charset=utf-8")
176
                    :allocation :class))
177
   (:documentation "the linked data platform store protocol endpoint for a given repository,
178
    to be accompanied by an indirect identifer for the target resource.
179
    it mixes in binary decode _after_ service media types")
180
   (:metaclass spocq.i::persistent-class))
181
 
182
 (defmethod initialize-instance ((instance |/:account/:repository/ldp|) &rest initargs
183
                                 &key (request (http:request))
184
                                 (resource (http:request-query-argument request "resource"))
185
                                 &allow-other-keys)
186
   (apply #'call-next-method instance
187
          (if resource
188
              (list* :graph resource initargs)
189
              initargs)))
190
 
191
 (defclass |/:account/:repository/:graph| (direct-graph-resource graph-store-service-resource |/:account/:repository|)
192
   ((mime:mime-type :initform (mime:mime-type "application/sparql-results+json; charset=utf-8")
193
                    :allocation :class))
194
   (:documentation "the graph store protocol endpoint for a given repository w/ a direct graph.
195
    for a sparql protocol request, this names a view
196
    NYI, but holding the place.
197
    ")
198
   (:metaclass spocq.i::persistent-class))
199
 
200
 (defclass |/:account/:repository/:view.:type| (direct-graph-resource graph-store-service-resource |/:account/:repository|)
201
   ((view :initform "" :initarg :view
202
          :reader resource-view)
203
    (type :initform "json" :initarg :type
204
          :reader resource-type)
205
    (mime:mime-type :initform (mime:mime-type "application/sparql-results+json; charset=utf-8")
206
                    :allocation :class))
207
   (:documentation "the graph store protocol endpoint for a given repository w/ a view.")
208
   (:metaclass spocq.i::persistent-class))
209
 
210
 (defclass |/:account/:repository/:graph/:element*| (|/:account/:repository/:graph|)
211
   ((elements
212
     :initarg :element :initarg :elements :accessor resource-elements)
213
    (mime:mime-type :initform (mime:mime-type "application/n-quads; charset=utf-8")
214
                    :allocation :class))
215
   (:documentation "the graph store protocol endpoint for a given repository w/ an extended direct graph.
216
    for a sparql protocol request, this names a view.
217
    for a ldp request this combines the complonents to yield the full path ( deprecated in favor of an indirect graph)
218
    ")
219
   (:metaclass spocq.i::persistent-class))
220
 
221
 ;;; metadata
222
 
223
 
224
 (defclass |/system| (administrator-resource metadata-resource account-resource)
225
   ()
226
   (:default-initargs :account "admin"))
227
 
228
 (defclass |/system/accounts| (administrator-resource metadata-resource account-resource)
229
   ())
230
   
231
 (defclass |/system/accounts/:account| (metadata-resource account-resource)
232
   ()
233
   (:metaclass spocq.i::persistent-class))
234
 
235
 (defclass |/system/accounts/:account/authorization| (authorization-account-resource)
236
   ()
237
   (:metaclass spocq.i::persistent-class))
238
 
239
 (defclass |/system/accounts/:account/configuration| (configuration-account-resource)
240
   ()
241
   (:metaclass spocq.i::persistent-class))
242
 
243
 (defclass |/system/accounts/:account/configuration/:property| (configuration-account-resource)
244
   ()
245
   (:metaclass spocq.i::persistent-class))
246
 
247
 (defclass |/system/accounts/:account/profile| (profile-account-resource)
248
   ()
249
   (:metaclass spocq.i::persistent-class))
250
 
251
 (defclass |/system/accounts/:account/repositories| (metadata-resource repository-resource)
252
   ())
253
 
254
 (defclass |/system/accounts/:account/repositories/:repository| (metadata-resource repository-resource)
255
   ())
256
 
257
 (defclass |/system/accounts/:account/repositories/:repository/authorization| (authorization-repository-resource)
258
   ()
259
   (:metaclass spocq.i::persistent-class))
260
 
261
 (defclass |/system/accounts/:account/repositories/:repository/configuration| (configuration-repository-resource)
262
   ()
263
   (:metaclass spocq.i::persistent-class))
264
 
265
 (defclass |/system/accounts/:account/repositories/:repository/configuration/:property| (configuration-repository-resource)
266
   ;; does not specialize /*/repositories/*, as that is the sparql endpoint
267
   ()
268
   (:metaclass spocq.i::persistent-class)
269
   (:documentation
270
     "Provide a resource which permits to specify an individual configuration property,
271
      for example, the namespace prefix bindings."))
272
 
273
 (defclass |/system/accounts/:account/repositories/:repository/views/:view| (|/:account/:repository|)
274
   ((view :initform "" :initarg :view
275
          :reader resource-view))
276
   (:metaclass spocq.i::persistent-class)
277
   (:documentation "the view management endpoint"))
278
 
279
 (defclass |/system/accounts/:account/repositories/:repository/views| (|/:account/:repository|)
280
   ()
281
   (:metaclass spocq.i::persistent-class)
282
   (:documentation "the view list endpoint"))
283
 
284
 (defclass |/system/accounts/:account/repositories/:repository/profile| (profile-repository-resource)
285
   ;; does not specialize /*/repositories/*, as that is the sparql endpoint
286
   ()
287
   (:metaclass spocq.i::persistent-class))
288
 
289
 (defclass |/system/accounts/:account/repositories/:repository/revisions| (repository-resource)
290
   ()
291
   (:metaclass spocq.i::persistent-class))
292
 
293
 (defclass |/system/accounts/:account/repositories/:repository/service_description| (repository-resource)
294
   ()
295
   (:metaclass spocq.i::persistent-class))
296
 
297
 (defclass |/system/accounts/:account/repositories/:repository/service_history| (anonymous-resource repository-resource)
298
   ()
299
   (:metaclass spocq.i::persistent-class))
300
 
301
 (defclass |/system/accounts/:account/repositories/:repository/service_statistics| (anonymous-resource repository-resource)
302
   ()
303
   (:metaclass spocq.i::persistent-class))
304
 
305
 (defclass |/system/accounts/:account/repositories/:repository/revisions| (repository-resource)
306
   ()
307
   (:metaclass spocq.i::persistent-class))
308
 
309
 (defclass |/system/accounts/:account/services/:host/:path*| (service-repository-resource)
310
   ()
311
   (:metaclass spocq.i::persistent-class))
312
 
313
 
314
 (defclass |/system/configuration.:type| (|/system|)
315
   ((type :initform "srj" :initarg :type
316
          :reader resource-type)))
317
 
318
 
319
 (defclass  |/system/service_history/imports| (|/system| authorized-resource)
320
   ())
321
 (defclass  |/system/service_history/imports.:type| (|/system/history/imports|)
322
   ((type :initform "json" :initarg :type
323
          :reader resource-type)
324
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
325
                    :allocation :class)))
326
 
327
 (defclass  |/system/service_history/queries| (|/system| authorized-resource)
328
   ())
329
 (defclass  |/system/service_history/queries/:account/:query-hash| (|/system/history/queries| account-resource)
330
   ((query-hash :initarg :query-hash :initform nil
331
          :reader resource-query-hash)))
332
 (defclass  |/system/service_history/queries.:type| (|/system/history/queries|)
333
   ((type :initform "json" :initarg :type
334
          :reader resource-type)
335
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
336
                    :allocation :class)))
337
 
338
 (defclass  |/system/service_statistics/queries| (|/system| authorized-resource)
339
   ())
340
 (defclass  |/system/service_statistics/queries/:account/:query-hash| (|/system/history/queries| account-resource)
341
   ((query-hash :initarg :query-hash :initform nil
342
          :reader resource-query-hash)))
343
 (defclass  |/system/service_statistics/queries.:type| (|/system/history/queries|)
344
   ((type :initform "json" :initarg :type
345
          :reader resource-type)
346
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
347
                    :allocation :class)))
348
 
349
 (defclass |/system/service_history/transactions| (|/system| system-pathname-resource)
350
   ()
351
   (:default-initargs :pathname #p"/var/log/dydra/commits.log"))
352
 (defclass  |/system/service_history/transactions.:type| (|/system/history/transactions|)
353
   ((type :initform "json" :initarg :type
354
          :reader resource-type)
355
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
356
                    :allocation :class)))
357
 
358
 (defclass |/system/service_statistics/transactions| (|/system| system-pathname-resource)
359
   ()
360
   (:default-initargs :pathname #p"/var/log/dydra/commits.log"))
361
 (defclass  |/system/service_statistics/transactions.:type| (|/system/history/transactions|)
362
   ((type :initform "json" :initarg :type
363
          :reader resource-type)
364
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
365
                    :allocation :class)))
366
 
367
 (defclass  |/system/status/accounts| (|/system| authorized-resource)
368
   ())
369
 (defclass  |/system/status/accounts.:type| (|/system/manage/accounts|)
370
   ((type :initform "json" :initarg :type
371
          :reader resource-type)
372
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
373
                    :allocation :class)))
374
 
375
 (defclass  |/system/status/repositories| (|/system| authorized-resource)
376
   ())
377
 (defclass  |/system/status/repositories.:type| (|/system/manage/repositories|)
378
   ((type :initform "json" :initarg :type
379
          :reader resource-type)
380
    (mime:mime-type :initform (mime:mime-type "application/json; charset=utf-8")
381
                    :allocation :class)))
382
 
383
 
384
 (defclass |/system/queries| (|/system|)
385
   ())
386
 
387
 (defclass |/system/threads| (|/system|)
388
   ())
389
 
390
 (defclass |/system/status| (anonymous-resource |/system|)
391
   ())
392
 
393
 (defclass |/system/status.:type| (|/system|)
394
   ((type :initform "srj" :initarg :type
395
          :reader resource-type)))
396
 
397
 (defclass |/admin/status.:type| (|/system|)
398
   ((type :initform "srj" :initarg :type
399
          :reader resource-type)))
400
 
401
 (defclass |/:user| (user-resource)
402
   ()
403
   (:metaclass spocq.i::persistent-class))
404
 
405
 (defclass |/system/users/:user/profile| (|/:user|)
406
   ()
407
   (:metaclass spocq.i::persistent-class))
408
 
409