|
|
alert:make-action(
|
|
$name as xs:string,
|
|
$description as xs:string,
|
|
$module-db as xs:unsignedLong,
|
|
$module-root as xs:string,
|
|
$module as xs:string,
|
|
$options as element(alert:options)
|
| ) as element(alert:action) |
|
 |
Summary:
This function creates the xml representing an action.
When a rule associated with the action matches a document,
the action's module will be invoked with the following
external variables set:
declare variable $alert:config-uri as xs:string external;
declare variable $alert:doc as node() external;
declare variable $alert:rule as element(alert:rule) external;
declare variable $alert:action as element(alert:action) external;
All actions must accept these external variables.
|
Parameters:
$name
:
The name give to
the action.
|
$description
:
A text description
of the action.
|
$module-db
:
The database ID
where the XQuery modules reside. Use
xdmp:module-database() to specify the
configured database.
|
$module-root
:
The path to the module
root. Use xdmp:module-root() to specify the
configured root.
|
$module
:
The URI of the module
to invoke.
|
$options
:
Optional
information specific to the action.
|
|
Example:
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:make-action(
"sms",
"Sends basic SMS text message",
xdmp:modules-database(),
xdmp:modules-root(),
"/modules/sms.xqy",
<alert:options>
<provider name="T-Mobile" domain="tmomail.net"/>
<provider name="Virgin" domain="vmobl.com"/>
<provider name="Cingular" domain="cingularme.com"/>
<provider name="Sprint" domain="messaging.sprintpcs.com"/>
<provider name="Verizon" domain="vtext.com"/>
<provider name="Nextel" domain="messaging-nextel.com"/>
</alert:options>
)
=> Returns the XML representing an action with the specified information
|
|
|
|
alert:make-config(
|
|
$uri as xs:string,
|
|
$name as xs:string,
|
|
$description as xs:string,
|
|
$options as element(alert:options)
|
| ) as element(alert:config) |
|
 |
Summary:
Create an alerting configuration associated with a
particular URI. The URI will be used to create a protected
collection when the config is inserted into the database with
alert:config-insert. This URI will also be
used as a directory for all documents (config, actions,
and rules) associated with the config.
|
Parameters:
$uri
:
The URI for this alerting
config.
|
$name
:
The name for this
alerting config.
|
$description
:
A description for
this alerting config.
|
$options
:
Additional options available to an alerting application
for extra state.
|
|
Required Privilege:
The alert-admin role is required to run
this function (or all of the privileges in the
alert-admin role).
|
Usage Notes:
If you add the
<alert:unfiltered>true</alert:unfiltered>
option to the $options parameter, it will cause all
cts:search operations that use this config to
run unfiltered. This applies to the functions in the
Alerting API that use cts:search (for example,
alert:find-matching rules). The default is for them
to run filtered. Unfiltered searches skip the filtering stage of
query processing, relying on the index resolution for
the accuracy of the results. The unfiltered option can give a
performance boost to configurations
whose index settings do not require results to be filtered.
|
Example:
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:make-config(
"http://acme.com/alert/message-board",
"Message Board",
"Alerting config for messages on the message board",
<alert:options/>
)
|
|
|
|
alert:make-log-action( ) as element(alert:action)
|
|
 |
Summary:
Create a standard logging action named "log".
Rules that reference this action must provide an
<alert:directory/> element that
specifies where the log file should be created. The
inserted document will have a random long integer
ID and its filename will be ID.xml within the
specified directory.
Rules that reference this action may also provide options
with an <alert:permissions> element
containing a series of <sec:permission>
elements and/or an <alert:collections>
element containing <alert:collection>
elements that specify the permissions and collections for
the log document. This information is simply passed through
to xdmp:document-insert.
An example of the rule's options is as follows:
<alert:options>
<alert:directory>/some/directory</alert:directory>
<alert:permissions>
<sec:permission>
<sec:capability>read</sec:capability>
<sec:role-id>129382323</sec:role-id>
</sec:permission>
</alert:permissions>
<alert:collections>
<alert:collection>http://acme.com/alert-log</alert:collection>
</alert:collections>
</alert:options>
The log document has the following structure:
<alert:log>
<alert:log-id>82388423</alert:log-id>
<alert:config-uri>http://acme.com/alert/message-board</alert:config-uri>
<alert:rule-id>12352</alert:rule-id>
<alert:user-id>8271938239</alert:user-id>
<alert:document-uri>/the/URI/of/the/matching/document</alert:document-uri>
<alert:timestamp>2008-05-31T08:20:00-08:00</alert:timestamp>
</alert:log>
The log document insertion will be performed as the user who created
the rule, and the user must have permission to create documents in any
collections they specify. The log-id is a random number chosen by
the action.
|
Example:
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:action-insert(alert:make-log-action())
|
|
|
|
alert:make-rule(
|
|
$name as xs:string,
|
|
$description as xs:string,
|
|
$user-id as xs:unsignedLong,
|
|
$query as cts:query,
|
|
$action as xs:string,
|
|
$options as element(alert:options)
|
| ) as element(alert:rule) |
|
 |
Summary:
This function creates the XML representing a rule.
If the caller does not have the alert-admin
privilege then $user-id must be the ID
of the current user from the security database.
If $user-id is 0, it will be automatically
replaced with the current user's ID.
|
Parameters:
$name
:
The name given to
the rule.
|
$description
:
A text
description of the rule.
|
$user-id
:
The user
ID from the security database of the user who will
be notified of matches.
|
$query
:
The query that
the rule will be matched against for alerting.
|
$action
:
The name of the
action to occur upon the matching of the rule.
|
$options
:
Information specific to the application for the rule.
|
|
Example:
xquery version "1.0-ml";
import module namespace alert = "http://marklogic.com/xdmp/alert"
at "/MarkLogic/alert.xqy";
alert:make-rule(
"nucleic acids email",
"Alert me to anything concerning nucleic acids",
0,
cts:or-query((
cts:word-query("dna"),
cts:word-query("rna")
)),
"email",
<alert:options>
<alert:email-address>me@somedomain.com</alert:email-address>
</alert:options>
)
|
|
|