Changeset 3164


Ignore:
Timestamp:
07/18/13 16:13:20 (11 years ago)
Author:
andmor
Message:

Implemented verb 'NEW' to create a new user.
Fixed some problems where references are logged instead of the actual variable values.
Added more debug info.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cats/SCHEMAcat/trunk/urn.org.isocat.schemacat.access.data/access/user.dpml

    r3090 r3164  
    55                        <level>INFO</level>
    66                        <message>
    7                                 <literal type="string">user verb: %1</literal>
     7                                <literal type="string">user accessor verb: %1 for principal : %2</literal>
    88                        </message>
    99                        <param>arg:verb</param>
     10                        <param>arg:principal</param>
     11                        <!-- weird!! first call prints principal 2nd call print object id -->
    1012                </log>
    1113        </sloot-debug>
    12         <switch>
    13                 <!--<cond>
     14        <switch assignment="response">
     15                <cond>
    1416                        <request>
    1517                                <identifier>active:sloot.xpath2</identifier>
     
    2224                <then>
    2325                        <sequence>
    24                                 <request assignment="response">
     26                                <!-- compute the id for the new user -->
     27                                <request assignment="new-user-id">
     28                                        <identifier>active:sloot.generateUUID</identifier>
     29                                </request>
     30                                <!-- create the new user -->
     31                                <request>
    2532                                        <identifier>active:org.basex.query</identifier>
    2633                                        <argument name="operator">
    27                                                 <request>
    28                                                         <identifier>active:sloot.xquery</identifier>
    29                                                         <argument name="operator">
    30                                                                 <literal type="xml">
    31                                                                         <user xmlns:sc="http://www.isocat.org/ns/schemacat">
    32                                                                                 {{//sc:user[sc:principal={$principal}]/@*,//sc:user[sc:principal={$principal}]/*)}}
    33                                                                         </user>
    34                                                                 </literal>
    35                                                         </argument>
    36                                                         <argument name="principal">arg:principal</argument>
    37                                                 </request>
     34                                                <literal type="xml">
     35                                                        <query xmlns:sc="http://www.isocat.org/ns/schemacat"> let $new-user :=
     36                                                                element user { attribute xml:id {$new-user-id}, element principal
     37                                                                {$principal}, element displayName {$principal}, element role
     38                                                                {'user'} } return insert node $new-user into /sc:users </query>
     39                                                </literal>
    3840                                        </argument>
     41                                        <argument name="principal">arg:principal</argument>
     42                                        <argument name="new-user-id">this:new-user-id</argument>
    3943                                </request>
     44                                <literal assignment="response" type="boolean">true</literal>
    4045                                <log>
    4146                                        <level>INFO</level>
    4247                                        <message>
    43                                                 <literal type="string">user [%1] &lt; [%2]</literal>
     48                                                <literal type="string">Created user for principal: [%1]</literal>
    4449                                        </message>
    4550                                        <param>arg:principal</param>
    46                                         <param>this:response</param>
    4751                                </log>
    4852                        </sequence>
    49                 </then>-->
     53                </then>
    5054                <cond>
    5155                        <request>
     
    6064                        <!-- check if the user exists in the database -->
    6165                        <!-- TODO: do we always search by principal? also support the user/@xml:id pattern 'u[0-9]+', which is unlikely(?) to clash with the principal? -->
    62                         <request assignment="response">
     66                        <request>
    6367                                <identifier>active:org.basex.booleanQuery</identifier>
    6468                                <argument name="operator">
    6569                                        <literal type="xml">
    66                                                 <b xmlns:sc="http://www.isocat.org/ns/schemacat">{exists(//sc:user[sc:principal=$principal])}</b>
     70                                                <query xmlns:sc="http://www.isocat.org/ns/schemacat">
     71                                                        <b>{exists(//sc:user[sc:principal=$principal])}</b>
     72                                                </query>
    6773                                        </literal>
    6874                                </argument>
     
    8187                <then>
    8288                        <!-- get the user information -->
    83                         <request assignment="response">
    84                                 <identifier>active:org.basex.query</identifier>
    85                                 <argument name="operator">
    86                                         <literal type="xml">
    87                                                 <sc:user xmlns:sc="http://www.isocat.org/ns/schemacat">{(//sc:user[sc:principal=$principal]/@*,//sc:user[sc:principal=$principal]/*)}</sc:user>
    88                                         </literal>
    89                                 </argument>
    90                                 <argument name="principal">arg:principal</argument>
    91                         </request>
     89                        <sequence>
     90                                <request assignment="res">
     91                                        <identifier>active:org.basex.query</identifier>
     92                                        <argument name="operator">
     93                                                <literal type="xml">
     94                                                        <query xmlns:sc="http://www.isocat.org/ns/schemacat">
     95                                                                <sc:user>{(//sc:user[sc:principal=$principal]/@*,//sc:user[sc:principal=$principal]/*)}</sc:user>
     96                                                        </query>
     97                                                </literal>
     98                                        </argument>
     99                                        <argument name="principal">arg:principal</argument>
     100                                </request>
     101                                <!-- pass the document returned by basex trough sloot.xpath2 so
     102                                when we log the response (end of this dpml) the actual user
     103                                document is logged instead of the value of its pointer!-->
     104                                <request assignment="response">
     105                                        <identifier>active:sloot.xpath2</identifier>
     106                                        <argument name="operand">this:res</argument>
     107                                        <argument name="operator">
     108                                                <literal type="xml">
     109                                                        <dummy>.</dummy>
     110                                                </literal>
     111                                        </argument>
     112                                </request>
     113
     114                                <!--    AAM: it would be better  to use sloot.xquery instead of sloot.xpath2
     115                for instance to log the user document in its own line. However using it
     116                causes a type mismatch in findUser.dpml since sloot.xquery does not seem
     117                to return an element of type "document" as expected by findUser.dpml
     118               
     119                                        <request assignment="response">
     120                                        <identifier>active:sloot.xquery</identifier>
     121                                        <argument name="operator">
     122                                                <literal type="xml"><dummy>{$NL}{$doc}{$NL}</dummy></literal>
     123                                        </argument>
     124                                        <argument name="NL">
     125                                                <literal type="string">
     126</literal>
     127                                        </argument>
     128                                        <argument name="doc">this:res</argument>
     129                                </request>-->
     130
     131                        </sequence>
    92132                </then>
    93133                <otherwise>
     
    103143        </switch>
    104144        <sloot-debug>
     145                <log>
     146                        <level>INFO</level>
     147                        <message>
     148                                <literal type="string">user accessor response: [%1]</literal>
     149                        </message>
     150                        <param>this:response</param>
     151                </log>
    105152                <request>
    106153                        <verb>SINK</verb>
Note: See TracChangeset for help on using the changeset viewer.