@@ -604,33 +604,36 @@ def report_get_by_id(report_id, format_id)
604
604
if not report
605
605
raise OMPError . new ( "Invalid report id." )
606
606
end
607
+
607
608
format = @formats [ format_id . to_i ]
608
609
if not format
609
610
raise OMPError . new ( "Invalid format id." )
610
611
end
611
- req = xml_attrs ( "get_reports" , { "report_id" => report [ "id" ] , "format_id" => format [ "id" ] } )
612
612
613
+ req = xml_attrs ( "get_reports" , { "report_id" => report [ "id" ] , "format_id" => format [ "id" ] } )
613
614
begin
614
615
status , status_text , resp = omp_request_xml ( req )
615
- if status == "404"
616
- raise OMPError . new ( status_text )
617
- end
618
- content_type = resp . elements [ "report" ] . attributes [ "content_type" ]
619
- report = resp . elements [ "report" ] . text
620
-
621
- if report == nil
622
- raise OMPError . new ( "The report is empty." )
623
- end
624
-
625
- # XML reports are in XML format, everything else is base64 encoded.
626
- if content_type == "text/xml"
627
- return resp . elements [ "report" ] . text
628
- else
629
- return Base64 . decode64 ( resp . elements [ "report" ] . text )
630
- end
631
616
rescue
632
617
raise OMPResponseError
633
618
end
619
+
620
+ if status == "404"
621
+ raise OMPError . new ( status_text )
622
+ end
623
+
624
+ content_type = resp . elements [ "report" ] . attributes [ "content_type" ]
625
+ report = resp . elements [ "report" ] . to_s
626
+
627
+ if report == nil
628
+ raise OMPError . new ( "The report is empty." )
629
+ end
630
+
631
+ # XML reports are in XML format, everything else is base64 encoded.
632
+ if content_type == "text/xml"
633
+ return report
634
+ else
635
+ return Base64 . decode64 ( report )
636
+ end
634
637
end
635
638
636
639
end
0 commit comments