com.fota.pushMgt.controller.PushFotaCTR.java Source code

Java tutorial

Introduction

Here is the source code for com.fota.pushMgt.controller.PushFotaCTR.java

Source

/*
 * M2M ServiceFOTA ONM version 1.0
 *
 *  Copyright  2014 kt corp. All rights reserved.
 *
 *  This is a proprietary software of kt corp, and you may not use this file except in
 *  compliance with license agreement with kt corp. Any redistribution or use of this
 *  software, with or without modification shall be strictly prohibited without prior written
 *  approval of kt corp, and the copyright notice above does not evidence any actual or
 *  intended publication of such software.
 */
package com.fota.pushMgt.controller;

import java.util.ArrayList;
import java.util.List;

//import javax.persistence.criteria.CriteriaBuilder.In;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;

import com.fota.comm.util.Masking;
import com.fota.comm.util.VoV;
import com.fota.comm.vo.PushResBasVO;
import com.fota.commMgt.vo.UserLoginVO;
import com.fota.devMgt.service.DevMgtSVC;
import com.fota.devMgt.vo.DevSearchVO;
import com.fota.pushMgt.service.PushFotaSVC;
import com.fota.pushMgt.vo.PushMgtVO;

//import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.web.util.HtmlUtils;

/**
 * PUSH ? FOTA ? 
 * @author yms
 *
 */
@Controller
//@RequestMapping("/commonDeviceQuality/pushMgt")
@RequestMapping("/commonFota/pushMgt")
public class PushFotaCTR {

    private static final Logger logger = LoggerFactory.getLogger(PushFotaCTR.class);

    /**
     * @uml.property  name="mySVC"
     * @uml.associationEnd  readOnly="true"
     */
    @Autowired
    PushFotaSVC mySVC;

    /**
     * @uml.property  name="devSVC"
     * @uml.associationEnd  readOnly="true"
     */
    @Autowired
    DevMgtSVC devSVC;

    /**
     * @uml.property  name="ajaxMainView"
     * @uml.associationEnd  readOnly="true"
     */
    @Autowired
    private MappingJacksonJsonView ajaxMainView;

    @RequestMapping(value = "/pushFota")
    public String getPushActionView(HttpServletRequest request, HttpServletResponse response, Model model)
            throws Exception {
        //      if (!request.getServletPath().equals("/commonDeviceQuality/pushMgt/pushFota")) {
        if (!request.getServletPath().equals("/commonFota/pushMgt/pushFota")) {
            response.setStatus(403);
            return "redirect:/lresources/errorPage.jsp";
            //         return null;
        }

        return "pushMgt/pushFota";
    }

    /**
     * PUSH FOTA ?? ? ? 
     * @param vo
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("/searchPushFota")
    @ResponseBody
    public ModelAndView searchPushFota(@ModelAttribute("pushMgtVO") PushMgtVO vo, ModelMap model) throws Exception {
        // validation check
        vo.setBizTypeId(VoV.valid(vo.getBizTypeId(), 30, 4));
        vo.setSvcId(VoV.valid(vo.getSvcId(), 30, 4));
        vo.setDevMakerId(VoV.valid(vo.getDevMakerId(), 30, 4));
        vo.setDevModelId(VoV.valid(vo.getDevModelId(), 30, 4));
        vo.setModemModelId(VoV.valid(vo.getModemModelId(), 30, 4));
        vo.setClientNm(VoV.valid(vo.getClientNm(), 50, 2));
        vo.setDealerNm(VoV.valid(vo.getDealerNm(), 50, 2));
        vo.setCtn(VoV.valid(vo.getCtn(), 20, 4));
        vo.setSendResultCd(VoV.valid(vo.getSendResultCd(), 1));
        vo.setFotaType(VoV.valid(vo.getFotaType(), 50));
        if (!vo.getFotaType().equals("") && !vo.getFotaType().equals("PUSH") && !vo.getFotaType().equals("POLLING")
                && !vo.getFotaType().equals("PUSHPOLLING"))
            throw new Exception();

        vo.setSendDtFrom(VoV.valid(vo.getSendDtFrom()));
        vo.setSendDtTo(VoV.valid(vo.getSendDtTo()));
        //-------------------

        List<PushMgtVO> rs = mySVC.searchPushFota(vo);

        // -  ?   java-Ctrl ?  - DMS ?
        PushMgtVO tempVo;
        if (rs != null && rs.size() > 0) {
            for (int i = 0; i < rs.size(); i++) {
                tempVo = rs.get(i);

                if (tempVo.getCtn() != null && !tempVo.getCtn().isEmpty()) {
                    tempVo.setCtn(Masking.convertCtn(tempVo.getCtn()));
                }

                // ?? DB ?  ?  
                //            if(tempVo.getClientNm() != null && !tempVo.getClientNm().isEmpty()) {
                //               tempVo.setClientNm(Masking.convertClientName(tempVo.getClientNm()));
                //            }
            }
        }

        model.addAttribute("gridData", rs);

        model.addAttribute("resultsSize", vo.getTotalCnt());
        model.addAttribute("page", vo.getCurPage());
        model.addAttribute("totalPage", vo.getMaxViewPage());

        return new ModelAndView(ajaxMainView, model);
    }

    /**
     * push  ?? push  ?? ? (,  ??)
     * MenuMgtInterceptor  ? PushFotaRequestCTR.java  ??
     * @param vo
     * @param model
     * @return
     * @throws Exception
     */
    //   @RequestMapping("/addResFota")
    //   @ResponseBody
    //   public ModelAndView addRes(
    //                        HttpServletRequest request,
    //                        @ModelAttribute("pushResBasVO") PushResBasVO vo,
    //                        ModelMap model) 
    //   throws Exception{
    //      // TODO : ? post urlencoded  ,  ?  ?  .    .
    //      int max = Integer.valueOf(request.getParameter("selectionCnt"));
    //      String t = "";
    //      String devId = "";
    //      List<String> idList = new ArrayList<String>();
    //      for (int i = 1; i <= max; i++) {
    //         t = "id" + i;
    //
    //         // validation check
    //         devId = VoV.valid(request.getParameter(t), 30, 4);
    //         //-------------------
    //         
    //         idList.add(devId);
    //      }
    //      
    //      vo.setUserId(((UserLoginVO)request.getSession().getAttribute("userInfo")).getUserId());
    //      vo.setPushType("F");
    //      vo.setPushRsvYn(request.getParameter("pushRsvYn"));
    //      if (vo.getPushRsvYn().equals("Y")) {
    //         vo.setResDate(request.getParameter("resDate"));
    //         vo.setResClock(String.format("%02d", Integer.parseInt(request.getParameter("resClock"))));
    //         vo.setResMinute(String.format("%02d", Integer.parseInt(request.getParameter("resMinute"))));
    //      }
    //      mySVC.addRes(idList, vo);
    //
    //      return new ModelAndView (ajaxMainView, model);
    //   }

