No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0099.xml 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM "xep.ent">
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>IQ Query Action Protocol</title>
  10. <abstract>Standardizes behavior of &IQ; &QUERY; actions for generic query behavior.</abstract>
  11. &LEGALNOTICE;
  12. <number>0099</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies/>
  17. <supersedes/>
  18. <supersededby/>
  19. <shortname>Not yet assigned</shortname>
  20. <author>
  21. <firstname>Iain</firstname>
  22. <surname>Shigeoka</surname>
  23. <email>iain@jivesoftware.com</email>
  24. <jid>smirk@jabber.com</jid>
  25. </author>
  26. <revision>
  27. <version>0.1</version>
  28. <date>2003-06-25</date>
  29. <initials>iss</initials>
  30. <remark>Initial version.</remark>
  31. </revision>
  32. </header>
  33. <section1 topic='Introduction'>
  34. <p>There is a need for consistent query behavior amongst XMPP &IQ; protocols. Currently
  35. each protocol invents it's own, slightly different behavior for conducting
  36. query behavior to create, read, update, and delete (CRUD) recipient node data. This document defines a generic
  37. query acton protocol to standardize behavior across &IQ; protocols. In addition, we hope
  38. this standard will make other protocols easier to understand and implement by using a common
  39. core protocol.</p>
  40. </section1>
  41. <section1 topic='&QUERY; Action Protocol'>
  42. <section2 topic='Description'>
  43. <p>The existing XMPP core protocol defines
  44. four &IQ; types (get, set, result, and error). Unfortunately, these
  45. four types don't include a 'delete' type, and the 'set' type must do double duty for
  46. 'create' and 'update'. Many protocols can benefit from a clear separation of create
  47. and update paralleling other query languages such as SQL.</p>
  48. <p>Protocols complying with the &QUERY; action protocol use &IQ; 'set' to initiate
  49. all request-response interactions. The particular action to be taken MUST be set as an "action" attribute
  50. in the &IQ; &QUERY; sub-element. The action attribute MUST have a value of 'create', 'read',
  51. 'update', or 'delete'. Responses use the standard &IQ; 'result' and 'error' types.
  52. For backward compatibility, an &IQ; 'get' query is treated as equivalent to an &IQ; 'set'
  53. query with action of 'read'. Action protocols may require all or just a subset of these
  54. actions depending on the desired outcome.</p>
  55. <p>In addition to the action attribute an optional "strict" attribute may be set in the &IQ; &QUERY;
  56. sub-element. The only valid values for strict is "true" or "false" (case sensitive).
  57. The strict behavior of actions causes more errors to be returned which tends to make
  58. protocols more robust but also more complex. Action protocols MUST define the default value of
  59. the "strict" attribute in the context of that protocol. In addition, some protocols may
  60. not wish to allow changing the strict default, so action protocols MUST declare
  61. whether the strict behavior of the protocol may be set in the &IQ; &QUERY; sub-element.</p>
  62. </section2>
  63. <section2 topic='Actions'>
  64. <table caption='Description of Acceptable &QUERY; Actions'>
  65. <tr><td>create</td><td>Creates/inserts new data on the recipient node.</td></tr>
  66. <tr><td>read</td><td>Retrieves data from the recipient node.</td></tr>
  67. <tr><td>update</td><td>Updates existing data on the recipient node.</td></tr>
  68. <tr><td>delete</td><td>Deletes existing data on the recipient node.</td></tr>
  69. </table>
  70. </section2>
  71. <section2 topic='Elements'>
  72. <p>The root element is query which is in a namespace defining the
  73. protocol in use. The query element MUST have
  74. an attribute named 'action' with values given in the previous table.</p>
  75. </section2>
  76. <section2 topic='Error Codes'>
  77. <p>The following error codes apply to all action codes.</p>
  78. <table caption='Error Codes used by Action Protocols'>
  79. <tr>
  80. <th>Code</th><th>Text</th><th>Description</th>
  81. </tr>
  82. <tr>
  83. <td>406</td><td>Not Acceptable</td><td>The IQ query contents are not properly formatted for the action protocol.</td>
  84. </tr>
  85. <tr>
  86. <td>503</td><td>Service Unavailable</td><td>The IQ query is sent to a JID that cannot handle the query.</td>
  87. </tr>
  88. </table>
  89. </section2>
  90. </section1>
  91. <section1 topic='Create Action'>
  92. <section2 topic='Description'>
  93. <p>The create action inserts new data on the recipient node. If the strict attribute is
  94. 'true' the create action fails if colliding data already exists on the recipient node. If the strict
  95. attribute is false, the create action will insert new data on the recipient node overwriting
  96. existing colliding data if it exists (e.g. equivalent to update).</p>
  97. </section2>
  98. <section2 topic='Error Codes'>
  99. <table caption='Error Codes used by Create Action'>
  100. <tr>
  101. <th>Code</th><th>Text</th><th>Description</th>
  102. </tr>
  103. <tr>
  104. <td>409</td><td>Conflict</td><td>The strict attribute is set to 'true' and colliding data exists on the recipient node.</td>
  105. </tr>
  106. </table>
  107. </section2>
  108. <section2 topic='Examples'>
  109. <p>Creating new data on the server using iq:private, and strict actions when no existing data is on the server.</p>
  110. <example caption='Client Stores New Private Data'><![CDATA[
  111. SENDER:
  112. <iq type="set" id="1001">
  113. <query xmlns="jabber:iq:private" action="create" strict="true">
  114. <exodus xmlns="exodus:prefs">
  115. <defaultnick>Hamlet</defaultnick>
  116. </exodus>
  117. </query>
  118. </iq>
  119. RECIPIENT:
  120. <iq
  121. type="result"
  122. from="hamlet@shakespeare.lit/denmark"
  123. to="hamlet@shakespeare.lit/denmark"
  124. id="1001"/>
  125. ]]></example>
  126. <p>With strict actions enabled, conflict data will cause the create action
  127. to fail when existing data is on the recipient node. Here we show iq:private, and strict actions with existing data on the server.</p>
  128. <example caption='Client Stores New Private Data but Conflicts'><![CDATA[
  129. SENDER:
  130. <iq type="set" id="1002">
  131. <query xmlns="jabber:iq:private" action="create" strict="true">
  132. <exodus xmlns="exodus:prefs">
  133. <defaultnick>Hamlet</defaultnick>
  134. </exodus>
  135. </query>
  136. </iq>
  137. RECIPIENT:
  138. <iq
  139. type="error"
  140. from="hamlet@shakespeare.lit/denmark"
  141. to="hamlet@shakespeare.lit/denmark"
  142. id="1002">
  143. <error code="409">Conflict</error>
  144. <exodus xmlns="exodus:prefs">
  145. <defaultnick>Hamlet</defaultnick>
  146. </exodus>
  147. </query>
  148. </iq>
  149. ]]></example>
  150. </section2>
  151. </section1>
  152. <section1 topic='Read Action'>
  153. <section2 topic='Description'>
  154. <p>The read action retrieves data on the recipient node. If the strict attribute is
  155. 'true' the read action fails if no appropriate data exists on the recipient node. If the strict
  156. attribute is false, the read action will always return with a 'result', sending an empty
  157. result in place of a 'not found' error.</p>
  158. </section2>
  159. <section2 topic='Error Codes'>
  160. <table caption='Error Codes used by Create Action'>
  161. <tr>
  162. <th>Code</th><th>Text</th><th>Description</th>
  163. </tr>
  164. <tr>
  165. <td>404</td><td>Not found</td><td>The strict attribute is set to 'true' and no matching data exists on the recipient node.</td>
  166. </tr>
  167. </table>
  168. </section2>
  169. <section2 topic='Examples'>
  170. <p>Reading data on the server using iq:private, and strict actions when data is on the server.</p>
  171. <example caption='Client Reads Private Data'><![CDATA[
  172. SENDER:
  173. <iq type="set" id="1001">
  174. <query xmlns="jabber:iq:private" action="read" strict="true">
  175. <exodus xmlns="exodus:prefs"/>
  176. <defaultnick>Hamlet</defaultnick>
  177. </exodus>
  178. </query>
  179. </iq>
  180. RECIPIENT:
  181. <iq
  182. type="result"
  183. from="hamlet@shakespeare.lit/denmark"
  184. to="hamlet@shakespeare.lit/denmark"
  185. id="1001">
  186. <query xmlns="jabber:iq:private" action="read" strict="true">
  187. <exodus xmlns="exodus:prefs"/>
  188. <defaultnick>Hamlet</defaultnick>
  189. </exodus>
  190. </query>
  191. </iq>
  192. ]]></example>
  193. <p>With strict actions enabled, the absence of matching data will cause the read action
  194. to fail. Here we show iq:private, and strict actions with no matching data on the server.</p>
  195. <example caption='Client Reads Private Data but Not Found (strict)'><![CDATA[
  196. SENDER:
  197. <iq type="set" id="1002">
  198. <query xmlns="jabber:iq:private" action="read" strict="true">
  199. <data xmlns="imaginary"/>
  200. </query>
  201. </iq>
  202. RECIPIENT:
  203. <iq
  204. type="error"
  205. from="hamlet@shakespeare.lit/denmark"
  206. to="hamlet@shakespeare.lit/denmark"
  207. id="1002">
  208. <error code="404">Not Found</error>
  209. <data xmlns="imaginary"/>
  210. </query>
  211. </iq>
  212. ]]></example>
  213. <p>With strict actions disabled, the absence of matching data will cause the read action
  214. to return an 'empty' result. Here we show iq:private, and strict actions disabled with no matching data
  215. on the server.</p>
  216. <example caption='Client Reads Private Data but Not Found (not strict)'><![CDATA[
  217. SENDER:
  218. <iq type="set" id="1003">
  219. <query xmlns="jabber:iq:private" action="read" strict="false">
  220. <data xmlns="imaginary"/>
  221. </query>
  222. </iq>
  223. RECIPIENT:
  224. <iq
  225. type="result"
  226. from="hamlet@shakespeare.lit/denmark"
  227. to="hamlet@shakespeare.lit/denmark"
  228. id="1003">
  229. <data xmlns="imaginary"/>
  230. </query>
  231. </iq>
  232. ]]></example>
  233. </section2>
  234. </section1>
  235. <section1 topic='Update Action'>
  236. <section2 topic='Description'>
  237. <p>The update action edits existing data on the recipient node. If the strict attribute is
  238. 'true' the update action fails if matching data does not already exists on the recipient node. If the strict
  239. attribute is false, the update action will edit existing data, inserting the data on the recipient node
  240. if necessary.</p>
  241. </section2>
  242. <section2 topic='Error Codes'>
  243. <table caption='Error Codes used by Create Action'>
  244. <tr>
  245. <th>Code</th><th>Text</th><th>Description</th>
  246. </tr>
  247. <tr>
  248. <td>404</td><td>Not Found</td><td>The strict attribute is set to 'true' and matching data does NOT already exist on the recipient node.</td>
  249. </tr>
  250. </table>
  251. </section2>
  252. <section2 topic='Examples'>
  253. <p>Updating existing new data on the server using iq:private, and strict actions when existing data is on the server.</p>
  254. <example caption='Client Updates Existing Private Data'><![CDATA[
  255. SENDER:
  256. <iq type="set" id="1001">
  257. <query xmlns="jabber:iq:private" action="update" strict="true">
  258. <exodus xmlns="exodus:prefs">
  259. <defaultnick>Hamlet</defaultnick>
  260. </exodus>
  261. </query>
  262. </iq>
  263. RECIPIENT:
  264. <iq
  265. type="result"
  266. from="hamlet@shakespeare.lit/denmark"
  267. to="hamlet@shakespeare.lit/denmark"
  268. id="1001"/>
  269. ]]></example>
  270. <p>With strict actions enabled, the absence of existing data will cause the update action
  271. to fail. Here we show iq:private, and strict actions with no existing data on the server.</p>
  272. <example caption='Client Updates Private Data but None Found'><![CDATA[
  273. SENDER:
  274. <iq type="set" id="1002">
  275. <query xmlns="jabber:iq:private" action="update" strict="true">
  276. <exodus xmlns="exodus:prefs">
  277. <defaultnick>Hamlet</defaultnick>
  278. </exodus>
  279. </query>
  280. </iq>
  281. RECIPIENT:
  282. <iq
  283. type="error"
  284. from="hamlet@shakespeare.lit/denmark"
  285. to="hamlet@shakespeare.lit/denmark"
  286. id="1002">
  287. <error code="404">Not Found</error>
  288. <exodus xmlns="exodus:prefs">
  289. <defaultnick>Hamlet</defaultnick>
  290. </exodus>
  291. </query>
  292. </iq>
  293. ]]></example>
  294. </section2>
  295. </section1>
  296. <section1 topic='Delete Action'>
  297. <section2 topic='Description'>
  298. <p>The delete action deletes existing data on the recipient node. If the strict attribute is
  299. 'true' the delete action fails if matching data does not already exists on the recipient node. If the strict
  300. attribute is false, the delete action will delete any existing data on the recipient node (if any) and return
  301. successful..</p>
  302. </section2>
  303. <section2 topic='Error Codes'>
  304. <table caption='Error Codes used by Create Action'>
  305. <tr>
  306. <th>Code</th><th>Text</th><th>Description</th>
  307. </tr>
  308. <tr>
  309. <td>404</td><td>Not Found</td><td>The strict attribute is set to 'true' and matching data does NOT already exist on the recipient node.</td>
  310. </tr>
  311. </table>
  312. </section2>
  313. <section2 topic='Examples'>
  314. <p>Deleting existing new data on the server using iq:private, and strict actions when existing data is on the server.</p>
  315. <example caption='Client Deletes Existing Private Data'><![CDATA[
  316. SENDER:
  317. <iq type="set" id="1001">
  318. <query xmlns="jabber:iq:private" action="delete" strict="true">
  319. <exodus xmlns="exodus:prefs"/>
  320. </query>
  321. </iq>
  322. RECIPIENT:
  323. <iq
  324. type="result"
  325. from="hamlet@shakespeare.lit/denmark"
  326. to="hamlet@shakespeare.lit/denmark"
  327. id="1001"/>
  328. ]]></example>
  329. <p>With strict actions enabled, the absence of existing data will cause the delete action
  330. to fail. Here we show iq:private, and strict actions with no existing data on the server.</p>
  331. <example caption='Client Deletes Private Data but None Found (strict)'><![CDATA[
  332. SENDER:
  333. <iq type="set" id="1002">
  334. <query xmlns="jabber:iq:private" action="delete" strict="true">
  335. <data xmlns="imaginary"/>
  336. </query>
  337. </iq>
  338. RECIPIENT:
  339. <iq
  340. type="error"
  341. from="hamlet@shakespeare.lit/denmark"
  342. to="hamlet@shakespeare.lit/denmark"
  343. id="1002">
  344. <error code="404">Not Found</error>
  345. <data xmlns="imaginary"/>
  346. </query>
  347. </iq>
  348. ]]></example>
  349. <p>With strict actions disabled, the absence of existing data will not cause the delete action
  350. to fail. Here we show iq:private, and strict actions with no existing data on the server.</p>
  351. <example caption='Client Deletes Private Data but None Found (not strict)'><![CDATA[
  352. SENDER:
  353. <iq type="set" id="1003">
  354. <query xmlns="jabber:iq:private" action="delete" strict="false">
  355. <data xmlns="imaginary"/>
  356. </query>
  357. </iq>
  358. RECIPIENT:
  359. <iq
  360. type="result"
  361. from="hamlet@shakespeare.lit/denmark"
  362. to="hamlet@shakespeare.lit/denmark"
  363. id="1003"/>
  364. ]]></example>
  365. </section2>
  366. </section1>
  367. <section1 topic='Defining an Action Protocol'>
  368. <section2 topic='Description'>
  369. <p>In order to define an action protocol that uses the &QUERY; behavior defined in
  370. this document, you must specify the following:</p>
  371. <ul>
  372. <li>The actions (create, read, update, delete) supported in the action protocol.</li>
  373. <li>The matching semantics for determing if data exists/collides.</li>
  374. <li>The default "strict" attribute ('true' or 'false'). This may be defined for each action
  375. supported or for all actions supported.</li>
  376. <li>Whether the "strict" attribute may be set by the user. If the attribute may not be set,
  377. the strict attribute will always hold the default value.</li>
  378. </ul>
  379. </section2>
  380. </section1>
  381. </xep>