DhroovSankla commented on code in PR #6090:
URL: https://github.com/apache/fineract/pull/6090#discussion_r3528839742


##########
fineract-mix/src/main/java/org/apache/fineract/mix/api/MixReportApiResource.java:
##########
@@ -48,8 +51,18 @@ public String retrieveXBRLReport(@QueryParam("startDate") 
final Date startDate,
             @QueryParam("currency") final String currency) {
 
         final var data = xbrlResultService.getXBRLResult(startDate, endDate, 
currency);
+        final MixReportXBRLDocument document = 
this.xbrlBuilder.buildDocumentGraph(data);
 
-        // TODO: make this type safe?
-        return this.xbrlBuilder.build(data);
+        try {
+            final JAXBContext context = 
JAXBContext.newInstance(MixReportXBRLDocument.class);
+            final Marshaller marshaller = context.createMarshaller();
+            marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, 
Boolean.TRUE);
+
+            final StringWriter writer = new StringWriter();
+            marshaller.marshal(document, writer);
+            return writer.toString();
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to serialize XBRL report 
document graph", e);
+        }

Review Comment:
   Done! I've updated the endpoint to return `MixReportXBRLDocument` directly 
and let the Jakarta framework layer manage the native XML serialization as 
suggested. I also simplified the DTO inner class definitions to clear the 
static analysis/SpotBugs checks. Thanks for the catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to