You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
@Tag(name = "Run Reports", description = "API for executing predefined reports with dynamic parameters")
58
58
@RequiredArgsConstructor
59
59
publicclassRunreportsApiResource {
60
60
@@ -68,14 +68,16 @@ public class RunreportsApiResource {
68
68
@Path("/availableExports/{reportName}")
69
69
@Consumes({ MediaType.APPLICATION_JSON })
70
70
@Produces({ MediaType.APPLICATION_JSON })
71
-
@Operation(summary = "Return all available export types for the specific report", description = "Returns the list of all available export types.")
71
+
@Operation(summary = "Return all available export types for the specific report", description = "Returns the list of all available export types for a given report.")
@ApiResponse(responseCode = "400", description = "Bad Request - Invalid report name or parameters"),
75
+
@ApiResponse(responseCode = "500", description = "Internal Server Error") })
76
+
publicResponseretrieveAllAvailableExports(
77
+
@PathParam("reportName") @Parameter(description = "Name of the report to get available export types for", example = "Client Listing", required = true) finalStringreportName,
@DefaultValue("false") @QueryParam(IS_SELF_SERVICE_USER_REPORT_PARAMETER) @Parameter(description = "Indicates if this is a self-service user report", example = "false") finalbooleanisSelfServiceUserReport) {
@Operation(summary = "Running a Report", description = "This resource allows you to run and receive output from pre-defined Apache Fineract reports.\n"
97
-
+ "\n" + "Reports can also be used to provide data for searching and workflow functionality.\n" + "\n"
98
-
+ "The default output is a JSON formatted \"Generic Resultset\". The Generic Resultset contains Column Heading as well as Data information. However, you can export to CSV format by simply adding \"&exportCSV=true\" to the end of your URL.\n"
99
-
+ "\n"
100
-
+ "If Pentaho reports have been pre-defined, they can also be run through this resource. Pentaho reports can return HTML, PDF or CSV formats.\n"
101
-
+ "\n"
102
-
+ "The Apache Fineract reference application uses a JQuery plugin called stretchy reporting which, itself, uses this reports resource to provide a pretty flexible reporting User Interface (UI).\n\n"
@ApiResponse(responseCode = "401", description = "Unauthorized - Not authorized to run this report"),
103
+
@ApiResponse(responseCode = "500", description = "Internal Server Error") })
104
+
publicResponserunReport(
105
+
@PathParam("reportName") @Parameter(description = "The name of the report to execute (e.g., 'Client Listing', 'Expected Payments By Date')", example = "Client Listing", required = true) finalStringreportName,
@DefaultValue("false") @QueryParam(IS_SELF_SERVICE_USER_REPORT_PARAMETER) @Parameter(description = "Whether this is a self-service user report", example = "false") finalbooleanisSelfServiceUserReport,
121
109
110
+
@DefaultValue("false") @QueryParam("exportCSV") @Parameter(description = "Set to true to export results as CSV", example = "false") finalBooleanexportCSV,
111
+
112
+
@DefaultValue("false") @QueryParam("parameterType") @Parameter(description = "Indicates if this is a parameter type request", example = "false") finalBooleanparameterType,
113
+
114
+
@QueryParam("output-type") @Parameter(description = "Output format type (HTML, XLS, CSV, PDF)", example = "HTML") finalStringoutputType,
115
+
116
+
@QueryParam("R_officeId") @Parameter(description = "Office ID filter", example = "1") finalStringrOfficeId,
117
+
118
+
@QueryParam("R_loanOfficerId") @Parameter(description = "Loan officer ID filter", example = "5") finalStringrLoanOfficerId,
119
+
120
+
@QueryParam("R_fromDate") @Parameter(description = "Start date filter (yyyy-MM-dd)", example = "2023-01-01") finalStringrFromDate,
121
+
122
+
@QueryParam("R_toDate") @Parameter(description = "End date filter (yyyy-MM-dd)", example = "2023-12-31") finalStringrToDate,
123
+
124
+
@QueryParam("R_currencyId") @Parameter(description = "Currency ID filter", example = "USD") finalStringrCurrencyId,
125
+
126
+
@QueryParam("R_accountNo") @Parameter(description = "Account number filter", example = "00010001") finalStringrAccountNo) {
* Validates report name to prevent SQL injection attacks.
154
-
*
155
-
* @param reportName
156
-
* the report name to validate
157
-
* @throws IllegalArgumentException
158
-
* if the report name is invalid
159
-
*/
160
-
privatevoidvalidateReportName(StringreportName) {
161
-
if (StringUtils.isBlank(reportName)) {
162
-
thrownewIllegalArgumentException("Report name cannot be null or empty");
163
-
}
164
-
165
-
// Basic length validation
166
-
if (reportName.length() > 100) {
167
-
thrownewIllegalArgumentException("Report name exceeds maximum length of 100 characters");
168
-
}
169
-
170
-
// Check for potentially dangerous characters
171
-
// Allow letters, numbers, spaces, hyphens, underscores, and parentheses which are common in report names
172
-
if (!reportName.matches("^[a-zA-Z0-9\\s\\-_()%&.]+$")) {
173
-
thrownewIllegalArgumentException(
174
-
"Report name contains invalid characters. Only letters, numbers, spaces, hyphens, underscores, parentheses, percent, ampersand, and dots are allowed");
0 commit comments