--- src/main/java/egovframework/com/cmm/web/EgovFileDownloadController.java
+++ src/main/java/egovframework/com/cmm/web/EgovFileDownloadController.java
... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 |
import java.io.PrintWriter; |
| 11 | 11 |
import java.net.URLEncoder; |
| 12 | 12 |
import java.util.ArrayList; |
| 13 |
-import java.util.Collections; |
|
| 14 | 13 |
import java.util.List; |
| 15 | 14 |
import java.util.Map; |
| 16 | 15 |
|
... | ... | @@ -107,7 +106,7 @@ |
| 107 | 106 |
String browser = getBrowser(request); |
| 108 | 107 |
|
| 109 | 108 |
String dispositionPrefix = "attachment; filename="; |
| 110 |
- String encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
|
| 109 |
+ String encodedFilename = null; |
|
| 111 | 110 |
|
| 112 | 111 |
if (browser.equals("MSIE")) {
|
| 113 | 112 |
encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
|
... | ... | @@ -133,8 +132,7 @@ |
| 133 | 132 |
throw new IOException("Not supported browser");
|
| 134 | 133 |
} |
| 135 | 134 |
|
| 136 |
- response.setHeader("Content-Disposition",
|
|
| 137 |
- "attachment; filename=\"" + encodedFilename + "\"; filename*=UTF-8''" + encodedFilename); |
|
| 135 |
+ response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename);
|
|
| 138 | 136 |
|
| 139 | 137 |
if ("Opera".equals(browser)) {
|
| 140 | 138 |
response.setContentType("application/octet-stream;charset=UTF-8");
|
... | ... | @@ -740,71 +738,134 @@ |
| 740 | 738 |
|
| 741 | 739 |
/* 파일 다운로드 - 일괄 zip 압축(사업관리)*/ |
| 742 | 740 |
@RequestMapping(value = "/cmm/fms/bizFileDownZip.do") |
| 743 |
- public void bizFileDownZip(@RequestParam Map<String, Object> commandMap, |
|
| 744 |
- @ModelAttribute("bizCntrtVO") BizCntrtVO bizCntrtVO,
|
|
| 745 |
- BizItemVO bizItemVO, |
|
| 746 |
- HttpServletRequest request, |
|
| 747 |
- HttpServletResponse response) throws Exception {
|
|
| 748 |
- List<String> atchFileIdList = new ArrayList<>(); |
|
| 749 |
- |
|
| 750 |
- if (bizItemVO.getAtchFileId() != null && !bizItemVO.getAtchFileId().trim().isEmpty()) {
|
|
| 751 |
- String[] splitStr = bizItemVO.getAtchFileId().split(",");
|
|
| 752 |
- for (String id : splitStr) {
|
|
| 753 |
- if (id != null && !id.trim().isEmpty()) {
|
|
| 754 |
- atchFileIdList.add(id.trim()); |
|
| 755 |
- } |
|
| 756 |
- } |
|
| 741 |
+ public void bizFileDownZip(@RequestParam Map<String, Object> commandMap, @ModelAttribute("bizCntrtVO") BizCntrtVO bizCntrtVO,
|
|
| 742 |
+ BizItemVO bizItemVO, |
|
| 743 |
+ HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
| 744 |
+ |
|
| 745 |
+ //파일ID를 리스트에 담기 |
|
| 746 |
+ List<String> atchFileIdList = new ArrayList<String>(); |
|
| 747 |
+ //split을 이용해 아이디를 각자 배열에 담기 |
|
| 748 |
+ String[] splitStr =bizItemVO.getAtchFileId().split(",");
|
|
| 749 |
+ //리스트에 아이디 담기 |
|
| 750 |
+ for(int i=0; i<splitStr.length; i++) {
|
|
| 751 |
+ atchFileIdList.add(splitStr[i]); |
|
| 757 | 752 |
} |
| 758 |
- |
|
| 759 |
- FileVO fileVO = new FileVO(); |
|
| 760 |
- fileVO.setAtchFileIdList(!atchFileIdList.isEmpty() ? atchFileIdList : null); |
|
| 761 |
- |
|
| 762 |
- List<FileVO> fvoList = fileService.selectBizFileInfs(fileVO); |
|
| 763 |
- |
|
| 764 |
- if (fvoList == null || fvoList.isEmpty()) {
|
|
| 765 |
- response.sendError(HttpServletResponse.SC_NOT_FOUND, "파일이 존재하지 않습니다."); |
|
| 766 |
- return; |
|
| 767 |
- } |
|
| 768 |
- |
|
| 753 |
+ |
|
| 754 |
+ //zip파일 이름 (메뉴명+글 제목명 +날짜) |
|
| 769 | 755 |
String menuNm = "사업관리"; |
| 770 |
- String orgnZipNm = menuNm + "_" |
|
| 771 |
- + bizCntrtVO.getBizNm() + "_" |
|
| 772 |
- + bizCntrtVO.getFrstRegistPnttm() + ".zip"; |
|
| 773 |
- |
|
| 774 |
- response.reset(); |
|
| 775 |
- response.setContentType("application/zip");
|
|
| 776 |
- |
|
| 777 |
- String encodedFileName = URLEncoder.encode(orgnZipNm, "UTF-8").replaceAll("\\+", "%20");
|
|
| 778 |
- |
|
| 779 |
- response.setHeader("Content-Disposition",
|
|
| 780 |
- "attachment; filename=\"" + encodedFileName + "\"; filename*=UTF-8''" + encodedFileName); |
|
| 781 |
- |
|
| 782 |
- byte[] buffer = new byte[1024]; |
|
| 783 |
- |
|
| 784 |
- try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(response.getOutputStream())) {
|
|
| 785 |
- |
|
| 786 |
- zos.setEncoding("UTF-8");
|
|
| 787 |
- |
|
| 788 |
- for (FileVO vo : fvoList) {
|
|
| 789 |
- |
|
| 790 |
- File file = new File(vo.getFileStreCours(), vo.getStreFileNm()); |
|
| 791 |
- |
|
| 792 |
- if (!file.exists()) continue; |
|
| 793 |
- |
|
| 794 |
- try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
|
|
| 795 |
- |
|
| 796 |
- zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); |
|
| 797 |
- |
|
| 798 |
- int len; |
|
| 799 |
- while ((len = bis.read(buffer)) != -1) {
|
|
| 800 |
- zos.write(buffer, 0, len); |
|
| 756 |
+ String orgnZipNm = menuNm+"_"+bizCntrtVO.getBizNm()+"_"+bizCntrtVO.getFrstRegistPnttm()+".zip"; // 압축 파일명 필요.. |
|
| 757 |
+ |
|
| 758 |
+ |
|
| 759 |
+ FileVO fileVO = new FileVO(); |
|
| 760 |
+ fileVO.setAtchFileIdList(atchFileIdList); |
|
| 761 |
+ List<FileVO> fvoList = fileService.selectBizFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 |
|
| 762 |
+ |
|
| 763 |
+ if(fvoList.size() == 0){
|
|
| 764 |
+ response.setContentType("application/x-msdownload");
|
|
| 765 |
+ PrintWriter printwriter = response.getWriter(); |
|
| 766 |
+ printwriter.println("<html>");
|
|
| 767 |
+ printwriter.println("<br><br><br><h2>Could not get file name:<br></h2>");
|
|
| 768 |
+ printwriter.println("<br><br><br><center><h3><a href='javascript: history.go(-1)'>Back</a></h3></center>");
|
|
| 769 |
+ printwriter.println("<br><br><br>© webAccess");
|
|
| 770 |
+ printwriter.println("</html>");
|
|
| 771 |
+ printwriter.flush(); |
|
| 772 |
+ printwriter.close(); |
|
| 773 |
+ return ; |
|
| 774 |
+ } |
|
| 775 |
+ |
|
| 776 |
+ |
|
| 777 |
+ // buffer size |
|
| 778 |
+ int size = 1024; |
|
| 779 |
+ byte[] buf = new byte[size]; |
|
| 780 |
+ |
|
| 781 |
+ String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; |
|
| 782 |
+ FileInputStream fis = null; |
|
| 783 |
+ ZipArchiveOutputStream zos = null; |
|
| 784 |
+ BufferedInputStream bis = null; |
|
| 785 |
+ |
|
| 786 |
+ try {
|
|
| 787 |
+ // Zip 파일생성 |
|
| 788 |
+ zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); |
|
| 789 |
+ |
|
| 790 |
+ for ( FileVO vo : fvoList ){
|
|
| 791 |
+ zos.setEncoding("UTF-8");
|
|
| 792 |
+ |
|
| 793 |
+ //buffer에 해당파일의 stream을 입력한다. |
|
| 794 |
+ fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); |
|
| 795 |
+ bis = new BufferedInputStream(fis,size); |
|
| 796 |
+ |
|
| 797 |
+ //zip에 넣을 다음 entry 를 가져온다. |
|
| 798 |
+ zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); |
|
| 799 |
+ |
|
| 800 |
+ //준비된 버퍼에서 집출력스트림으로 write 한다. |
|
| 801 |
+ int len; |
|
| 802 |
+ while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); |
|
| 803 |
+ |
|
| 804 |
+ bis.close(); |
|
| 805 |
+ fis.close(); |
|
| 806 |
+ zos.closeArchiveEntry(); |
|
| 807 |
+ } |
|
| 808 |
+ |
|
| 809 |
+ zos.close(); |
|
| 810 |
+ |
|
| 811 |
+ } catch (FileNotFoundException e) {
|
|
| 812 |
+ e.printStackTrace(); |
|
| 813 |
+ }finally{
|
|
| 814 |
+ if( zos != null ) zos.close(); |
|
| 815 |
+ if( fis != null ) fis.close(); |
|
| 816 |
+ if( bis != null ) bis.close(); |
|
| 817 |
+ } |
|
| 818 |
+ |
|
| 819 |
+ File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); |
|
| 820 |
+ long fSize = uFile.length(); |
|
| 821 |
+ |
|
| 822 |
+ if (fSize > 0) {
|
|
| 823 |
+ String mimetype = "application/x-msdownload"; |
|
| 824 |
+ |
|
| 825 |
+ response.setContentType(mimetype); |
|
| 826 |
+ setDisposition(orgnZipNm, request, response); |
|
| 827 |
+ //response.setContentLength(fSize); |
|
| 828 |
+ |
|
| 829 |
+ BufferedInputStream in = null; |
|
| 830 |
+ BufferedOutputStream out = null; |
|
| 831 |
+ |
|
| 832 |
+ try {
|
|
| 833 |
+ in = new BufferedInputStream(new FileInputStream(uFile)); |
|
| 834 |
+ out = new BufferedOutputStream(response.getOutputStream()); |
|
| 835 |
+ |
|
| 836 |
+ FileCopyUtils.copy(in, out); |
|
| 837 |
+ out.flush(); |
|
| 838 |
+ } catch (Exception ex) {
|
|
| 839 |
+ LOGGER.debug("IGNORED: {}", ex.getMessage());
|
|
| 840 |
+ } finally {
|
|
| 841 |
+ if (in != null) {
|
|
| 842 |
+ try {
|
|
| 843 |
+ in.close(); |
|
| 844 |
+ } catch (Exception ignore) {
|
|
| 845 |
+ LOGGER.debug("IGNORED: {}", ignore.getMessage());
|
|
| 801 | 846 |
} |
| 802 |
- |
|
| 803 |
- zos.closeArchiveEntry(); |
|
| 847 |
+ } |
|
| 848 |
+ if (out != null) {
|
|
| 849 |
+ try {
|
|
| 850 |
+ out.close(); |
|
| 851 |
+ } catch (Exception ignore) {
|
|
| 852 |
+ LOGGER.debug("IGNORED: {}", ignore.getMessage());
|
|
| 853 |
+ } |
|
| 804 | 854 |
} |
| 805 | 855 |
} |
| 806 |
- |
|
| 807 |
- zos.finish(); |
|
| 856 |
+ //파일 다운로드 후 파일 삭제 |
|
| 857 |
+ File delFile = new File(outZipNm); |
|
| 858 |
+ delFile.delete(); |
|
| 859 |
+ } else {
|
|
| 860 |
+ response.setContentType("application/x-msdownload");
|
|
| 861 |
+ PrintWriter printwriter = response.getWriter(); |
|
| 862 |
+ printwriter.println("<html>");
|
|
| 863 |
+ printwriter.println("<br><br><br><h2>Could not get file name:<br>" + orgnZipNm + "</h2>");
|
|
| 864 |
+ printwriter.println("<br><br><br><center><h3><a href='javascript: history.go(-1)'>Back</a></h3></center>");
|
|
| 865 |
+ printwriter.println("<br><br><br>© webAccess");
|
|
| 866 |
+ printwriter.println("</html>");
|
|
| 867 |
+ printwriter.flush(); |
|
| 868 |
+ printwriter.close(); |
|
| 808 | 869 |
} |
| 809 | 870 |
} |
| 810 | 871 |
|
--- src/main/java/egovframework/let/itsm/security/service/RuleVO.java
+++ src/main/java/egovframework/let/itsm/security/service/RuleVO.java
... | ... | @@ -88,5 +88,5 @@ |
| 88 | 88 |
public void setRuleDetailUrl(String ruleDetailUrl) {
|
| 89 | 89 |
this.ruleDetailUrl = ruleDetailUrl; |
| 90 | 90 |
} |
| 91 |
- |
|
| 91 |
+ |
|
| 92 | 92 |
} |
--- src/main/webapp/WEB-INF/jsp/uss/itsm/bizCntrt/BizCntrtView.jsp
+++ src/main/webapp/WEB-INF/jsp/uss/itsm/bizCntrt/BizCntrtView.jsp
... | ... | @@ -607,9 +607,10 @@ |
| 607 | 607 |
var frm = document.writeForm |
| 608 | 608 |
window.opener.name="parentPage"; |
| 609 | 609 |
frm.target = "parentPage"; |
| 610 |
- frm.action="/cmm/fms/bizFileDownZip.do?"; |
|
| 610 |
+ frm.action="/cmm/fms/bizFileDownZip.do?atchFileId="+checkboxId; |
|
| 611 | 611 |
frm.submit(); |
| 612 |
- } |
|
| 612 |
+ |
|
| 613 |
+ } |
|
| 613 | 614 |
|
| 614 | 615 |
/* 감사기간 validate */ |
| 615 | 616 |
function validateDate(neceFlag){
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?