egovframework.oe1.cms.cmm.web.EgovOe1DicWordController.java Source code

Java tutorial

Introduction

Here is the source code for egovframework.oe1.cms.cmm.web.EgovOe1DicWordController.java

Source

/*
 * Copyright 2010 MOPAS(Ministry of Public Administration and Security).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package egovframework.oe1.cms.cmm.web;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.jxls.transformer.XLSTransformer;

import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.util.FileCopyUtils;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
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.bind.annotation.SessionAttributes;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springmodules.validation.commons.DefaultBeanValidator;

import egovframework.oe1.cms.cmm.service.EgovOe1DicWordVO;
import egovframework.oe1.cms.cmm.service.EgovOe1DicWordService;
import egovframework.oe1.cms.com.service.EgovOe1LoginVO;
import egovframework.oe1.cms.com.service.EgovOe1MessageSource;
import egovframework.rte.fdl.excel.EgovExcelService;
import egovframework.rte.fdl.property.EgovPropertyService;
import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;

/**
 * 
 * - ?  controller ? ?.
 * 
 * ?
 * - ?  ?, , , ? .
 * - ? ? ?, ? ?.
 * @author ?1 
 * @since 2010.08.13
 * @version 1.0
 * @see
 *
 * <pre>
 *  == ?(Modification Information) ==
 *   
 *   ?      ?           
 *  -------    --------    ---------------------------
 *   2010.08.13            ?
 *
 * </pre>
 */
@Controller
public class EgovOe1DicWordController {

    /** EgovOe1DicWordService */
    @Resource(name = "egovOe1DicWordService")
    private EgovOe1DicWordService egovOe1DicWordService;

    /** EgovPropertyService */
    @Resource(name = "propertiesService")
    protected EgovPropertyService propertiesService;

    /** Validator */
    @Resource(name = "beanValidator")
    protected DefaultBeanValidator beanValidator;

    /**
    * 
    */
    /***/
    @Resource(name = "excelService")
    private EgovExcelService excelService;

    @Resource(name = "propertiesService")
    protected EgovPropertyService propertyService;

    Logger log = Logger.getLogger(this.getClass());

    /**
     *  ?
     * @param :    EgovOe1DicWordVO
     * @return : "forward:/cms/cmm/selectDicWordList.do"
     * @exception Exception
     */
    @RequestMapping(value = "/cms/cmm/selectDicWordList.do")
    public String selectDicWordList(@ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO,
            ModelMap model) throws Exception {

        log.debug(this.getClass().getName() + " ==>  ?  ");

        /** EgovPropertyService.egovOe1DicWordService */

        egovOe1DicWordVO.setPageUnit(propertiesService.getInt("pageUnit"));
        egovOe1DicWordVO.setPageSize(propertiesService.getInt("pageSize"));

        /** pageing setting */
        PaginationInfo paginationInfo = new PaginationInfo();
        paginationInfo.setCurrentPageNo(egovOe1DicWordVO.getPageIndex());
        paginationInfo.setRecordCountPerPage(egovOe1DicWordVO.getPageUnit());
        paginationInfo.setPageSize(egovOe1DicWordVO.getPageSize());

        egovOe1DicWordVO.setFirstIndex(paginationInfo.getFirstRecordIndex());
        egovOe1DicWordVO.setLastIndex(paginationInfo.getLastRecordIndex());
        egovOe1DicWordVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage());

        String authorCode = "";
        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (isAuthenticated) {
            // ? ? 
            List authorList = EgovUserDetailsHelper.getAuthorities();
            for (int i = 0; i < authorList.size(); i++) {
                if ("ROLE_ADMIN".equals(authorList.get(i).toString())) {
                    authorCode = "ROLE_ADMIN";
                    break;
                }
            }
        }
        model.addAttribute("authorCode", authorCode);

        List dicWordList = egovOe1DicWordService.selectDicWordList(egovOe1DicWordVO);
        model.addAttribute("resultList", dicWordList);

