source: cats/ISOcat/trunk/mod-ISOcat-manage-system/manage/dc-status.acc @ 3337

Last change on this file since 3337 was 3337, checked in by mwindhouwer, 11 years ago

M mod-ISOcat-manage-system/manage/dc-status.acc

  • turned off debugging
File size: 8.2 KB
Line 
1<accessor debug="false" trace="false" deadlock="true">
2        <name>/isocat/manage/dc-status</name>
3        <descr>Change the status of one or more DCs</descr>
4        <param>
5                <name>dc</name>
6                <descr>which DC</descr>
7                <type canonical="true">string</type>
8                <source>
9                        <param/>
10                        <nvp/>
11                        <default>
12                                <string/>
13                        </default>
14                </source>
15        </param>
16        <param>
17                <name>dcs</name>
18                <descr>which DCS</descr>
19                <type canonical="true">string</type>
20                <source>
21                        <param/>
22                        <nvp/>
23                        <default>
24                                <string/>
25                        </default>
26                </source>
27        </param>
28        <param>
29                <name>status</name>
30                <descr>which status</descr>
31                <type canonical="true">string</type>
32                <source>
33                        <nvp/>
34                        <default>
35                                <string/>
36                        </default>
37                </source>
38        </param>
39        <param>
40                <name>user</name>
41                <descr>which user</descr>
42                <type canonical="true">string</type>
43                <source>
44                        <nvp/>
45                        <default>
46                                <string/>
47                        </default>
48                </source>
49        </param>
50        <param>
51                <name>message</name>
52                <descr>informative message</descr>
53                <type canonical="true">string</type>
54                <source>
55                        <nvp/>
56                        <default>
57                                <string/>
58                        </default>
59                </source>
60        </param>
61        <params/>
62        <idoc>
63                <accessor-debug>
64                        <instr>
65                                <type>log</type>
66                                <operand>var:params</operand>
67                        </instr>
68                </accessor-debug>
69
70                <!-- check if DC or DCS is specified -->
71                <choose>
72                        <cond>
73                                <instr>
74                                        <type>sloot.xpath2eval</type>
75                                        <operand>var:dc</operand>
76                                        <operator>
77                                                <xpath>normalize-space(.)!=''</xpath>
78                                        </operator>
79                                        <target>this:cond</target>
80                                </instr>
81                        </cond>
82                        <then>
83                                <!-- create a dummy DCS -->
84                                <instr>
85                                        <type>sloot.xquery</type>
86                                        <operator>
87                                                <dcs name="DC status update" owner="none">
88                                                        <dc ref="{$dc}"/>
89                                                </dcs>
90                                        </operator>
91                                        <dc>var:dc</dc>
92                                        <target>var:dcs</target>
93                                </instr>
94                        </then>
95                        <cond>
96                                <instr>
97                                        <type>sloot.xpath2eval</type>
98                                        <operand>var:dcs</operand>
99                                        <operator>
100                                                <xpath>normalize-space(.)!=''</xpath>
101                                        </operator>
102                                        <target>this:cond</target>
103                                </instr>
104                        </cond>
105                        <then>
106                                <!-- load the DCS -->
107                                <instr>
108                                        <type>ISOcat.access.data.dcs</type>
109                                        <dcs>var:dcs</dcs>
110                                        <target>var:dcs</target>
111                                </instr>
112                        </then>
113                        <else>
114                                <!-- ERROR: no DC(S) found -->
115                                <instr>
116                                        <type>throw</type>
117                                        <operand>
118                                                <ex>
119                                                        <id>ISOcat[BAD REQUEST]</id>
120                                                        <message>No DC or DCS specified!</message>
121                                                </ex>
122                                        </operand>
123                                </instr>
124                        </else>
125                </choose>
126                <accessor-debug>
127                        <instr>
128                                <type>log</type>
129                                <operand>var:dcs</operand>
130                        </instr>
131                </accessor-debug>
132               
133                <!-- check if an user is specified -->
134                <if>
135                        <cond>
136                                <instr>
137                                        <type>sloot.xpath2eval</type>
138                                        <operand>var:user</operand>
139                                        <operator>
140                                                <xpath>normalize-space(.)=''</xpath>
141                                        </operator>
142                                        <target>this:cond</target>
143                                </instr>
144                        </cond>
145                        <then>
146                                <instr>
147                                        <type>copy</type>
148                                        <operand>
149                                                <string>isocat</string>
150                                        </operand>
151                                        <target>var:user</target>
152                                </instr>
153                        </then>
154                        <else>
155                                <!-- noop -->
156                                <instr>
157                                        <type>copy</type>
158                                        <operand>
159                                                <null/>
160                                        </operand>
161                                        <target>var:void</target>
162                                </instr>
163                        </else>
164                </if>
165               
166                <!-- turn user into uid -->
167                <instr>
168                        <type>ISOcat.access.data.user.id</type>
169                        <user>var:user</user>
170                        <target>var:user</target>
171                </instr>
172                <accessor-debug>
173                        <instr>
174                                <type>log</type>
175                                <operand>var:user</operand>
176                        </instr>
177                </accessor-debug>
178               
179                <!-- check if a status is specified -->
180                <if>
181                        <cond>
182                                <instr>
183                                        <type>sloot.xpath2eval</type>
184                                        <operand>var:status</operand>
185                                        <operator>
186                                                <xpath>normalize-space(.)=''</xpath>
187                                        </operator>
188                                        <target>this:cond</target>
189                                </instr>
190                        </cond>
191                        <then>
192                                <!-- ERROR: no status found -->
193                                <instr>
194                                        <type>throw</type>
195                                        <operand>
196                                                <ex>
197                                                        <id>ISOcat[BAD REQUEST]</id>
198                                                        <message>No status specified!</message>
199                                                </ex>
200                                        </operand>
201                                </instr>
202                        </then>
203                        <else>
204                                <!-- noop -->
205                                <instr>
206                                        <type>copy</type>
207                                        <operand>
208                                                <null/>
209                                        </operand>
210                                        <target>var:void</target>
211                                </instr>
212                        </else>
213                </if>
214                <accessor-debug>
215                        <instr>
216                                <type>log</type>
217                                <operand>var:status</operand>
218                        </instr>
219                </accessor-debug>
220               
221                <!-- check if a message is specified -->
222                <if>
223                        <cond>
224                                <instr>
225                                        <type>sloot.xpath2eval</type>
226                                        <operand>var:message</operand>
227                                        <operator>
228                                                <xpath>normalize-space(.)=''</xpath>
229                                        </operator>
230                                        <target>this:cond</target>
231                                </instr>
232                        </cond>
233                        <then>
234                                <!-- create a default message -->
235                                <instr>
236                                        <type>sloot.xquery</type>
237                                        <operator>
238                                                <string>Status changed to {string($status)}</string>
239                                        </operator>
240                                        <status>var:status</status>
241                                        <target>var:message</target>
242                                </instr>
243                        </then>
244                        <else>
245                                <!-- noop -->
246                                <instr>
247                                        <type>copy</type>
248                                        <operand>
249                                                <null/>
250                                        </operand>
251                                        <target>var:void</target>
252                                </instr>
253                        </else>
254                </if>
255                <accessor-debug>
256                        <instr>
257                                <type>log</type>
258                                <operand>var:message</operand>
259                        </instr>
260                </accessor-debug>
261               
262                <!-- generate the DPML -->
263                <instr>
264                        <type>sloot.xquery</type>
265                        <operator>
266                                <idoc>
267                                        <seq>
268                                                <instr>
269                                                        <type>copy</type>
270                                                        <operand>
271                                                                <html>
272                                                                        <head>
273                                                                                <title>DC status update log</title>
274                                                                        </head>
275                                                                        <body>
276                                                                                <h1>DC status update log</h1>
277                                                                                <table>
278                                                                                        <tr>
279                                                                                                <th>dc</th>
280                                                                                                <th>status</th>
281                                                                                                <th>user</th>
282                                                                                                <th>message</th>
283                                                                                        </tr>
284                                                                                </table>
285                                                                        </body>
286                                                                </html>
287                                                        </operand>
288                                                        <target>var:log</target>
289                                                </instr>
290                                                {
291                                                        for $dc in $dcs//dc/@ref return
292                                                        <seq>
293                                                                <instr>
294                                                                        <type>ISOcat.access.data.dc.status</type>
295                                                                        <dc>
296                                                                                <string>{string($dc)}</string>
297                                                                        </dc>
298                                                                        <user>
299                                                                                <string>{string($user)}</string>
300                                                                        </user>
301                                                                        <status>
302                                                                                <string>{string($status)}</string>
303                                                                        </status>
304                                                                        <message>
305                                                                                <string>{string($message)}</string>
306                                                                        </message>
307                                                                        <target>var:void</target>
308                                                                </instr>
309                                                                <instr>
310                                                                        <type>ISOcat.access.data.dc.change</type>
311                                                                        <dc>
312                                                                                <string>{string($dc)}</string>
313                                                                        </dc>
314                                                                        <user>
315                                                                                <string>{string($user)}</string>
316                                                                        </user>
317                                                                        <change>
318                                                                                <string>{string($message)}</string>
319                                                                        </change>
320                                                                        <target>var:void</target>
321                                                                </instr>
322                                                                <instr>
323                                                                        <type>xslt2</type>
324                                                                        <operand>var:log</operand>
325                                                                        <operator>
326                                                                                <xsl:stylesheet
327                                                                                        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
328                                                                                        version="2.0"
329                                                                                >
330                                                                                        <xsl:param name="dc"/>
331                                                                                        <xsl:param name="status"/>
332                                                                                        <xsl:param name="user"/>
333                                                                                        <xsl:param name="message"/>
334                                                                                        <xsl:output method="xml"/>
335                                                                                        <xsl:template match="@*|node()">
336                                                                                                <xsl:copy>
337                                                                                                        <xsl:apply-templates select="@*|node()"/>
338                                                                                                </xsl:copy>
339                                                                                        </xsl:template>
340                                                                                        <xsl:template match="table">
341                                                                                                <xsl:copy>
342                                                                                                        <xsl:apply-templates select="@*|node()"/>
343                                                                                                        <tr>
344                                                                                                                <td>{string($dc)}</td>
345                                                                                                                <td>{string($status)}</td>
346                                                                                                                <td>{string($user)}</td>
347                                                                                                                <td>{string($message)}</td>
348                                                                                                        </tr>
349                                                                                                </xsl:copy>
350                                                                                        </xsl:template>
351                                                                                </xsl:stylesheet>
352                                                                        </operator>
353                                                                        <target>var:log</target>
354                                                                </instr>
355                                                        </seq>
356                                                }
357                                                <instr>
358                                                        <type>copy</type>
359                                                        <operand>var:log</operand>
360                                                        <target>this:response</target>
361                                                </instr>
362                                        </seq>
363                                </idoc>
364                        </operator>
365                        <dcs>var:dcs</dcs>
366                        <user>var:user</user>
367                        <status>var:status</status>
368                        <message>var:message</message>
369                        <target>var:dpml</target>
370                </instr>
371                <accessor-debug>
372                        <instr>
373                                <type>copy</type>
374                                <operand>var:dpml</operand>
375                                <target>ffcpl:/trace/dc-status.dpml.xml</target>
376                        </instr>
377                </accessor-debug>
378               
379                <!-- execute the DPML -->
380                <instr>
381                        <type>dpml</type>
382                        <operand>var:dpml</operand>
383                        <target>this:response</target>
384                </instr>
385               
386        </idoc>
387        <exception>
388                <debug/>
389                <trace>ffcpl:/trace/dc-status.exception.xml</trace>
390                <throw/>
391        </exception>
392        <response>
393                <expire>now</expire>
394                <mime>text/html</mime>
395        </response>
396</accessor>
Note: See TracBrowser for help on using the repository browser.