%ents; ]>
IQ Query Action Protocol Standardizes behavior of &IQ; &QUERY; actions for generic query behavior. &LEGALNOTICE; 0099 Deferred Standards Track Standards None None None Not yet assigned Iain Shigeoka iain@jivesoftware.com smirk@jabber.com 0.1 2003-06-25 iss Initial version.

There is a need for consistent query behavior amongst XMPP &IQ; protocols. Currently each protocol invents it's own, slightly different behavior for conducting query behavior to create, read, update, and delete (CRUD) recipient node data. This document defines a generic query acton protocol to standardize behavior across &IQ; protocols. In addition, we hope this standard will make other protocols easier to understand and implement by using a common core protocol.

The existing XMPP core protocol defines four &IQ; types (get, set, result, and error). Unfortunately, these four types don't include a 'delete' type, and the 'set' type must do double duty for 'create' and 'update'. Many protocols can benefit from a clear separation of create and update paralleling other query languages such as SQL.

Protocols complying with the &QUERY; action protocol use &IQ; 'set' to initiate all request-response interactions. The particular action to be taken MUST be set as an "action" attribute in the &IQ; &QUERY; sub-element. The action attribute MUST have a value of 'create', 'read', 'update', or 'delete'. Responses use the standard &IQ; 'result' and 'error' types. For backward compatibility, an &IQ; 'get' query is treated as equivalent to an &IQ; 'set' query with action of 'read'. Action protocols may require all or just a subset of these actions depending on the desired outcome.

In addition to the action attribute an optional "strict" attribute may be set in the &IQ; &QUERY; sub-element. The only valid values for strict is "true" or "false" (case sensitive). The strict behavior of actions causes more errors to be returned which tends to make protocols more robust but also more complex. Action protocols MUST define the default value of the "strict" attribute in the context of that protocol. In addition, some protocols may not wish to allow changing the strict default, so action protocols MUST declare whether the strict behavior of the protocol may be set in the &IQ; &QUERY; sub-element.

createCreates/inserts new data on the recipient node.
readRetrieves data from the recipient node.
updateUpdates existing data on the recipient node.
deleteDeletes existing data on the recipient node.

The root element is query which is in a namespace defining the protocol in use. The query element MUST have an attribute named 'action' with values given in the previous table.

The following error codes apply to all action codes.

CodeTextDescription
406Not AcceptableThe IQ query contents are not properly formatted for the action protocol.
503Service UnavailableThe IQ query is sent to a JID that cannot handle the query.

The create action inserts new data on the recipient node. If the strict attribute is 'true' the create action fails if colliding data already exists on the recipient node. If the strict attribute is false, the create action will insert new data on the recipient node overwriting existing colliding data if it exists (e.g. equivalent to update).

CodeTextDescription
409ConflictThe strict attribute is set to 'true' and colliding data exists on the recipient node.

Creating new data on the server using iq:private, and strict actions when no existing data is on the server.

Hamlet RECIPIENT: ]]>

With strict actions enabled, conflict data will cause the create action to fail when existing data is on the recipient node. Here we show iq:private, and strict actions with existing data on the server.

Hamlet RECIPIENT: Conflict Hamlet ]]>

The read action retrieves data on the recipient node. If the strict attribute is 'true' the read action fails if no appropriate data exists on the recipient node. If the strict attribute is false, the read action will always return with a 'result', sending an empty result in place of a 'not found' error.

CodeTextDescription
404Not foundThe strict attribute is set to 'true' and no matching data exists on the recipient node.

Reading data on the server using iq:private, and strict actions when data is on the server.

Hamlet RECIPIENT: Hamlet ]]>

With strict actions enabled, the absence of matching data will cause the read action to fail. Here we show iq:private, and strict actions with no matching data on the server.

RECIPIENT: Not Found ]]>

With strict actions disabled, the absence of matching data will cause the read action to return an 'empty' result. Here we show iq:private, and strict actions disabled with no matching data on the server.

RECIPIENT: ]]>

The update action edits existing data on the recipient node. If the strict attribute is 'true' the update action fails if matching data does not already exists on the recipient node. If the strict attribute is false, the update action will edit existing data, inserting the data on the recipient node if necessary.

CodeTextDescription
404Not FoundThe strict attribute is set to 'true' and matching data does NOT already exist on the recipient node.

Updating existing new data on the server using iq:private, and strict actions when existing data is on the server.

Hamlet RECIPIENT: ]]>

With strict actions enabled, the absence of existing data will cause the update action to fail. Here we show iq:private, and strict actions with no existing data on the server.

Hamlet RECIPIENT: Not Found Hamlet ]]>

The delete action deletes existing data on the recipient node. If the strict attribute is 'true' the delete action fails if matching data does not already exists on the recipient node. If the strict attribute is false, the delete action will delete any existing data on the recipient node (if any) and return successful..

CodeTextDescription
404Not FoundThe strict attribute is set to 'true' and matching data does NOT already exist on the recipient node.

Deleting existing new data on the server using iq:private, and strict actions when existing data is on the server.

RECIPIENT: ]]>

With strict actions enabled, the absence of existing data will cause the delete action to fail. Here we show iq:private, and strict actions with no existing data on the server.

RECIPIENT: Not Found ]]>

With strict actions disabled, the absence of existing data will not cause the delete action to fail. Here we show iq:private, and strict actions with no existing data on the server.

RECIPIENT: ]]>

In order to define an action protocol that uses the &QUERY; behavior defined in this document, you must specify the following:

  • The actions (create, read, update, delete) supported in the action protocol.
  • The matching semantics for determing if data exists/collides.
  • The default "strict" attribute ('true' or 'false'). This may be defined for each action supported or for all actions supported.
  • Whether the "strict" attribute may be set by the user. If the attribute may not be set, the strict attribute will always hold the default value.