        int totCnt = egovOe1DicWordService.selectDicWordListTot(egovOe1DicWordVO);
        paginationInfo.setTotalRecordCount(totCnt);
        model.addAttribute("paginationInfo", paginationInfo);
        model.addAttribute("resultCnt", totCnt);
        return "/cms/cmm/EgovDicWordList";
    }

    /**
    *  ? ? .
    * @param EgovOe1DicWordVO - ?    VO
    * @param model
    * @return "/cms/cmm/EgovDicWordRegist"
    * @exception Exception
    */
    @RequestMapping("/cms/cmm/addDicWord.do")
    public String addDicWord(@ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO, Model model)
            throws Exception {

        log.debug(this.getClass().getName() + " ==>  ? ? ?? ");

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);

        return "/cms/cmm/EgovDicWordRegist";
    }

    /**
    *  ?
    * @param EgovOe1DicWordVO - ?   VO
    * @param status
    * @return "forward:/cms/cmm/selectDicWordList.do"
    * @exception Exception
    */

    @RequestMapping("/cms/cmm/addDicWordOK.do")
    public String addDicWordOK(@ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO,
            BindingResult bindingResult, Model model, SessionStatus status) throws Exception {

        log.debug(this.getClass().getName() + " ==>  ?");

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);

        // Server-Side Validation
        beanValidator.validate(egovOe1DicWordVO, bindingResult);
        if (bindingResult.hasErrors()) {
            model.addAttribute("egovOe1DicWordVO", egovOe1DicWordVO);
            return "/cms/cmm/addDicWord";
        }

        //
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
        egovOe1DicWordVO.setFrstRegisterId(user.getMberId());
        if (("".equals(egovOe1DicWordVO.getWrdDc())) || (egovOe1DicWordVO.getWrdDc() == null)) {
            egovOe1DicWordVO.setWrdDc(egovOe1DicWordVO.getWrdNm());
        }

        int dup_count = egovOe1DicWordService.dupCheckDicWord(egovOe1DicWordVO);

        if (dup_count > 0) {
            model.addAttribute("resultMsg", "? .  .");
            return "forward:/cms/cmm/addDicWord.do";
        }

        egovOe1DicWordService.insertDicWord(egovOe1DicWordVO);

        status.setComplete();

        if (status.isComplete()) {
            model.addAttribute("resultMsg", " ? ");
        } else {
            model.addAttribute("resultMsg", " ? ");
        }

        return "forward:/cms/cmm/selectDicWordList.do";
    }

    /**
     *  ? 
     * @param : EgovOe1DicWordVO
     * @return : "/cms/cmm/EgovDicWordDetail"
     * @exception Exception
     */
    @RequestMapping("/cms/cmm/selectDicWord.do")
    public String selectDicWord(@RequestParam("selectedId") String selectedId,
            @ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO, Model model) throws Exception {

        log.debug(this.getClass().getName() + " ==>  ?");

        //
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
        egovOe1DicWordVO.setFrstRegisterId(user.getMberId());

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);
        //selectedId VO? .
        egovOe1DicWordVO.setWrdId(selectedId);
        //? 
        EgovOe1DicWordVO egovOe1DicWordVO1 = new EgovOe1DicWordVO();
        egovOe1DicWordVO1 = egovOe1DicWordService.selectDicWord(egovOe1DicWordVO);
        model.addAttribute("egovOe1DicWordVO", egovOe1DicWordVO1);

        // ?
        if (!egovOe1DicWordVO.getFrstRegisterId().equals(user.getMberId())) {
            egovOe1DicWordService.updateRDCnt(egovOe1DicWordVO1);
        }

        return "/cms/cmm/EgovDicWordDetail";
    }

    /**
    *  ? .
    * @param id -   id
    * @param egovOe1DicWordVO - ?    VO
    * @param model
    * @return "/cms/cmm/EgovDicWordUpdt"
    * @exception Exception
    */
    @RequestMapping("/cms/cmm/updateDicWord.do")
    public String updateDicWord(@RequestParam("selectedId") String selectedId,
            @ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO, Model model) throws Exception {

        log.debug(this.getClass().getName() + " ==>  ");

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);
        //selectedId VO? .
        egovOe1DicWordVO.setWrdId(selectedId);
        //?  ? 
        model.addAttribute(egovOe1DicWordService.selectDicWord(egovOe1DicWordVO));
        return "/cms/cmm/EgovDicWordUpdt";
    }

    /**
    * ? .
    * @param egovOe1DicWordVO    -    VO
    * @param status
    * @return "forward:/cms/cmm/selectDicWordList.do"
    * @exception Exception
    */
    @RequestMapping("/cms/cmm/updateDicWordOK.do")
    public String updateDicWordOK(@RequestParam("selectedId") String selectedId,
            @ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO, BindingResult bindingResult,
            Model model, SessionStatus status) throws Exception {

        log.debug(this.getClass().getName() + " ==>   ");

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);

        beanValidator.validate(egovOe1DicWordVO, bindingResult);
        if (bindingResult.hasErrors()) {
            model.addAttribute("egovOe1DicWordVO", egovOe1DicWordVO);
            return "/cms/cmm/EgovDicWordUpdt";
        }

        //
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
        egovOe1DicWordVO.setLastUpdusrId(user.getMberId());
        if (("".equals(egovOe1DicWordVO.getWrdDc())) || (egovOe1DicWordVO.getWrdDc() == null)) {
            egovOe1DicWordVO.setWrdDc(egovOe1DicWordVO.getWrdNm());
        }

        //selectedId VO? .
        //System.out.println(" ? ?++++++++++++++++++++++++++++++++"+selectedId);

        egovOe1DicWordVO.setWrdId(selectedId);
        egovOe1DicWordService.updateDicWord(egovOe1DicWordVO);
        status.setComplete();

        if (status.isComplete()) {
            model.addAttribute("resultMsg", "  ");
        } else {
            model.addAttribute("resultMsg", "  ");
        }
        return "forward:/cms/cmm/selectDicWordList.do";
    }

    /**
    * ? .
    * @param egovOe1DicWordVO -    VO
    * @param status
    * @return "forward:/cms/cmm/selectDicWordList.do"
    * @exception Exception
    */
    @RequestMapping("/cms/cmm/removeDicWordOK.do")
    public String removeDicWordOK(@RequestParam("selectedId") String selectedId,
            @ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO, Model model,
            SessionStatus status) throws Exception {

        log.debug(this.getClass().getName() + " ==>  ");

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);

        egovOe1DicWordVO.setWrdId(selectedId);

        egovOe1DicWordService.deleteDicWord(egovOe1DicWordVO);

        status.setComplete();

        if (status.isComplete()) {
            model.addAttribute("resultMsg", "  ");
        } else {
            model.addAttribute("resultMsg", "  ");
        }

        return "forward:/cms/cmm/selectDicWordList.do";
    }

    /**
    *   ?  ??
    * @param EgovOe1DicWordVO - ?    VO
    * @param model
    * @return "/cms/cmm/EgovDicWordExcelRegist"
    * @exception Exception
    */
    @RequestMapping("/cms/cmm/addDicWordExcel.do")
    public String addDicWordExcel(@ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO,
            Model model) throws Exception {

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        //?   ?   ??.
        model.addAttribute("searchMode", egovOe1DicWordVO);

        return "/cms/cmm/EgovDicWordExcelRegist";
    }

    /**
    *   ? 
    * @param EgovOe1DicWordVO - ?    VO
    * @param model
    * @return "forward:/cms/cmm/selectDicWordList.do"
    * @exception Exception
    */
    @RequestMapping("/cms/cmm/addDicWordExcelOK.do")
    public String addDicWordExcelRegister(final HttpServletRequest request,
            @ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO, BindingResult bindingResult,
            Model model, SessionStatus status) throws Exception {

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }

        if (bindingResult.hasErrors()) {
            model.addAttribute("egovOe1DicWordVO", egovOe1DicWordVO);
            return "/cms/cmm/addDicWord";
        }

        model.addAttribute("searchMode", egovOe1DicWordVO);

        //
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();

        try {

            final MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
            final Map<String, MultipartFile> files = multiRequest.getFileMap();

            Iterator<Entry<String, MultipartFile>> itr = files.entrySet().iterator();
            MultipartFile file;

            String filePath = "";

            while (itr.hasNext()) {
                Entry<String, MultipartFile> entry = itr.next();

                file = entry.getValue();
                if (!"".equals(file.getOriginalFilename())) {

                    String _storePath = propertyService.getString("Globals.fileStorePath");

                    File saveFolder = new File(_storePath);
                    if (!saveFolder.exists() || saveFolder.isFile()) {
                        saveFolder.mkdirs();
                    }

                    String orginFileName = file.getOriginalFilename();
                    int _index = orginFileName.lastIndexOf(".");
                    String fileName = orginFileName.substring(0, _index);
                    String fileExt = orginFileName.substring(_index + 1);
                    long _size = file.getSize();

                    if (!"".equals(orginFileName)) {
                        filePath = _storePath + File.separator + "StandardWordStatus.xls";
                        file.transferTo(new File(filePath));
                    }

                    //System.out.println("?=====>"+orginFileName);
                    //System.out.println("?=====>"+fileName);
                    //System.out.println("?=====>"+fileExt);
                    //System.out.println("??=====>"+_size);
                    //System.out.println("??=====>"+filePath);

                    if ((fileExt.equals("xls") || fileExt.equals("xlsx"))
                            && (filePath != null && !"".equals(filePath))) {

                        HSSFWorkbook wbT = excelService.loadWorkbook(filePath);
                        HSSFSheet sheetT = wbT.getSheet(wbT.getSheetName(0));

                        HSSFRow rowValue = sheetT.getRow(2);
                        HSSFCell cellValue0 = rowValue.getCell(0); //
                        HSSFCell cellValue1 = rowValue.getCell(1); //?(Full Name)
                        HSSFCell cellValue2 = rowValue.getCell(2); //?
                        HSSFCell cellValue3 = rowValue.getCell(3); //
                        HSSFCell cellValue5 = rowValue.getCell(5); //?
                        String wordNm = (cellValue0 + "").trim();
                        String engNm = (cellValue1 + "").trim();
                        String wordNmEngAbrv = (cellValue2 + "").trim();
                        String wordDc = (cellValue3 + "").trim();
                        String useAt = (cellValue5 + "").trim();

                        //System.out.println("wordNm====>"+wordNm);
                        //System.out.println("engNm====>"+engNm);
                        //System.out.println("wordNmEngAbrv====>"+wordNmEngAbrv);
                        //System.out.println("wordDc====>"+wordDc);
                        //System.out.println("useAt====>"+useAt);

                        if (!"".equals(wordNm) || !"?(Full Name)".equals(engNm)
                                || !"?".equals(wordNmEngAbrv) || !"".equals(wordDc)
                                || !"?".equals(useAt)) {
                            model.addAttribute("resultMsg",
                                    " EXCEL ?? .   .");
                            return "/cms/cmm/EgovDicWordExcelRegist";
                        }

                        List<EgovOe1DicWordVO> dicWordListVO = new ArrayList<EgovOe1DicWordVO>();

                        for (int i = 3; i <= sheetT.getLastRowNum(); i++) {
                            HSSFRow row1 = sheetT.getRow(i);
                            HSSFCell cell0 = row1.getCell(0); //
                            HSSFCell cell1 = row1.getCell(1); //?
                            HSSFCell cell2 = row1.getCell(2); //?
                            HSSFCell cell3 = row1.getCell(3); //
                            HSSFCell cell5 = row1.getCell(5); //

                            wordNm = (cell0 + "").trim();
                            engNm = (cell1 + "").trim();
                            wordNmEngAbrv = (cell2 + "").trim();
                            wordDc = (cell3 + "").trim();
                            useAt = (cell5 + "").trim();

                            if ((!"".equals(wordNm) && wordNm != null) && (!"".equals(engNm) && engNm != null)
                                    && (!"".equals(wordNmEngAbrv) && wordNmEngAbrv != null)
                                    && (!"".equals(wordDc) && wordDc != null)) {
                                EgovOe1DicWordVO egovOe1DicWordExcelVO = new EgovOe1DicWordVO();
                                egovOe1DicWordExcelVO.setWrdNm(wordNm);
                                egovOe1DicWordExcelVO.setWrdEngNm(engNm);
                                egovOe1DicWordExcelVO.setWrdEngAbrv(wordNmEngAbrv);
                                egovOe1DicWordExcelVO.setWrdDc(wordDc);
                                if (useAt.equals("")) {
                                    egovOe1DicWordExcelVO.setUseAt("Y");
                                } else {
                                    egovOe1DicWordExcelVO.setUseAt("N");
                                }
                                egovOe1DicWordExcelVO.setFrstRegisterId(user.getMberId());

                                dicWordListVO.add(egovOe1DicWordExcelVO);

                                for (int kk = 0; kk < dicWordListVO.size(); kk++) {
                                    if (kk > 1) {
                                        if (dicWordListVO.get(kk - 1).getWrdNm().trim().equals(wordNm)) {
                                            model.addAttribute("resultMsg", (i + 1)
                                                    + "??? ? . ?    .");
                                            return "/cms/cmm/EgovDicWordExcelRegist";
                                        }
                                        if (dicWordListVO.get(kk - 1).getWrdEngNm().trim().equals(engNm)) {
                                            model.addAttribute("resultMsg", (i + 1)
                                                    + "??? ?(Full Name)? . ?    .");
                                            return "/cms/cmm/EgovDicWordExcelRegist";
                                        }
                                        if (dicWordListVO.get(kk - 1).getWrdEngAbrv().trim()
                                                .equals(wordNmEngAbrv)) {
                                            model.addAttribute("resultMsg", (i + 1)
                                                    + "??? ?? . ?    .");
                                            return "/cms/cmm/EgovDicWordExcelRegist";
                                        }
                                    } else if (kk == 1) {
                                        if (dicWordListVO.get(kk - 1).getWrdNm().trim().equals(wordNm)) {
                                            model.addAttribute("resultMsg", (i + 1)
                                                    + "??? ? . ?    .");
                                            return "/cms/cmm/EgovDicWordExcelRegist";
                                        }
                                        if (dicWordListVO.get(kk - 1).getWrdEngNm().trim().equals(engNm)) {
                                            model.addAttribute("resultMsg", (i + 1)
                                                    + "??? ?(Full Name)? . ?    .");
                                            return "/cms/cmm/EgovDicWordExcelRegist";
                                        }
                                        if (dicWordListVO.get(kk - 1).getWrdEngAbrv().trim()
                                                .equals(wordNmEngAbrv)) {
                                            model.addAttribute("resultMsg", (i + 1)
                                                    + "??? ?? . ?    .");
                                            return "/cms/cmm/EgovDicWordExcelRegist";
                                        }
                                    }
                                }

                            } else {
                                if ("".equals(wordNm) || wordNm == null) {
                                    model.addAttribute("resultMsg", (i + 1)
                                            + "??? ? . ?    .");
                                }
                                if ("".equals(engNm) || engNm == null) {
                                    model.addAttribute("resultMsg", (i + 1)
                                            + "??? ?(Full Name)? . ?    .");
                                }
                                if ("".equals(wordNmEngAbrv) || wordNmEngAbrv == null) {
                                    model.addAttribute("resultMsg", (i + 1)
                                            + "??? ?? . ?    .");
                                }
                                if ("".equals(wordDc) || wordDc == null) {
                                    model.addAttribute("resultMsg", (i + 1)
                                            + "??? ? . ?    .");
                                }
                                return "/cms/cmm/EgovDicWordExcelRegist";
                            }
                        }

                        // ? ??    .
                        egovOe1DicWordService.deleteExcelDicWord();

                        List<EgovOe1DicWordVO> list = dicWordListVO;
                        for (EgovOe1DicWordVO dicWordVo : list) {
                            egovOe1DicWordService.insertExcelDicWord(dicWordVo);
                        }

                    } else {
                        model.addAttribute("resultMsg",
                                " EXCEL ?? .   .");
                        return "/cms/cmm/EgovDicWordExcelRegist";
                    }
                }
            }

            status.setComplete();

            model.addAttribute("resultMsg", " Excel ? ?  ");

            return "forward:/cms/cmm/selectDicWordList.do";

        } catch (Exception ex) {

            model.addAttribute("resultMsg",
                    " Excel ? ? ,  Excel ? ? ?. ");

            return "/cms/cmm/EgovDicWordExcelRegist";
        }
    }

    /**
     *  ? Excel 
     * @param : EgovOe1DicWordVO
     * @exception Exception
     */
    @RequestMapping(value = "/cms/cmm/addDicWordExcelDwon.do")
    public String selectDicWordListExcelDown(@ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO,
            HttpServletRequest request, HttpServletResponse response) throws Exception {

        log.debug(this.getClass().getName() + " ==>  ? Excel ");

        Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
        if (!isAuthenticated) {
            return "/cms/com/EgovLoginUsr"; //? ??
        }
        EgovOe1LoginVO user = (EgovOe1LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
        java.util.Calendar cal = java.util.Calendar.getInstance();
        String year = cal.get(java.util.Calendar.YEAR) + "";
        String month = (cal.get(java.util.Calendar.MONTH) + 1) + "";
        String date = cal.get(java.util.Calendar.DATE) + "";
        year = year;
        month = month.length() == 1 ? "0" + month : month;
        date = date.length() == 1 ? "0" + date : date;

        //?? 
        List<EgovOe1DicWordVO> list = egovOe1DicWordService.selectDicWordListExcelDown(egovOe1DicWordVO);
        // 
        String _storePath = propertyService.getString("Globals.excelStorePath");
        //  ? ?
        String _storePathName = _storePath + File.separator + "StandardWordStatus.xls";

        List<EgovOe1DicWordVO> dicWordListVO = new ArrayList<EgovOe1DicWordVO>();

        for (EgovOe1DicWordVO dicWordVo : list) {

            EgovOe1DicWordVO dicWordValueVO = new EgovOe1DicWordVO();

            dicWordValueVO.setWrdNm(dicWordVo.getWrdNm());
            dicWordValueVO.setWrdEngNm(dicWordVo.getWrdEngNm());
            dicWordValueVO.setWrdEngAbrv(dicWordVo.getWrdEngAbrv());
            dicWordValueVO.setWrdDc(dicWordVo.getWrdDc());
            dicWordValueVO.setFrstRegisterPnttm(dicWordVo.getFrstRegisterPnttm());
            if ("Y".equals(dicWordVo.getUseAt())) {
                dicWordValueVO.setUseAt("");
            } else {
                dicWordValueVO.setUseAt("");
            }

            dicWordListVO.add(dicWordValueVO);
        }

        //?  

        Map<String, Object> beans = new HashMap<String, Object>();
        beans.put("userName", user.getMberNm());
        beans.put("today", year + "." + month + "." + date);
        beans.put("dicWordListVO", dicWordListVO);
        XLSTransformer transformer = new XLSTransformer();

        File output = File.createTempFile("aaa", ".tmp");

        transformer.transformXLS(_storePathName, beans, output.getAbsolutePath());

        String mimetype = "application/x-msdownload";

        response.setBufferSize((int) output.length());
        response.setContentType(mimetype);

        setDisposition("StandardWordStatus.xls", request, response);

        BufferedInputStream in = null;
        BufferedOutputStream out = null;

        try {
            in = new BufferedInputStream(new FileInputStream(output));
            out = new BufferedOutputStream(response.getOutputStream());

            FileCopyUtils.copy(in, out);
            out.flush();
        } catch (Exception ex) {
            ex.printStackTrace();
            // ? Exception  
            // Connection reset by peer: socket write error
            //System.out.println("IGNORED: " + ex.getMessage());
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception ignore) {
                    ignore.printStackTrace();
                    //System.out.println("IGNORED: " + ignore.getMessage());
                }
            }
            if (out != null) {
                try {
                    out.close();
                } catch (Exception ignore) {
                    ignore.printStackTrace();
                    //System.out.println("IGNORED: " + ignore.getMessage());
                }
            }
        }

        return "";

    }

    /**
    * ?  .
    * 
    * @param request
    * @return String
    */
    private String getBrowser(HttpServletRequest request) {
        String header = request.getHeader("User-Agent");
        if (header.indexOf("MSIE") > -1) {
            return "MSIE";
        } 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
     * @exception 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("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");
        }
    }

    /**
     *  Excel  
     * @param : EgovOe1DicWordVO
     * @exception Exception
     */
    @RequestMapping(value = "/cms/cmm/addDicWordExcelTempletDwon.do")
    public void selectDicWordExcelTempletDown(@ModelAttribute("egovOe1DicWordVO") EgovOe1DicWordVO egovOe1DicWordVO,
            HttpServletRequest request, HttpServletResponse response) throws Exception {

        log.debug(this.getClass().getName() + " ==>  Excel  ");

        // 
        String _storePath = propertyService.getString("Globals.excelStoreDownPath");

        File uFile = new File(_storePath, "StandardWordStatus.xls");
        int fSize = (int) uFile.length();

        if (fSize > 0) {
            String mimetype = "application/x-msdownload";

            response.setBufferSize(fSize);
            response.setContentType(mimetype);
            //response.setHeader("Content-Disposition", "attachment; filename=\"" + URLEncoder.encode(fvo.getOrignlFileNm(), "utf-8") + "\"");
            setDisposition("StandardWordStatus.xls", request, response);
            response.setContentLength(fSize);

            /*
             * FileCopyUtils.copy(in, response.getOutputStream());
             * in.close(); 
             * response.getOutputStream().flush();
             * response.getOutputStream().close();
             */
            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) {
                //ex.printStackTrace();
                // ? Exception  
                // Connection reset by peer: socket write error
                log.debug("IGNORED: " + ex.getMessage());
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (Exception ignore) {
                        // no-op
                        log.debug("IGNORED: " + ignore.getMessage());
                    }
                }
                if (out != null) {
                    try {
                        out.close();
                    } catch (Exception ignore) {
                        // no-op
                        log.debug("IGNORED: " + ignore.getMessage());
                    }
                }
            }
        }
    }

}