/request/request-path /request/content-type /request/method /request/body /request/headers/header[name = 'orbeon-exist-uri'] /fr/service/exist/crud((?:/([^/]+)/([^/]+))/(?:(?:form)/[^/]+|((data)/[^/]+)/[^/]+)) /fr/service/exist/crud/(([^/]+)/([^/]+)/(data)/)
declare variable $frPath := request:get-path-info(); declare variable $collection := request:get-parameter('collection' , ''); declare variable $username := request:get-parameter('username' , ''); declare variable $groupname := request:get-parameter('groupname' , ''); declare variable $organization := request:get-parameter('organization', ()); declare variable $method := request:get-parameter('method' , ''); declare variable $path := concat( $frPath, if (ends-with($frPath, '/')) then '' else '/', $collection ); declare function local:createPath($parts, $count) { concat('/', string-join(subsequence($parts, 1, $count), '/')) }; let $dataExists := let $dataURI := concat($path, '/data.xml') return element data-exists { doc-available($dataURI) } let $existingMetadata := if ($username != '' and $method = 'PUT' and not(xmldb:collection-available($path))) then (: Create the collection, since it doesn't exist :) let $dummy := let $parts := tokenize($path, '/')[. != ''] return for $i in 2 to count($parts) return let $partialPath := local:createPath($parts, $i) return if (xmldb:collection-available($partialPath)) then () else xmldb:create-collection(local:createPath($parts, $i - 1), $parts[$i]) (: Store metadata.xml :) let $metadata := element metadata { element username { $username }, element groupname { $groupname }, if (exists($organization)) then element organization { for $level in $organization return element level { $level } } else () } let $dummy := xmldb:store($path, 'metadata.xml', $metadata) return () else (: Since we're not creating a metadata.xml, return it if it exists :) let $metadataURI := concat($path, '/metadata.xml') return if (doc-available($metadataURI)) then doc($metadataURI) else () return ($dataExists, $existingMetadata) binary
created
false created
false utf-8 false