package egovframework.com.cmm.web; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintWriter; import java.net.URLEncoder; import java.util.ArrayList; import java.util.List; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.util.FileCopyUtils; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; import egovframework.com.cmm.service.EgovFileMngService; import egovframework.com.cmm.service.FileVO; import egovframework.let.itsm.asset.service.AssetVO; import egovframework.let.itsm.audit.service.AuditItemVO; import egovframework.let.itsm.audit.service.AuditManageService; import egovframework.let.itsm.audit.service.AuditVO; import egovframework.let.itsm.bizCntrt.service.BizCntrtVO; import egovframework.let.itsm.bizCntrt.service.BizItemVO; import egovframework.let.itsm.edu.service.EduVO; import egovframework.let.itsm.ip.service.IpVO; import egovframework.let.itsm.per.service.PeriFile; import egovframework.let.itsm.per.service.PerispVO; import egovframework.let.itsm.per.service.PeritemVO; import egovframework.let.itsm.security.service.SecVO; import egovframework.let.itsm.sla.service.SlaAutItemVO; import egovframework.let.itsm.sla.service.SlaAutscitecVO; /** * 파일 다운로드를 위한 컨트롤러 클래스 * @author 공통서비스개발팀 이삼섭 * @since 2009.06.01 * @version 1.0 * @see * *
 * << 개정이력(Modification Information) >>
 *
 *   수정일      수정자           수정내용
 *  -------    --------    ---------------------------
 *   2009.3.25  이삼섭          최초 생성
 *
 * Copyright (C) 2009 by MOPAS  All right reserved.
 * 
*/ @Controller public class EgovFileDownloadController { @Resource(name = "EgovFileMngService") private EgovFileMngService fileService; @Resource(name = "auditManageService") private AuditManageService auditManageService; private static final Logger LOGGER = LoggerFactory.getLogger(EgovFileDownloadController.class); /** * 브라우저 구분 얻기. * * @param request * @return */ private String getBrowser(HttpServletRequest request) { String header = request.getHeader("User-Agent"); if (header.indexOf("MSIE") > -1) { return "MSIE"; } else if (header.indexOf("Trident") > -1) { // IE11 문자열 깨짐 방지 return "Trident"; } else if (header.indexOf("Chrome") > -1) { return "Chrome"; } else if (header.indexOf("Opera") > -1) { return "Opera"; } return "Firefox"; } /** * Disposition 지정하기. * * @param filename * @param request * @param response * @throws Exception */ private void setDisposition(String filename, HttpServletRequest request, HttpServletResponse response) throws Exception { String browser = getBrowser(request); String dispositionPrefix = "attachment; filename="; String encodedFilename = null; if (browser.equals("MSIE")) { encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20"); } else if (browser.equals("Trident")) { // IE11 문자열 깨짐 방지 encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20"); } else if (browser.equals("Firefox")) { encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\""; } else if (browser.equals("Opera")) { encodedFilename = "\"" + new String(filename.getBytes("UTF-8"), "8859_1") + "\""; } else if (browser.equals("Chrome")) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < filename.length(); i++) { char c = filename.charAt(i); if (c > '~') { sb.append(URLEncoder.encode("" + c, "UTF-8")); } else { sb.append(c); } } encodedFilename = sb.toString(); } else { //throw new RuntimeException("Not supported browser"); throw new IOException("Not supported browser"); } response.setHeader("Content-Disposition", dispositionPrefix + encodedFilename); if ("Opera".equals(browser)) { response.setContentType("application/octet-stream;charset=UTF-8"); } } /** * 첨부파일로 등록된 파일에 대하여 다운로드를 제공한다. * * @param commandMap * @param response * @throws Exception */ @RequestMapping(value = "/cmm/fms/FileDown.do") public void cvplFileDownload(@RequestParam Map commandMap , HttpServletRequest request , HttpServletResponse response , HttpSession session ) throws Exception { String atchFileId = (String) commandMap.get("atchFileId"); String fileSn = (String) commandMap.get("fileSn"); String sessionFileId = (String)session.getAttribute("atchFileId"); if(sessionFileId != null) { if(!sessionFileId.equals(atchFileId)) { response.setCharacterEncoding("utf-8"); response.setContentType("text/html; charset=utf-8"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } } /*Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();*/ /*if (isAuthenticated) {*/ FileVO fileVO = new FileVO(); fileVO.setAtchFileId(atchFileId); fileVO.setFileSn(fileSn); FileVO fvo = fileService.selectFileInf(fileVO); if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } File uFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(fvo.getOrignlFileNm(), request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + fvo.getOrignlFileNm() + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } /*}*/ } /** * 첨부파일로 등록된 PDF파일을 미리보기 한다. * * @param commandMap * @param response * @throws Exception */ @RequestMapping(value = "/cmm/fms/pdfView.do") public void pdfView(@RequestParam Map commandMap, HttpServletRequest request, HttpServletResponse response) throws Exception { String atchFileId = (String) commandMap.get("atchFileId"); String fileSn = (String) commandMap.get("fileSn"); FileVO fileVO = new FileVO(); fileVO.setAtchFileId(atchFileId); fileVO.setFileSn(fileSn); FileVO fvo = fileService.selectFileInf(fileVO); if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } FileInputStream fis = null; BufferedOutputStream bos = null; try{ /* String pdfFileName = "C:/upload/TEST.pdf"; File pdfFile = new File(pdfFileName);*/ File pdfFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); //클라이언트 브라우져에서 바로 보는 방법(헤더 변경) response.setContentType("application/pdf"); //★ 이 구문이 있으면 [다운로드], 이 구문이 없다면 바로 target 지정된 곳에 view 해줍니다. //response.addHeader("Content-Disposition", "attachment; filename="+pdfFile.getName()+".pdf"); //파일 읽고 쓰는 건 일반적인 Write방식이랑 동일합니다. 다만 reponse 출력 스트림 객체에 write. fis = new FileInputStream(pdfFile); int size = fis.available(); //지정 파일에서 읽을 수 있는 바이트 수를 반환 byte[] buf = new byte[size]; //버퍼설정 int readCount = fis.read(buf); response.flushBuffer(); bos = new BufferedOutputStream(response.getOutputStream()); bos.write(buf, 0, readCount); bos.flush(); } catch(Exception e) { e.printStackTrace(); } finally { try{ if (fis != null) fis.close(); //close는 꼭! 반드시! if (bos != null) bos.close(); } catch (IOException e) { e.printStackTrace(); } } } /*감사/담당자 명함 다운로드*/ @RequestMapping(value = "/cmm/fms/ItsmFileDown.do") public void itsmFileDown(@RequestParam Map commandMap, HttpServletRequest request, HttpServletResponse response) throws Exception { String atchFileId = (String) commandMap.get("atchFileId"); String fileSn = (String) commandMap.get("fileSn"); FileVO fileVO = new FileVO(); fileVO.setAtchFileId(atchFileId); fileVO.setFileSn(fileSn); FileVO fvo = fileService.selectItsmFileInf(fileVO); if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } File uFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(fvo.getOrignlFileNm(), request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + fvo.getOrignlFileNm() + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /*정기점검 첨부파일 다운로드*/ @RequestMapping(value = "/cmm/fms/perFileDown.do") public void perFileDown(@RequestParam Map commandMap, HttpServletRequest request, HttpServletResponse response) throws Exception { String atchFileId = (String) commandMap.get("atchFileId"); String fileSn = (String) commandMap.get("fileSn"); FileVO fileVO = new FileVO(); fileVO.setAtchFileId(atchFileId); fileVO.setFileSn(fileSn); FileVO fvo = new FileVO(); if(null != commandMap.get("dbType")){ if("ipFile".equals((String) commandMap.get("dbType"))) { fvo = fileService.selectItsmIpFileInf(fileVO); } }else { fvo = fileService.selectItsmperFileInf(fileVO); } if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } File uFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(fvo.getOrignlFileNm(), request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + fvo.getOrignlFileNm() + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(기본)*/ @RequestMapping(value = "/cmm/fms/fileDownZipTest.do") public void fileDownZipTest(@RequestParam Map commandMap, HttpServletRequest request, HttpServletResponse response) throws Exception { // String atchFileId = (String) commandMap.get("atchFileId"); String orgnZipNm = "test.zip"; // 압축 파일명 필요.. String atchFileId = "FILE_000000000015459"; FileVO fileVO = new FileVO(); fileVO.setAtchFileId(atchFileId); List fvoList = fileService.selectFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(보안관리)*/ @RequestMapping(value = "/cmm/fms/secFileDownZip.do") public void secFileDownZip(@RequestParam Map commandMap, @ModelAttribute("sec") SecVO secVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =((String) commandMap.get("atchFileId")).split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectSecFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(사업관리)*/ @RequestMapping(value = "/cmm/fms/bizFileDownZip.do") public void bizFileDownZip(@RequestParam Map commandMap, @ModelAttribute("bizCntrtVO") BizCntrtVO bizCntrtVO, BizItemVO bizItemVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =bizItemVO.getAtchFileId().split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectBizFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(개인정보실태평가,국정원실태평가,외부감사)*/ @RequestMapping(value = "/cmm/fms/evalFileDownZip.do") public void evalFileDownZip(@RequestParam Map commandMap , @ModelAttribute("auditVO") AuditVO auditVO, @ModelAttribute("auditItemVO") AuditItemVO auditItemVO , EduVO eduVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =auditItemVO.getAtchFileIdDown().split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectEvalFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(교육회의관리)*/ @RequestMapping(value = "/cmm/fms/eduFileDownZip.do") public void eduFileDownZip(@RequestParam Map commandMap , @ModelAttribute("auditVO") AuditVO auditVO, @ModelAttribute("auditItemVO") AuditItemVO auditItemVO , EduVO eduVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =auditItemVO.getAtchFileId().split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectEvalFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(국정원실태평가 - 세부 평가지표 및 결과[파일디테일이 없어서 따로 만듬])*/ @RequestMapping(value = "/cmm/fms/evalFileDownZip2.do") public void evalFileDownZip2(@RequestParam Map commandMap , @ModelAttribute("auditVO") AuditVO auditVO, @ModelAttribute("auditItemVO") AuditItemVO auditItemVO , EduVO eduVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =auditItemVO.getAtchFileIdDown().split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectNisEvalFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(SLA관리)*/ @RequestMapping(value = "/cmm/fms/slaFileDownZip.do") public void slaFileDownZip(@RequestParam Map commandMap, @ModelAttribute("slaAutscitecVO") SlaAutscitecVO slaAutscitecVO, @ModelAttribute("slaAutItemVO") SlaAutItemVO slaAutItemVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =slaAutItemVO.getAtchFileId().split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectSLAFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 - 일괄 zip 압축(정기점검)*/ @RequestMapping(value = "/cmm/fms/perFileDownZip.do") public void perFileDownZip(@RequestParam Map commandMap, PeriFile periFileVO, PeritemVO peritemVO, PerispVO perispVO, HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =periFileVO.getAtchFileId().split(","); //리스트에 아이디 담기 for(int i=0; i fvoList = fileService.selectPerFileInfs(fileVO); // 해당 기능에 맞게 파일 조회 if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /*감사 첨부파일 다운로드 */ @RequestMapping(value = "/uss/itsm/audit/SciTecAuditItemFileDown.do") public void fileDownSciTecAuditAjax(@RequestParam Map commandMap, AuditVO auditVO, AuditItemVO auditItemVO, @RequestParam("atchFileId") String[] atchFileId, HttpServletRequest request, HttpServletResponse response ) throws Exception { String fileSn = "0"; for(String id:atchFileId) { FileVO fileVO = new FileVO(); fileVO.setAtchFileId(id); fileVO.setFileSn(fileSn); FileVO fvo = fileService.selectItsmFileInf(fileVO); if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; }else { File uFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(fvo.getOrignlFileNm(), request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + fvo.getOrignlFileNm() + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } } } /*첨부파일 다운로드 */ @RequestMapping(value = "/uss/itsm/nis/NisEvalItemFileDown.do") public void fileDownNisEvalItemAjax(@RequestParam Map commandMap, AuditVO auditVO, AuditItemVO auditItemVO, @RequestParam("atchFileId") String[] atchFileId, HttpServletRequest request, HttpServletResponse response ) throws Exception { String fileSn = "0"; for(String id:atchFileId) { FileVO fileVO = new FileVO(); fileVO.setAtchFileId(id); fileVO.setFileSn(fileSn); FileVO fvo = fileService.selectNisEvalItemFileInfo(fileVO); if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; }else { File uFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(fvo.getOrignlFileNm(), request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + fvo.getOrignlFileNm() + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } } } /* 파일 다운로드 - 일괄 zip 압축(IP관리 등)*/ @RequestMapping(value = "/cmm/fms/fileDownZip.do") public void fileDownZip(@RequestParam Map commandMap, PeriFile periFileVO, IpVO ipVO , AssetVO assetVO , HttpServletRequest request, HttpServletResponse response) throws Exception { //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); String menuNm = "IP관리"; String orgnZipNm = "IP관리.zip"; List fvoList = new ArrayList<>(); if(null != commandMap.get("dbType")){ if("ipFile".equals((String) commandMap.get("dbType"))) { //IP관리 페이지 for(String IpId : ipVO.getIpIds()) { atchFileIdList.add(IpId); } FileVO fileVO = new FileVO(); fileVO.setAtchFileIdList(atchFileIdList); fvoList = fileService.selectIpFileList(fileVO); menuNm = "IP관리" ; orgnZipNm = "IP관리.zip"; }else if("assetFile".equals((String) commandMap.get("dbType"))) { //IP관리 페이지 for(String astId : assetVO.getAstIds()) { atchFileIdList.add(astId); } FileVO fileVO = new FileVO(); fileVO.setAtchFileIdList(atchFileIdList); fvoList = fileService.selectAssertFileList(fileVO); menuNm = "자산관리" ; orgnZipNm = "자산관리.zip"; } }else { //fvoList = fileService.selectItsmperFileInf(fileVO); } if(fvoList.size() == 0){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } // buffer size int size = 1024; byte[] buf = new byte[size]; String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm; FileInputStream fis = null; ZipArchiveOutputStream zos = null; BufferedInputStream bis = null; try { // Zip 파일생성 zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm))); for ( FileVO vo : fvoList ){ zos.setEncoding("UTF-8"); //buffer에 해당파일의 stream을 입력한다. fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm()); bis = new BufferedInputStream(fis,size); //zip에 넣을 다음 entry 를 가져온다. zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm())); //준비된 버퍼에서 집출력스트림으로 write 한다. int len; while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len); bis.close(); fis.close(); zos.closeArchiveEntry(); } zos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }finally{ if( zos != null ) zos.close(); if( fis != null ) fis.close(); if( bis != null ) bis.close(); } File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(orgnZipNm, request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } //파일 다운로드 후 파일 삭제 File delFile = new File(outZipNm); delFile.delete(); } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + orgnZipNm + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } /* 파일 다운로드 체크(IP관리 등)*/ @RequestMapping(value = "/uss/itsm/ip/FileDownZipCheckAjax.do") public ModelAndView fileDownZipCheckAjax(@RequestParam Map commandMap, PeriFile periFileVO, IpVO ipVO , AssetVO assetVO ) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); List fvoList = new ArrayList<>(); if(null != commandMap.get("dbType")){ if("ipFile".equals((String) commandMap.get("dbType"))) { //IP관리 페이지 for(String IpId : ipVO.getIpIds()){ atchFileIdList.add(IpId); } FileVO fileVO = new FileVO(); fileVO.setAtchFileIdList(atchFileIdList); fvoList = fileService.selectIpFileList(fileVO); }else if("assetFile".equals((String) commandMap.get("dbType"))) { //자산관리 페이지 for(String astId : assetVO.getAstIds()){ atchFileIdList.add(astId); } FileVO fileVO = new FileVO(); fileVO.setAtchFileIdList(atchFileIdList); fvoList = fileService.selectAssertFileList(fileVO); } }else { modelAndView.addObject("result", "fail"); } if(fvoList.size() != 0){ modelAndView.addObject("result", "success"); }else { modelAndView.addObject("result", "fail"); } return modelAndView; } /* 파일 이동(개인정보실태평가,국정원실태평가,외부감사)*/ @RequestMapping(value = "/cmm/fms/EvalFileMoveAjax.do") public ModelAndView evalFileMoveAjax(@RequestParam Map commandMap , @ModelAttribute("auditVO") AuditVO auditVO, @ModelAttribute("auditItemVO") AuditItemVO auditItemVO , EduVO eduVO, HttpServletRequest request, HttpServletResponse response) throws Exception { ModelAndView modelAndView = new ModelAndView(); modelAndView.setViewName("jsonView"); //파일ID를 리스트에 담기 List atchFileIdList = new ArrayList(); //split을 이용해 아이디를 각자 배열에 담기 String[] splitStr =auditItemVO.getAtchFileIdDown().split(","); //리스트에 아이디 담기 for(int i=0; i commandMap, HttpServletRequest request, HttpServletResponse response) throws Exception { String atchFileId = (String) commandMap.get("atchFileId"); String fileSn = (String) commandMap.get("fileSn"); FileVO fileVO = new FileVO(); fileVO.setAtchFileId(atchFileId); fileVO.setFileSn(fileSn); FileVO fvo = fileService.selectItsmFileInf(fileVO); if(fvo == null){ response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); return ; } File uFile = new File(fvo.getFileStreCours(), fvo.getStreFileNm()); long fSize = uFile.length(); if (fSize > 0) { String mimetype = "application/x-msdownload"; response.setContentType(mimetype); setDisposition(fvo.getOrignlFileNm(), request, response); //response.setContentLength(fSize); BufferedInputStream in = null; BufferedOutputStream out = null; try { in = new BufferedInputStream(new FileInputStream(uFile)); out = new BufferedOutputStream(response.getOutputStream()); FileCopyUtils.copy(in, out); out.flush(); } catch (Exception ex) { LOGGER.debug("IGNORED: {}", ex.getMessage()); } finally { if (in != null) { try { in.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } if (out != null) { try { out.close(); } catch (Exception ignore) { LOGGER.debug("IGNORED: {}", ignore.getMessage()); } } } } else { response.setContentType("application/x-msdownload"); PrintWriter printwriter = response.getWriter(); printwriter.println(""); printwriter.println("


Could not get file name:
" + fvo.getOrignlFileNm() + "

"); printwriter.println("


Back

"); printwriter.println("


© webAccess"); printwriter.println(""); printwriter.flush(); printwriter.close(); } } }