Browse Source

fix:mail send fail #2345 (#2346)

Co-authored-by: dailidong <dailidong66@gmail.com>
pull/3/MERGE
Rubik-W 5 years ago committed by gaojun2048
parent
commit
d8ccab6a49
  1. 5
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java
  2. 10
      dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/ExcelUtilsTest.java

5
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/utils/ExcelUtils.java

@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@ -102,7 +103,11 @@ public class ExcelUtils {
for (int i = 0; i < headerList.size(); i++) { for (int i = 0; i < headerList.size(); i++) {
sheet.setColumnWidth(i, headerList.get(i).length() * 800); sheet.setColumnWidth(i, headerList.get(i).length() * 800);
}
File file = new File(xlsFilePath);
if (!file.exists()) {
file.mkdirs();
} }
//setting file output //setting file output

10
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/utils/ExcelUtilsTest.java

@ -89,4 +89,14 @@ public class ExcelUtilsTest {
ExcelUtils.genExcelFile(incorrectContent1, title, xlsFilePath); ExcelUtils.genExcelFile(incorrectContent1, title, xlsFilePath);
} }
/**
* Test GenExcelFile (check directory)
*/
@Test
public void testGenExcelFileByCheckDir() {
ExcelUtils.genExcelFile("[{\"a\": \"a\"},{\"a\": \"a\"}]", "t", "/tmp/xls");
File file = new File("/tmp/xls" + Constants.SINGLE_SLASH + "t" + Constants.EXCEL_SUFFIX_XLS);
file.delete();
}
} }
Loading…
Cancel
Save