source: cats/ISOcat/trunk/mod-ISOcat-interface-rest/interface/shared.acc @ 3447

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

Made the ISOcat API more RESTful:

  • create resources using POST
  • update resources using PUT

One outlier: we use POST for creating users eventhough the client in this case specifies the full resource URL
Other outliers: in many cases we allow a dummy 0 for a POST call, e.g., POST /dcs/0 to create a new DCS

File size: 4.8 KB
Line 
1<accessor debug="false">
2        <name>/rest/user/shared</name>
3        <descr>Get an users shared DCs.</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>
10                <name>tree</name>
11                <descr>show hierarchical DC relations (false, simple, complex, true)</descr>
12                <type canonical="true">string</type>
13                <source>
14                        <param/>
15                        <nvp/>
16                        <default>
17                                <string>false</string>
18                        </default>
19                </source>
20        </param>
21        <!-- authorization -->
22        <param mandatory="true">
23                <name>user</name>
24                <descr>the user name</descr>
25                <type canonical="true">string</type>
26        </param>
27        <param>
28                <name>credentials</name>
29                <descr>the users credentials</descr>
30                <source>
31                        <param/>
32                        <default>data:text/plain,guest:guest</default>
33                </source>
34        </param>
35        <!-- representation -->
36        <param>
37                <name>representation</name>
38                <descr>the requested representation</descr>
39                <type canonical="true">string</type>
40                <source>
41                        <param/>
42                        <default>
43                                <string/>
44                        </default>
45                </source>
46        </param>
47        <param>
48                <name>Accept</name>
49                <descr>the accepted representation</descr>
50                <type canonical="true">string</type>
51                <source>
52                        <param/>
53                        <default>
54                                <string/>
55                        </default>
56                </source>
57        </param>
58        <params/>
59        <idoc>
60                <!-- if requested make sure the shared DCS gets reloaded by cutting its golden thread -->
61                <if>
62                        <cond>
63                                <instr>
64                                        <type>sloot.xpath2eval</type>
65                                        <operand>var:params</operand>
66                                        <operator>
67                                                <xpath>exists(/nvp/reload)</xpath>
68                                        </operator>
69                                        <target>this:cond</target>
70                                </instr>
71                        </cond>
72                        <then>
73                                <instr>
74                                        <type>sloot.xquery</type>
75                                        <operator>
76                                                <string>goldenthread:/user/{string($user)}/shared</string>
77                                        </operator>
78                                        <user>var:user</user>
79                                        <target>var:thread</target>
80                                </instr>
81                                <instr>
82                                        <type>sloot.cutGoldenThread</type>
83                                        <param>var:thread</param>
84                                </instr>
85                        </then>
86                </if>
87                <!-- determine the requested representation -->
88                <instr>
89                        <type>ISOcat.interface.rest.dcs.determine.representation</type>
90                        <representation>var:representation</representation>
91                        <accept>var:Accept</accept>
92                        <target>var:representation</target>
93                </instr>
94                <!-- only the XML representation can handle a non false value for the tree param -->
95                <if>
96                        <cond>
97                                <instr>
98                                        <type>sloot.xpath2eval</type>
99                                        <operand>var:representation</operand>
100                                        <operator>
101                                                <xpath>.='xml'</xpath>
102                                        </operator>
103                                        <target>this:cond</target>
104                                </instr>
105                        </cond>
106                        <then>
107                                <instr>
108                                        <type>copy</type>
109                                        <operand>var:tree</operand>
110                                        <target>var:tree</target>
111                                </instr>
112                        </then>
113                        <else>
114                                <instr>
115                                        <type>copy</type>
116                                        <operand>
117                                                <string>false</string>
118                                        </operand>
119                                        <target>var:tree</target>
120                                </instr>
121                        </else>
122                </if>
123                <choose>
124                        <cond>
125                                <instr>
126                                        <type>sloot.xpath2eval</type>
127                                        <operand>var:method</operand>
128                                        <operator>
129                                                <xpath>.='POST'</xpath>
130                                        </operator>
131                                        <target>this:cond</target>
132                                </instr>
133                        </cond>
134                        <then>
135                                <instr>
136                                        <type>throw</type>
137                                        <operand>
138                                                <ex>
139                                                        <id>ISOcat[METHOD NOT ALLOWED]</id>
140                                                        <message>You can't create this resource.</message>
141                                                </ex>
142                                        </operand>
143                                </instr>
144                        </then>
145                        <cond>
146                                <instr>
147                                        <type>sloot.xpath2eval</type>
148                                        <operand>var:method</operand>
149                                        <operator>
150                                                <xpath>.='PUT'</xpath>
151                                        </operator>
152                                        <target>this:cond</target>
153                                </instr>
154                        </cond>
155                        <then>
156                                <instr>
157                                        <type>throw</type>
158                                        <operand>
159                                                <ex>
160                                                        <id>ISOcat[METHOD NOT ALLOWED]</id>
161                                                        <message>You can't update this resource.</message>
162                                                </ex>
163                                        </operand>
164                                </instr>
165                        </then>
166                        <cond>
167                                <instr>
168                                        <type>sloot.xpath2eval</type>
169                                        <operand>var:method</operand>
170                                        <operator>
171                                                <xpath>.='DELETE'</xpath>
172                                        </operator>
173                                        <target>this:cond</target>
174                                </instr>
175                        </cond>
176                        <then>
177                                <instr>
178                                        <type>throw</type>
179                                        <operand>
180                                                <ex>
181                                                        <id>ISOcat[METHOD NOT ALLOWED]</id>
182                                                        <message>You can't delete this resource.</message>
183                                                </ex>
184                                        </operand>
185                                </instr>
186                        </then>
187                        <else>
188                                <instr>
189                                        <type>ISOcat.manage.user.shared</type>
190                                        <user>var:user</user>
191                                        <credentials>var:credentials</credentials>
192                                        <tree>var:tree</tree>
193                                        <target>this:response</target>
194                                </instr>
195                        </else>
196                </choose>
197                <instr>
198                        <type>ISOcat.interface.rest.dcs.representation</type>
199                        <dcs>this:response</dcs>
200                        <id>var:user</id>
201                        <dcs-type>
202                                <string>shared</string>
203                        </dcs-type>
204                        <representation>var:representation</representation>
205                        <credentials>var:credentials</credentials>
206                        <nvp>var:params</nvp>
207                        <target>this:response</target>
208                </instr>
209        </idoc>
210        <exception>
211                <debug/>
212                <trace>ffcpl:/trace/shared.exception.xml</trace>
213                <throw/>
214        </exception>
215        <response>
216                <debug>ffcpl:/trace/shared.response.xml</debug>
217        </response>
218</accessor>
219
Note: See TracBrowser for help on using the repository browser.