PageRenderTime 18ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/xquery/import-media-element.xql

http://transcriptstudio4isha.googlecode.com/
Unknown | 31 lines | 27 code | 4 blank | 0 comment | 0 complexity | e77b9b9be6df0b359a0ffb27daf7aaac MD5 | raw file
 1xquery version "1.0";
 2 
 3declare option exist:serialize "media-type=text/plain";
 4
 5import module namespace media-fns = "http://www.ishafoundation.org/ts4isha/xquery/media-fns" at "media-fns.xqm";
 6import module namespace utils = "http://www.ishafoundation.org/ts4isha/xquery/utils" at "utils.xqm";
 7
 8if (not(utils:is-current-user-admin())) then	
 9	error((xs:QName('access-control-exception')), 'Only admin user allowed to call this script')
10else
11
12let $sessionId := request:get-parameter("sessionId", ())
13let $deviceCode := request:get-parameter("deviceCode", ())
14let $mediaXML := util:parse(request:get-parameter("mediaXML", ()))
15return
16	if (empty($sessionId)) then
17		error(xs:QName('missing-argument-exception'), 'No sessionId specified')
18	else if (empty($deviceCode)) then
19		error(xs:QName('missing-argument-exception'), 'No deviceCode specified')
20	else if (empty($mediaXML)) then
21		error(xs:QName('missing-argument-exception'), 'No mediaXML specified')
22	else
23		let $sessionXML := utils:get-session($sessionId)
24		return
25			if (empty($sessionXML)) then
26				error(xs:QName('illegal-argument-exception'), concat('Unknown sessionId: ', $sessionId))
27			else
28				let $mediaMetadataXML := media-fns:get-media-metadata-element($sessionXML)
29				let $deviceXML := media-fns:get-device-element($deviceCode, $mediaMetadataXML)
30				return
31					media-fns:import-media-element($mediaXML, $deviceXML)