@@ -64,36 +64,63 @@ function exp:describe-collection($uri) as map(xs:string, xs:string) {
6464
6565declare
6666 %private
67- function exp:collection-properties ($uri) as map (xs:string, xs:string) {
68- map:merge ((
69- exp:common-resource-properties ($uri),
70- map {
71- "created" : xmldb:created ($uri)
72- }
73- ))
74- };
75-
76- declare
77- %private
78- function exp:describe-document ($uri) as map (xs:string, item ()) {
79- let $collection-uri := ut:parent-path ($uri)
80- let $doc-name := ut:last-path-component ($uri)
67+ function exp:collection-properties ($uri) as map (xs:string, xs:string)? {
68+ (:
69+ TODO the need for the sm:has-access check below is likely
70+ a bug. I think reading the properties of the collection should
71+ not require read access to the collection as the collection
72+ properties are stored in the Collection entry... check what
73+ Unix does!
8174
82- let $last-modified := xmldb:last-modified ($collection-uri, $doc-name)
83- let $media-type := xmldb:get-mime-type ($uri)
84- let $is-binary-doc := util:is-binary-doc ($uri)
85- let $size := xmldb:size ($collection-uri, $doc-name)
86- return
75+ It seems especially strange... as xmldb:get-child-collections
76+ is able to read the collection entries without needing
77+ read access on each collection!
78+ :)
79+ if (sm:has-access (xs:anyURI ($uri), "r--" ))
80+ then
8781 map:merge ((
8882 exp:common-resource-properties ($uri),
8983 map {
90- "created" : xmldb:created ($collection-uri, $doc-name),
91- "lastModified" : $last-modified,
92- "mediaType" : $media-type,
93- "binaryDoc" : $is-binary-doc,
94- "size" : $size
84+ "created" : xmldb:created ($uri)
9585 }
9686 ))
87+ else ()
88+ };
89+
90+ declare
91+ %private
92+ function exp:describe-document ($uri) as map (xs:string, item ())? {
93+ (:
94+ TODO the need for the sm:has-access check below is likely
95+ a bug. I think reading the properties of the document should
96+ not require read access to the document as the document
97+ properties are stored in the Collection entry... check what
98+ Unix does!
99+
100+ It seems especially strange... as xmldb:get-child-resources
101+ is able to read the collection entries without needing
102+ read access on each document!
103+ :)
104+ if (sm:has-access (xs:anyURI ($uri), "r--" ))
105+ then
106+ let $collection-uri := ut:parent-path ($uri)
107+ let $doc-name := ut:last-path-component ($uri)
108+ let $last-modified := xmldb:last-modified ($collection-uri, $doc-name)
109+ let $media-type := xmldb:get-mime-type ($uri)
110+ let $is-binary-doc := util:is-binary-doc ($uri)
111+ let $size := xmldb:size ($collection-uri, $doc-name)
112+ return
113+ map:merge ((
114+ exp:common-resource-properties ($uri),
115+ map {
116+ "created" : xmldb:created ($collection-uri, $doc-name),
117+ "lastModified" : $last-modified,
118+ "mediaType" : $media-type,
119+ "binaryDoc" : $is-binary-doc,
120+ "size" : $size
121+ }
122+ ))
123+ else ()
97124};
98125
99126declare
0 commit comments