@@ -523,6 +523,24 @@ const schemas = {
523
523
404 : BadRequestSchema ( "Session with ID: 'xxx-xxx-xxx-xxx' was not found" ) ,
524
524
} ,
525
525
} ,
526
+ "GET/sessions/:sessionId/vmap" : {
527
+ description : "Gets the VMAP XML created for a specific session" ,
528
+ tags : [ "sessions" ] ,
529
+ params : {
530
+ sessionId : {
531
+ type : "string" ,
532
+ description : "The ID for the session. " ,
533
+ } ,
534
+ } ,
535
+ response : {
536
+ 200 : {
537
+ description : "VMAP XML" ,
538
+ type : "string" ,
539
+ } ,
540
+
541
+ 404 : BadRequestSchema ( "Session with ID: 'xxx-xxx-xxx-xxx' was not found" ) ,
542
+ } ,
543
+ } ,
526
544
"DELETE/sessions/:sessionId" : {
527
545
description : "Deletes the given session" ,
528
546
tags : [ "sessions" ] ,
@@ -969,6 +987,38 @@ module.exports = (fastify, opt, next) => {
969
987
}
970
988
) ;
971
989
990
+ fastify . get (
991
+ "/sessions/:sessionId/vmap" ,
992
+ {
993
+ schema : schemas [ "GET/sessions/:sessionId/vmap" ] ,
994
+ } ,
995
+ async ( req , reply ) => {
996
+ const sessionId = req . params . sessionId ;
997
+ try {
998
+ // Check if session exists.
999
+ const session = await DBAdapter . getSession ( sessionId ) ;
1000
+ if ( ! session ) {
1001
+ reply . code ( 404 ) . send ( {
1002
+ message : `Session with ID: '${ sessionId } ' was not found` ,
1003
+ } ) ;
1004
+ } else {
1005
+ vmap_xml = session . getVmapXml ( ) ;
1006
+ reply . headers ( {
1007
+ "Content-Type" : "application/xml;charset=UTF-8" ,
1008
+ } ) ;
1009
+ reply . code ( 200 ) . send ( vmap_xml ) ;
1010
+ }
1011
+ } catch ( exc ) {
1012
+ console . error ( exc ) ;
1013
+ logger . error ( exc , {
1014
+ label : req . headers [ "host" ] ,
1015
+ sessionId : sessionId ,
1016
+ } ) ;
1017
+ reply . code ( 500 ) . send ( { message : exc . message } ) ;
1018
+ }
1019
+ }
1020
+ ) ;
1021
+
972
1022
// Users - routes
973
1023
fastify . get (
974
1024
"/users/:userId" ,
0 commit comments