(:~ : Miscellaneous RESTXQ functions. : : : @author Rave Technologies, https://www.rave-tech.com/, 2017 :) (:~ : Update History : : Modified on 16/03/21: Resolve ticket CMS-235 :) module namespace blcommon = 'http://www.rave-tech.com/bloomsbury/common'; import module namespace config = 'http://www.rave-tech.com/bloomsbury/config' at './module/config.xqm'; (:~ : Get the content-type configuration from the database. : @header $authorization Authorization key : @return content type configuration or element(result) :) declare %rest:path("/content-types") %rest:GET %rest:query-param("type", "{$type}") %rest:query-param("supressItems", "{$supressItems}") %rest:header-param("Authorization", "{$authorization}", "none") function blcommon:content-type( $type as xs:string, $supressItems as xs:string?, $authorization as xs:string ) { config:session-check($authorization), let $ContentTypeXml := db:open($config:CoreDatabase,$config:ContentType) return if($ContentTypeXml) then ( Success { { for $item in $ContentTypeXml/*:controlledList/*:name (:[if($type='contenttype')then not(@metadataOnly)else @metadataOnly]:) [ if($type='contenttype' and $supressItems='true') then (not(@metadataOnly or @suppressInBrowse)) else if($type='contenttype' and $supressItems='false') then not(@metadataOnly) else @metadataOnly ] order by fn:upper-case($item/@label) return $item } } , config:non-update-message("[Content Type configuration XML file retrieved]") ) else ( config:non-update-message("[Content Type configuration not available]"), FailureNot Available ) }; (:~ : Get the content status configuration from the database. : @header $authorization Authorization key : @return status configuration or element(result) :) declare %rest:path("/content-statuses") %rest:GET %rest:header-param("Authorization", "{$authorization}", "none") function blcommon:content-status( $authorization as xs:string ) { config:session-check($authorization), let $StatusXml := db:open($config:CoreDatabase,$config:StatusFile) return if($StatusXml) then ( Success{$StatusXml}, config:non-update-message("[Status configuration XML file retrieved]") ) else ( config:non-update-message("[Status configuration is not available]"), FailureNot Available ) }; (:~ : Get the Organization Chart configuration from the database. : @header $authorization Authorization key : @return org. chart configuration or element(result) :) declare %rest:path("/organisation-chart") %rest:GET %rest:header-param("Authorization", "{$authorization}", "none") function blcommon:org-chart( $authorization as xs:string ) { config:session-check($authorization), let $OrgChartXml := db:open($config:CoreDatabase,$config:OrgChart) return if($OrgChartXml) then ( Success{$OrgChartXml}, config:non-update-message("[Org Chart XML configuration file retrieved]") ) else ( config:non-update-message("[Org Chart XML configuration is not available]"), FailureNot Available ) }; (:~ : Get the Role configuration from the database. : @header $authorization Authorization key : @return role configuration or element(result) :) declare %rest:path("/roles") %rest:GET %rest:header-param("Authorization", "{$authorization}", "none") function blcommon:role( $authorization as xs:string ) { config:session-check($authorization), let $RoleXml := db:open($config:CoreDatabase,$config:Role) return if($RoleXml) then ( Success{$RoleXml}, config:non-update-message("[Role configuration XML file retrieved]") ) else ( config:non-update-message("[Role configuration is not available]"), FailureNot Available ) }; declare function blcommon:get-db-name( $ctype as xs:string ) { let $dbname := if($ctype='looseleaf') then $config:LooseleafDatabase else if($ctype='monograph') then $config:MonographDatabase else if($ctype='play') then $config:playDatabase else if( ($ctype='audio') or ($ctype='person') or ($ctype='image') or ($ctype='video') or ($ctype='organisation') or ($ctype='organisation') or ($ctype='series') or ($ctype='publisher')) then $config:MetadataOnlyContentDatabase else if($ctype='screenplay') then $config:screenplayDatabase else('########No content-type found or Database not found######') return $dbname };