-
Notifications
You must be signed in to change notification settings - Fork 1
/
sparql11-subscribe.html
420 lines (381 loc) · 13.1 KB
/
sparql11-subscribe.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>SPARQL 1.1 Subscribe Language</title>
<!-- RESPEC CONFIGURATION -->
<script src="https://www.w3.org/Tools/respec/respec-w3c-common"
class="remove"></script>
<script class='remove'>
var respecConfig = {
// document info
specStatus : "unofficial",
shortName : "sparql11-subscribe",
copyrightStart : "2017",
edDraftURI : "https://vaimee.org/TR/sparql11-subscribe.html",
extraCSS : [ "css/respec.css" ],
// editors
editors : [{
name : "Luca Roffia",
mailto : "luca.roffia@unibo.it",
company: "University of Bologna",
companyURL: "https://www.unibo.it/sitoweb/luca.roffia/en"
} ],
formerEditors: [{
name : "Cristiano Aguzzi",
mailto : "cristiano.aguzzi@unibo.it"
}, {
name : "Francesco Antoniazzi",
mailto : "francesco.antoniazzi@unibo.it"
},
{
name : "Fabio Viola",
mailto : "fabio.viola@unibo.it"
} ],
// WG
wg : "Dynamic Linked Data and Web of Things working group @ ARCES",
wgURI : "https://site.unibo.it/wot/en",
};
</script>
</head>
<body>
<!-- ABSTRACT -->
<section id="abstract">
This document describes the SPARQL 1.1 Subscribe Language used within
the <a href="http://vaimee.org/TR/sepa.html">SPARQL Event
Processing Architecture</a> to describe subscription requests and
notifications.
</section>
<!-- STATUS OF THIS DOCUMENT -->
<section id="sotd">This is a first draft.</section>
<!-- INTRODUCTION -->
<section id="intro">
<h2>Introduction</h2>
<p>
The SPARQL 1.1 Subscribe Language defines the content of the
following elements: primitives (i.e., <i>subscribe</i> and <i>unsubscribe</i>)
and <i>notifications</i>. Every SEPA implementation MUST provide a
JSON serialization [[!RFC7159]] of the all these elements. Other
kinds of serialization formats MAY be provided. This document refers
to the REQUIRED JSON serialization.
</p>
<p>The SPARQL 1.1 Subscribe Language is framed within W3C
Recommendations as shown in the following figure.</p>
<img src="media/sparql11seprotocol.jpg">
<p>Fig. 1 - The SPARQL Event Processing Architecture (SEPA)</p>
<section id="conventions">
<h3>Document conventions</h3>
When this document uses the words MUST, MUST NOT, SHOULD, SHOULD NOT,
MAY and RECOMMENDED, and the words appear as emphasized text, they
must be interpreted as described in RFC 2119 [[!RFC2119]].
</section>
<section id="terms">
<h3>Terminology</h3>
<dl>
<dt>SEPA</dt>
<dd>
<a href="http://vaimee.org/TR/sepa.html">SPARQL Event
Processing Architecture</a>
</dd>
<dt>SEPA broker</dt>
<dd>
The server component of the SEPA. It implements the
publish-subscribe mechanisms and algorithms. Clients interact with
a SEPA broker with the <a
href="http://vaimee.org/TR/sparql11-se-protocol.html">SPARQL
1.1 SE Protocol</a>
</dd>
<dt>SPARQL 1.1 Subscribe Language</dt>
<dd>
The <a href="http://vaimee.org/TR/sparql11-subscribe.html">subscription
language</a> introduced by the SEPA
</dd>
<dt>SPARQL 1.1 SE Protocol</dt>
<dd>
The <a
href="http://vaimee.org/TR/sparql11-se-protocol.html">protocol</a>
implemented by a SEPA broker and defined in this document
</dd>
<dt>SPARQL 1.1 Update Language</dt>
<dd>As defined by [[sparql11-update]]</dd>
<dt>SPARQL 1.1 Query Language</dt>
<dd>As defined by [[sparql11-query]]</dd>
</dl>
</section>
</section>
<section id="Subscribe">
<h2>Subscribe</h2>
<section id="SubscribeRequest">
<h3>Request</h3>
A subscribe primitive is expressed as shown in the following example:
<pre class="example" title="Subscribe request">
{"subscribe" : {
"sparql" : "select * where {?vaimee ?deda ?didi}",
"authorization" : "Bearer xabtQWoH8RJJk1FyKJ78J8h8i2PcWmAugfJ4J6nMd+1jVSoiipV4Pcv8bH+8wJLJ2yRaVage8/TzdZJiz2jdRP8bhkuNzFhGx6N1/1mgmvfKihLheMmcU0pLj5uKOYWFb+TB98n1IpNO4G69lia2YoR15LScBzibBPpmKWF+XAr5TeDDHDZQK4N3VBS/e3tFL/yOhkfC9Mw45s3mz83oyeoFFePUX8MQIuqd3TIcjOhoPgYWd0E+L/EN5wItL5/n78pX/8mVZcpxdyNNqr3bVvrCi0I84mIAefwQ0GyPxFhUHu9PtVNQnXchZuFgppX/YDtOesZSxfIoffUpHFPBY3u4FRIYwpSZX96Knnp0J22RQm+0l8yobik3z6jftw0jbF5+/YC6PnfZT3Wzb6PRJPuVkDzpo+BTC9eKx87GEj8VjtfXjbYRTeZNumD+59wL5kV/OrntNqNQD+IzAYoIZk4rlRbNouNnvT0laEhV012tSD1uAfNUxAlZjSbSMTp5bPNp7PoutMr5q6zPYfAC1PTKnVdkD1CDNqZnhB838WDeISfVzXsf7dsZ0+SkNPtx2kMUYCOYsxNJxyzza3lmaCuvxfnDT3g5F41/p/zX1tXYy6emVfdOWSkJNm1z0FJB/ZIUES0WAA5UEM3kejND++vvIQr38ar72HdFzRvP2V29CsaE5PMRRRZIE5ru9Zwgdb5lfMdwDi4sZkQdNRGHiOfRCT9D92mFVps6s6kv7HKojx05R9WKMDG8bEmSgMYSYQlQzLm93Ardw/hpDoB1/DfNRxbc/GVNZEVOoRVMye8/vICZtxvVeKmu4QawWKSBtrXelWUT8AHTG6v/c88pZjtJWDzy6YIIXLDQ2eJPu30mt3gLfS2ukIV4Tl5Oqu3T1IIghmNgek8vwWNeuG/JGeKrfUp6X6mMH9hdmj5+naOIr8V5rUKCjXnlWLAsrGdOvV8vuYYbx2IFQScZQJD/sTKj3gs6yeYpOwQ2iEs9asA=",
"alias" : "All",
"default-graph-uri" : ["http://example/uri_of_the_default_graph"],
"named-graph-uri" : ["http://example/uri_of_a_named_graph"]
}}</pre>
<p>
The value of the
<code>sparql</code>
member MUST be a SPARQL 1.1 Query [[sparql11-query]], the value of
the
<code>authorization</code>
member (if present) MUST be a
<code>Bearer</code>
JSON Web Token [[!RFC7519]] and the value of the
<code>alias</code>
member (if present ) is a string representing a friendly name of the
subscription.
</p>
<p>The first member is REQUIRED, while all the other are
optional.</p>
<p>
The
<code>authorization</code>
member is only REQUIRED for secure operations.
</p>
<p>
The value of the
<code>alias</code>
member, if present, it will be included in the subscribe response.
The use of the
<code>alias</code>
member is RECOMMENDED if the SEPA client sends multiple subscribe
requests. If needed, the SEPA client MAY store the subscription
alias and link it with the subscription URI [[!RFC3986]] contained
in the subscribe response message.
</p>
<p>
The value of the
<code>default-graph-uri</code>
and of the
<code>named-graph-uri</code>
(if present) have the same meaning and content of the corresponding
parameters defined in the SPARQL 1.1 Protocol [[sparql11-protocol]]
</p>
</section>
<section id="SubscribeResponse">
<h2>Response</h2>
<p>If the subscribe request is successfully processed, every SEPA
implementation MUST respond with a message like the following:</p>
<pre class="example" title="Subscribe response">
{"notification":{
"spuid" : "sepa://subscription/0d057ca5-cc10-4e8a-a5d9-59d7b36f71d6",
"sequence" : 0,
"alias" : "All",
"addedResults" :{
"head": { "vars": ["vaimee","deda","didi"] },
"results": {
"bindings": [{
"vaimee": {"type": "uri", "value" : "http://wot.arces.unibo.it/example#Subject"},
"deda": {"type": "uri", "value": "http://wot.arces.unibo.it/example#Predicate"},
"didi": {"type": "literal","value": "ვაიმეე"} }]}},
"removedResults":{}}}
</pre>
<p>
The value of the
<code>spuid</code>
member is an URI [[!RFC3986]], while the
<code>sequence</code>
member is a number and it will be always 0. Both members MUST be
present. The
<code>sequence</code>
member will be incremented by one on each following <a
href="#Notification">notification</a>.
</p>
<p>
The
<code>alias</code>
member (if present) has the same value of the corresponding
<code>alias</code>
member of the subscribe request.
</p>
<p>
Eventually, the value of the
<code>addedResults</code>
member corresponds to the results of the SPARQL query according to
the SPARQL 1.1 Query Results JSON format [[sparql11-results-json]],
while the value of the
<code>removedResults</code>
will be always an empty object.
</p>
<p>
In case of error, it is RECOMMENDED to reply as shown <a
href='#ErrorResponses'>here</a>
</p>
</section>
</section>
<section id="Unsubscribe">
<h2>Unsubscribe</h2>
<section id="UnsubscribeRequest">
<h3>Request</h3>
<p>A client MAY request to remove a specific subscription. This
can be done by sending a message like the following:
<p>
<pre class="example" title="Unsubscribe request">
{"unsubscribe":{
"spuid":"sepa://subscription/0d057ca5-cc10-4e8a-a5d9-59d7b36f71d6",
"authorization" :"Bearer eyJhbGciOiJIUzI....ONFh7HgQ"}}
</pre>
<p>
The
<code>spuid</code>
member value is the subscription URI [[!RFC3986]] provided by the
subscribe response message.
</p>
<p>
The value of the
<code>authorization</code>
member (if present) MUST be a
<code>Bearer</code>
JSON Web Token [[!RFC7519]].
</p>
<p>The former member is REQUIRED, while the latter is only
REQUIRED for secure primitives.</p>
</section>
<section id="UnsubscribeResponse">
<h3>Response</h3>
<p>A SEPA broker implementation MUST reply to a unsubscribe
request with a message like the following:</p>
<pre class="example" title="Unsubscribe response">
{"unsubscribed":{
"spuid":"sepa://subscription/0d057ca5-cc10-4e8a-a5d9-59d7b36f71d6"}}</pre>
<p>
In case of error, it is RECOMMENDED to reply as shown <a
href='#ErrorResponses'>here</a>
</p>
</section>
</section>
<section id="Notification">
<h3>Notification</h3>
<p>An example of a content notification follows:</p>
<pre class="example" title="Notification">
{"notification":{
"spuid" : "sepa://subscription/0d057ca5-cc10-4e8a-a5d9-59d7b36f71d6",
"sequence" : 1,
"alias" : "All",
"addedResults" :{
"head": { "vars": ["vaimee","deda","didi"] },
"results": {
"bindings": [{
"didi": {"type": "literal","value": "ზბკლვვ"} }]}},
"removedResults":{
"head": { "vars": ["vaimee","deda","didi"] },
"results": {
"bindings": [{
"didi": {"type": "literal","value": "ვაიმეე"} }]}}}
</pre>
<p>
The value of
<code>spuid</code>
member is the URI [[!RFC3986]] of the subscription who generates the
notification.
</p>
<p>
The value of the
<code>sequence</code>
member is a number (incremented by one at every new notification of
the same SPUID).
</p>
<p>
The
<code>addedResults</code>
and
<code>removedResults</code>
are two JSON objects whose content conform with the <a
href="https://www.w3.org/TR/sparql11-results-json//">SPARQL 1.1
Query Results JSON format </a>.
</p>
</section>
<!--
<section id="Ping">
<h3>Ping</h3>
<p>The default content of a ping message follows:</p>
<pre class="example" title="Ping"> {"ping":"2017-12-05 08:51:54.919","spuid":"sepa://spuid/558a503d-1d7e-45fd-8bc8-4d5f9b7dd7ac"}</pre>
<p>
The
<code>ping</code>
member MUST be present and its value is the UTC time on the
SEPA broker represented as described in [[!RFC3339]].
</p>
</section>
-->
<section id="ErrorResponses">
<h3>Error responses</h3>
<p>In case of error, a SEPA broker implementation SHOULD reply
with a JSON object like the following:</p>
<pre class="example" title="Error response">
{
"error":"unauthorized_client",
"error_description" : "Client is not authorized",
"status_code" : 401
}
</pre>
<p>
The
<code>error</code>
member is a string representing the error. Refer to [[!RFC6749]] for
all OAuth related errors. Otherwise it would be a SPARQL 1.1 SE
Protocol specific error string.
</p>
<p>
The
<code>error_description</code>
member is optional and if present it provides a human readable
description of the error.
</p>
<p>
The
<code>status_code</code>
member is an integer representing the error. The use of use of HTTP
status codes [[!RFC2616]] is RECOMMENDED. As reference, a list of
common HTTP status codes follows. Implementation specific error codes
MAY also be used.
<pre>
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Request Entity Too Large
414 Request-URI Too Long
415 Unsupported Media Type
416 Requested Range Not Satisfiable
417 Expectation Failed
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported
</pre>
</section>
<!-- APPENDIX -->
<section class="appendix">
<!-- ACKNOWLEDGEMENTS -->
<h2>Acknowledgements</h2>
<p>
Editors would like to thanks the <a
href="http://www.arces.unibo.it/en">Advanced Research Center on
Electronic Systems "Ercole De Castro" (ARCES)</a> and the <a
href="http://www.cse.unibo.it/en/index.html">Computer Science
and Engineering Department (DISI)</a> of the <a
href="http://http://www.unibo.it/en/homepage">University of
Bologna</a>, the <a href="https://ec.europa.eu/commission/index_en">European
Commission</a> and all the partners of the <a
href="https://artemis-ia.eu/">ARTEMIS</a> projects who inspired the
SPARQL Event Processing Architecture (SEPA).
</p>
</section>
</section>
</body>
</html>