Skip to content

Commit

Permalink
MID-7747: replace illegal characters in report output file name on wi…
Browse files Browse the repository at this point in the history
…ndows
  • Loading branch information
skublik committed Mar 18, 2022
1 parent eb9686e commit 690f6e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ private String getDestinationFileName(ReportType reportType,
ReportDataWriter<? extends ExportedReportDataRow, ? extends ExportedReportHeaderRow> dataWriter) {
File exportDir = ReportSupportUtil.getOrCreateExportDir();

String fileNamePrefix = reportType.getName().getOrig() + "-EXPORT " + getDateTime();
String reportName = StringUtils.replace(reportType.getName().getOrig(), File.separator, "_");
String fileNamePrefix = reportName + "-EXPORT " + getDateTime();
String fileName = fileNamePrefix + dataWriter.getTypeSuffix();
return MiscUtil.replaceColonsInFileNameOnWindows(new File(exportDir, fileName).getPath());
return MiscUtil.replaceIllegalCharInFileNameOnWindows(new File(exportDir, fileName).getPath());
}

static String getNameOfExportedReportData(ReportType reportType, String type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ List<String> getLinesOfOutputFile(PrismObject<ReportType> report) throws IOExcep
File findOutputFile(PrismObject<ReportType> report) throws ParseException {
// We should use a more robust way of finding the file names, e.g. by looking at ReportDataType repo objects.
String expectedFilePrefix =
MiscUtil.replaceColonsInFileNameOnWindows(
MiscUtil.replaceIllegalCharInFileNameOnWindows(
report.getName().getOrig());
File[] matchingFiles = EXPORT_DIR.listFiles((dir, name) -> name.startsWith(expectedFilePrefix));
if (matchingFiles == null || matchingFiles.length == 0) {
Expand Down

0 comments on commit 690f6e8

Please sign in to comment.