source: cats/ISOcat/trunk/mod-ISOcat-interface-rest/interface/dc-scope.acc @ 5612

Last change on this file since 5612 was 5612, checked in by Menzo Windhouwer, 10 years ago

M dc-scope.acc
M lock.acc

  • added some more debugging options
File size: 4.8 KB
Line 
1<accessor debug="false">
2        <name>/rest/dc/scope</name>
3        <descr>Get or set the scope of a DC.</descr>
4        <param mandatory="true">
5                <name>method</name>
6                <descr>what do we want to do?</descr>
7                <type canonical="true">string</type>
8        </param>
9        <param mandatory="true">
10                <name>dc</name>
11                <descr>the DC key</descr>
12                <type canonical="true">string</type>
13        </param>
14        <param>
15                <name>credentials</name>
16                <descr>the user credentials</descr>
17                <source>
18                        <param/>
19                        <default>data:text/plain,guest:guest</default>
20                </source>
21        </param>
22        <param>
23                <name>representation</name>
24                <descr>the requested representation</descr>
25                <type canonical="true">string</type>
26                <source>
27                        <param/>
28                        <default>
29                                <string/>
30                        </default>
31                </source>
32        </param>
33        <param>
34                <name>Accept</name>
35                <descr>the accepted representation</descr>
36                <type canonical="true">string</type>
37                <source>
38                        <param/>
39                        <default>
40                                <string/>
41                        </default>
42                </source>
43        </param>
44        <params/>
45        <idoc>
46                <!-- determine the requested representation -->
47                <if>
48                        <cond>
49                                <instr>
50                                        <type>sloot.xpath2eval</type>
51                                        <operand>var:representation</operand>
52                                        <operator>
53                                                <xpath>.=''</xpath>
54                                        </operator>
55                                        <target>this:cond</target>
56                                </instr>
57                        </cond>
58                        <then>
59                                <instr>
60                                        <type>sloot.mimeparse</type>
61                                        <accept>var:Accept</accept>
62                                        <types>xml:application/xml</types>
63                                        <target>var:representation</target>
64                                </instr>
65                        </then>
66                </if>
67            <accessor-debug>
68                <instr>
69                    <type>log</type>
70                    <operand>var:credentials</operand>
71                </instr>
72                <instr>
73                    <type>log</type>
74                    <operand>var:method</operand>
75                </instr>
76                <instr>
77                    <type>log</type>
78                    <operand>var:dc</operand>
79                </instr>
80            </accessor-debug>
81            <choose>
82                        <cond>
83                                <instr>
84                                        <type>sloot.xpath2eval</type>
85                                        <operand>var:method</operand>
86                                        <operator>
87                                                <xpath>.='GET'</xpath>
88                                        </operator>
89                                        <target>this:cond</target>
90                                </instr>
91                        </cond>
92                        <then>
93                                <instr>
94                                        <type>ISOcat.manage.dc.scope</type>
95                                        <dc>var:dc</dc>
96                                        <credentials>var:credentials</credentials>
97                                        <target>var:response</target>
98                                </instr>
99                        </then>
100                        <cond>
101                                <instr>
102                                        <type>sloot.xpath2eval</type>
103                                        <operand>var:method</operand>
104                                        <operator>
105                                                <xpath>.='POST'</xpath>
106                                        </operator>
107                                        <target>this:cond</target>
108                                </instr>
109                        </cond>
110                        <then>
111                                <if>
112                                        <cond>
113                                                <instr>
114                                                        <type>sloot.non-exists</type>
115                                                        <operand>var:params</operand>
116                                                        <target>this:cond</target>
117                                                </instr>
118                                        </cond>
119                                        <then>
120                                                <instr>
121                                                        <type>throw</type>
122                                                        <operand>
123                                                                <ex>
124                                                                        <id>ISOcat[BAD REQUEST]</id>
125                                                                        <message>The DC scope update is absent.</message>
126                                                                </ex>
127                                                        </operand>
128                                                </instr>
129                                        </then>
130                                </if>
131                                <if>
132                                        <cond>
133                                                <instr>
134                                                        <type>sloot.xpath2eval</type>
135                                                        <operand>var:dc</operand>
136                                                        <operator>
137                                                                <xpath>.='0'</xpath>
138                                                        </operator>
139                                                        <target>this:cond</target>
140                                                </instr>
141                                        </cond>
142                                        <then>
143                                                <instr>
144                                                        <type>throw</type>
145                                                        <operand>
146                                                                <ex>
147                                                                        <id>ISOcat[BAD REQUEST]</id>
148                                                                        <message>The updated DC scope should already have an id.</message>
149                                                                </ex>
150                                                        </operand>
151                                                </instr>
152                                        </then>
153                                </if>
154                                <instr>
155                                        <type>ISOcat.manage.dc.scope.update</type>
156                                        <dc>var:dc</dc>
157                                        <scope>var:params</scope>
158                                        <credentials>var:credentials</credentials>
159                                        <target>var:response</target>
160                                </instr>
161                        </then>
162                        <else>
163                                <instr>
164                                        <type>throw</type>
165                                        <operand>
166                                                <ex>
167                                                        <id>ISOcat[METHOD NOT ALLOWED]</id>
168                                                        <message>This method is not suppored by this resource.</message>
169                                                </ex>
170                                        </operand>
171                                </instr>
172                        </else>
173                </choose>
174                <choose>
175                        <cond>
176                                <instr>
177                                        <type>sloot.xpath2eval</type>
178                                        <operand>var:representation</operand>
179                                        <operator>
180                                                <xpath>.='xml'</xpath>
181                                        </operator>
182                                        <target>this:cond</target>
183                                </instr>
184                        </cond>
185                        <then>
186                                <instr>
187                                        <type>cast</type>
188                                        <operand>var:response</operand>
189                                        <operator>
190                                                <cast>
191                                                        <mimetype>application/xml</mimetype>
192                                                </cast>
193                                        </operator>
194                                        <target>this:response</target>
195                                </instr>
196                        </then>
197                        <else>
198                                <instr>
199                                        <type>throw</type>
200                                        <operand>
201                                                <ex>
202                                                        <id>ISOcat[NOT FOUND]</id>
203                                                        <message>This representation isn't supported by this resource.</message>
204                                                </ex>
205                                        </operand>
206                                </instr>
207                        </else>
208                </choose>
209            <accessor-debug>
210                <instr>
211                    <type>log</type>
212                    <operand>this:response</operand>
213                </instr>
214            </accessor-debug>
215        </idoc>
216        <exception>
217                <debug/>
218                <trace>ffcpl:/trace/dc-scope.exception.xml</trace>
219                <throw/>
220        </exception>
221        <response>
222                <debug>ffcpl:/trace/dc-scope.response.xml</debug>
223                <expire>now</expire>
224        </response>
225</accessor>
226
Note: See TracBrowser for help on using the repository browser.