    /**
     * push  ?? push  ?? ? (,  ??)
     * @param vo
     * @param model
     * @return
     * @throws Exception
     */
    /*@RequestMapping("/deleteResFota")
    @ResponseBody
    public ModelAndView deleteRes(
                    HttpServletRequest request,
                    @ModelAttribute("pushResBasVO") PushResBasVO vo,
                    ModelMap model) 
    throws Exception{
           
       // TODO : ? post urlencoded  ,  ?  ?  .    .
       int max = Integer.valueOf(request.getParameter("selectionCnt"));
       String t = "";
       String devId = "";
       List<String> idList = new ArrayList<String>();
       for (int i = 1; i <= max; i++) {
     t = "resId" + i;
        
     // validation check
     devId = VoV.valid(request.getParameter(t), 30, 4);
     //-------------------
         
     idList.add(devId);
       }
           
       mySVC.deleteRes(idList);
        
       return new ModelAndView (ajaxMainView, model);
    }
    */

    /**
     * push  ?? push  ?? ? (,  ??)
     * MenuMgtInterceptor  ? PushFOTACTR -> PushFotaRequestCTR.java  ??
     * @param vo
     * @param model
     * @return
     * @throws Exception
     */
    //   @RequestMapping("/deleteResFota")
    //   @ResponseBody
    //   public ModelAndView deleteRes(
    //                        HttpServletRequest request,
    //                        @ModelAttribute("pushResBasVO") PushResBasVO vo,
    //                        ModelMap model) 
    //   throws Exception{
    //      
    //      // TODO : ? post urlencoded  ,  ?  ?  .    .
    //      int max = Integer.valueOf(request.getParameter("selectionCnt"));
    //      String t = "";
    //      String devId = "";
    //      List<Integer> idList = new ArrayList<Integer>();
    //      for (int i = 1; i <= max; i++) {
    //         t = "resId" + i;
    //
    //         // validation check
    //         devId = VoV.valid(request.getParameter(t), 30, 4);
    //         //-------------------
    //         int devIdVal = Integer.parseInt(devId);
    //         idList.add(devIdVal);
    //      }
    //      
    //      mySVC.deleteRes(idList);
    //
    //      return new ModelAndView (ajaxMainView, model);
    //   }

    /**
     *  ? ? push  ? ? 
     * MenuMgtInterceptor ? ?
     * PushFotaHistDetailCTR.java  ??
     * @param vo
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("/pushFotaHistDetailDev")
    @ResponseBody
    public ModelAndView pushHistDetailDev(HttpServletRequest request,
            @ModelAttribute("pushResBasVO") PushResBasVO vo, ModelMap model) throws Exception {
        // validation check
        vo.setDevId(VoV.valid(vo.getDevId(), 30, 4));
        //-------------------

        // ? ? 
        DevSearchVO devVO = new DevSearchVO();
        devVO.setDevId(vo.getDevId());
        devVO = devSVC.getDevInfo(devVO);
        devVO.setClientNm(HtmlUtils.htmlUnescape(devVO.getClientNm()));
        devVO.setDealerNm(HtmlUtils.htmlUnescape(devVO.getDealerNm()));
        model.addAttribute("devInfo", devVO);

        // ? ? 
        model.addAttribute("gridData", mySVC.pushHistDetailDev(vo));

        return new ModelAndView(ajaxMainView, model);
    }

}